yoavs 2004/07/28 14:31:16
Modified: catalina/src/share/org/apache/catalina/realm JAASRealm.java
webapps/docs changelog.xml
Log:
Addressed Bugzilla 29406, JAASRealm using context ClassLoader.
Revision Changes Path
1.7 +40 -5
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JAASRealm.java
Index: JAASRealm.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/JAASRealm.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JAASRealm.java 27 Feb 2004 14:58:45 -0000 1.6
+++ JAASRealm.java 28 Jul 2004 21:31:16 -0000 1.7
@@ -90,6 +90,7 @@
* </ul>
*
* @author Craig R. McClanahan
+ * @author Yoav Shapira
* @version $Revision$ $Date$
*/
@@ -139,6 +140,13 @@
*/
protected ArrayList userClasses = new ArrayList();
+ /**
+ * Whether to use context ClassLoader or default ClassLoader.
+ * True means use context ClassLoader, and True is the default
+ * value.
+ */
+ protected boolean useContextClassLoader = true;
+
// ------------------------------------------------------------- Properties
@@ -158,6 +166,27 @@
return appName;
}
+ /**
+ * Sets whether to use the context or default ClassLoader.
+ * True means use context ClassLoader.
+ *
+ * @param useContext True means use context ClassLoader
+ */
+ public void setUseContextClassLoader(boolean useContext) {
+ useContextClassLoader = useContext;
+ log.info("Setting useContextClassLoader = " + useContext);
+ }
+
+ /**
+ * Returns whether to use the context or default ClassLoader.
+ * True means to use the context ClassLoader.
+ *
+ * @return The value of useContextClassLoader
+ */
+ public boolean isUseContextClassLoader() {
+ return useContextClassLoader;
+ }
+
public void setContainer(Container container) {
super.setContainer(container);
String name=container.getName();
@@ -258,9 +287,13 @@
log.debug("Authenticating " + appName + " " + username);
// What if the LoginModule is in the container class loader ?
- //
- ClassLoader ocl=Thread.currentThread().getContextClassLoader();
-
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ ClassLoader ocl = null;
+
+ if (isUseContextClassLoader()) {
+ ocl=Thread.currentThread().getContextClassLoader();
+
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ }
+
try {
loginContext = new LoginContext
(appName, new JAASCallbackHandler(this, username,
@@ -269,7 +302,9 @@
log.error(sm.getString("jaasRealm.unexpectedError"), e);
return (null);
} finally {
- Thread.currentThread().setContextClassLoader(ocl);
+ if( isUseContextClassLoader()) {
+ Thread.currentThread().setContextClassLoader(ocl);
+ }
}
if( log.isDebugEnabled())
1.83 +3 -0 jakarta-tomcat-catalina/webapps/docs/changelog.xml
Index: changelog.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- changelog.xml 28 Jul 2004 17:26:03 -0000 1.82
+++ changelog.xml 28 Jul 2004 21:31:16 -0000 1.83
@@ -49,6 +49,9 @@
<fix>
<bug>30144</bug>: Made SSIServlet check resource MimeType before using
text/html and UTF-8 default. (yoavs)
</fix>
+ <fix>
+ <bug>29406</bug>: Made JAASRealm configurable as to whether it should use
the context ClassLoader or the default ClassLoader by adding a useContextClassLoader
boolean attribute. (yoavs)
+ </fix>
</changelog>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]