@@ -46,7 +46,7 @@ public class AuthorizationPluginClassLoader extends ClassLoader {
46
46
private final Map <String , Class > cache = new HashMap <>();
47
47
48
48
private static final Logger LOGGER = LoggerFactory .getLogger (AuthorizationPluginClassLoader .class );
49
- private final static String [] classWhitelist = new String []{
49
+ private final static String [] CLASS_WHITELIST = new String []{
50
50
"org.opensolaris.opengrok.configuration.Group" ,
51
51
"org.opensolaris.opengrok.configuration.Project" ,
52
52
"org.opensolaris.opengrok.configuration.RuntimeEnvironment" ,
@@ -55,7 +55,7 @@ public class AuthorizationPluginClassLoader extends ClassLoader {
55
55
"org.opensolaris.opengrok.logger.*" ,
56
56
};
57
57
58
- private final static String [] packageBlacklist = new String []{
58
+ private final static String [] PACKAGE_BLACKLIST = new String []{
59
59
"java" ,
60
60
"javax" ,
61
61
"org.w3c" ,
@@ -139,8 +139,8 @@ private byte[] loadBytes(InputStream in) throws IOException {
139
139
}
140
140
141
141
private boolean checkWhiteList (String name ) {
142
- for (int i = 0 ; i < classWhitelist .length ; i ++) {
143
- String pattern = classWhitelist [i ];
142
+ for (int i = 0 ; i < CLASS_WHITELIST .length ; i ++) {
143
+ String pattern = CLASS_WHITELIST [i ];
144
144
pattern = pattern .replaceAll ("\\ ." , "\\ \\ ." );
145
145
pattern = pattern .replaceAll ("\\ *" , ".*" );
146
146
if (name .matches (pattern )) {
@@ -155,18 +155,18 @@ private void checkClassname(String name) throws SecurityException {
155
155
&& !checkWhiteList (name )) {
156
156
throw new SecurityException ("Tried to load a blacklisted class \" " + name + "\" \n "
157
157
+ "Allowed classes from opengrok package are only: "
158
- + Arrays .toString (classWhitelist ));
158
+ + Arrays .toString (CLASS_WHITELIST ));
159
159
}
160
160
}
161
161
162
162
private void checkPackage (String name ) throws SecurityException {
163
- for (int i = 0 ; i < packageBlacklist .length ; i ++) {
164
- if (name .startsWith (packageBlacklist [i ] + "." )) {
163
+ for (int i = 0 ; i < PACKAGE_BLACKLIST .length ; i ++) {
164
+ if (name .startsWith (PACKAGE_BLACKLIST [i ] + "." )) {
165
165
throw new SecurityException ("Tried to load a class \" " + name
166
166
+ "\" to a blacklisted package "
167
- + "\" " + packageBlacklist [i ] + "\" \n "
167
+ + "\" " + PACKAGE_BLACKLIST [i ] + "\" \n "
168
168
+ "Disabled packages are: "
169
- + Arrays .toString (packageBlacklist ));
169
+ + Arrays .toString (PACKAGE_BLACKLIST ));
170
170
}
171
171
}
172
172
}
@@ -182,8 +182,8 @@ private void checkPackage(String name) throws SecurityException {
182
182
* <li>loading from .jar files</li>
183
183
* </ol>
184
184
*
185
- * Package blacklist: {@link #packageBlacklist }.<br />
186
- * Classes whitelist: {@link #classWhitelist }.
185
+ * Package blacklist: {@link #PACKAGE_BLACKLIST }.<br />
186
+ * Classes whitelist: {@link #CLASS_WHITELIST }.
187
187
*
188
188
* @param name class name
189
189
* @return loaded class or null
@@ -206,8 +206,8 @@ public Class loadClass(String name) throws ClassNotFoundException, SecurityExcep
206
206
* <li>loading from .jar files</li>
207
207
* </ol>
208
208
*
209
- * Package blacklist: {@link #packageBlacklist }.<br />
210
- * Classes whitelist: {@link #classWhitelist }.
209
+ * Package blacklist: {@link #PACKAGE_BLACKLIST }.<br />
210
+ * Classes whitelist: {@link #CLASS_WHITELIST }.
211
211
*
212
212
* @param name class name
213
213
* @param resolveIt if the class should be resolved
0 commit comments