Skip to content

Commit 42b9907

Browse files
author
Vladimir Kotal
committed
do not automatically add plugins not found in the configuration
fixes #1874
1 parent 60cc181 commit 42b9907

File tree

4 files changed

+60
-58
lines changed

4 files changed

+60
-58
lines changed

src/org/opensolaris/opengrok/authorization/AuthorizationFramework.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -277,36 +277,36 @@ protected void addPlugin(AuthorizationStack stack, AuthorizationEntity entity) {
277277
}
278278

279279
/**
280-
* Add a plugin into the plugin stack. This has the same effect as invoking
280+
* Add a plug-in into the plug-in stack. This has the same effect as invoking
281281
* addPlugin(stack, IAuthorizationPlugin, REQUIRED).
282282
*
283283
* @param stack the stack
284-
* @param plugin the authorization plugin
284+
* @param plugin the authorization plug-in
285285
*/
286286
public void addPlugin(AuthorizationStack stack, IAuthorizationPlugin plugin) {
287287
addPlugin(stack, plugin, AuthControlFlag.REQUIRED);
288288
}
289289

290290
/**
291-
* Add a plugin into the plugin array.
291+
* Add a plug-in into the plug-in array.
292292
*
293293
* <h3>Configured plugin</h3>
294-
* For plugin which have an entry in configuration, the new plugin is put in
295-
* the place respecting the user-defined order of execution.
294+
* For plug-in that has an entry in configuration, the new plug-in is put
295+
* in the place respecting the user-defined order of execution.
296296
*
297297
* <h3>New plugin</h3>
298298
* If there is no entry in configuration for this class, the plugin is
299299
* appended to the end of the plugin stack with flag <code>flag</code>
300+
*
301+
* <p><b>The plug-in's load method is NOT invoked at this point</b></p>
300302
*
301-
* <p>
302-
* <b>The plugin's load method is NOT invoked at this point</b></p>
303-
*
304-
* This has the same effect as invoking addPlugin(new
305-
* AuthorizationEntity(stack, flag, getClassName(plugin), plugin).
303+
* This has the same effect as invoking
304+
* {@code addPlugin(new AuthorizationEntity(stack, flag,
305+
* getClassName(plugin), plugin)}.
306306
*
307307
* @param stack the stack
308-
* @param plugin the authorization plugin
309-
* @param flag the flag for the new plugin
308+
* @param plugin the authorization plug-in
309+
* @param flag the flag for the new plug-in
310310
*/
311311
public void addPlugin(AuthorizationStack stack, IAuthorizationPlugin plugin, AuthControlFlag flag) {
312312
if (stack != null) {
@@ -452,15 +452,15 @@ protected List<Class> getInterfaces(Class c) {
452452
*/
453453
private void loadClasses(AuthorizationStack stack, List<File> classfiles, List<File> jarfiles) {
454454
IAuthorizationPlugin pf;
455+
455456
for (File file : classfiles) {
456457
String classname = getClassName(file);
457458
if (classname.isEmpty()) {
458459
continue;
459460
}
460-
// load the class in memory and try to find a configured space for this class
461-
if ((pf = handleLoadClass(classname)) != null && !stack.setPlugin(pf)) {
462-
// if there is not configured space -> append it to the stack
463-
addPlugin(stack, pf);
461+
// Load the class in memory and try to find a configured space for this class.
462+
if ((pf = handleLoadClass(classname)) != null) {
463+
stack.setPlugin(pf);
464464
}
465465
}
466466

@@ -473,10 +473,9 @@ private void loadClasses(AuthorizationStack stack, List<File> classfiles, List<F
473473
if (!entry.getName().endsWith(".class") || classname.isEmpty()) {
474474
continue;
475475
}
476-
// load the class in memory and try to find a configured space for this class
477-
if ((pf = handleLoadClass(classname)) != null && !stack.setPlugin(pf)) {
478-
// if there is not configured space -> append it to the stack
479-
addPlugin(stack, pf);
476+
// Load the class in memory and try to find a configured space for this class.
477+
if ((pf = handleLoadClass(classname)) != null) {
478+
stack.setPlugin(pf);
480479
}
481480
}
482481
} catch (IOException ex) {

src/org/opensolaris/opengrok/web/AuthorizationFilter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) thr
6161
} else {
6262
LOGGER.log(Level.INFO, "Access denied for URI: {0}", httpReq.getRequestURI());
6363
}
64+
6465
/**
6566
* Add the request to the statistics. This is called just once for a
6667
* single request otherwise the next filter will count the same
@@ -73,10 +74,12 @@ public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) thr
7374
config.getEnv().getStatistics().addRequest("requests_forbidden");
7475
config.getEnv().getStatistics().addRequestTime("requests_forbidden",
7576
System.currentTimeMillis() - processTime);
77+
7678
if (!config.getEnv().getConfiguration().getForbiddenIncludeFileContent().isEmpty()) {
7779
sr.getRequestDispatcher("/eforbidden").forward(sr, sr1);
7880
return;
7981
}
82+
8083
httpRes.sendError(HttpServletResponse.SC_FORBIDDEN, "Access forbidden");
8184
return;
8285
}

0 commit comments

Comments
 (0)