ASF Bugzilla – Attachment 29280 Details for
Bug 53777
Ability to bundle JAAS Configuration in Webappp
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch on JAASRealm (tomcat 7 trunk)
JAASRealm.diff (text/plain), 4.22 KB, created by
eolivelli
on 2012-08-26 15:51:00 UTC
(
hide
)
Description:
Patch on JAASRealm (tomcat 7 trunk)
Filename:
MIME Type:
Creator:
eolivelli
Created:
2012-08-26 15:51:00 UTC
Size:
4.22 KB
patch
obsolete
>--- C:/Users/Utente/AppData/Local/Temp/JAASRealm.java-revBASE.svn000.tmp.java dom ago 26 17:47:07 2012 >+++ C:/work/tomcat7/java/org/apache/catalina/realm/JAASRealm.java dom ago 26 17:46:24 2012 >@@ -19,6 +19,11 @@ > package org.apache.catalina.realm; > > >+import java.lang.reflect.Constructor; >+import java.lang.reflect.InvocationTargetException; >+import java.net.URI; >+import java.net.URISyntaxException; >+import java.net.URL; > import java.security.Principal; > import java.util.ArrayList; > import java.util.Iterator; >@@ -27,6 +32,7 @@ > import javax.security.auth.Subject; > import javax.security.auth.callback.CallbackHandler; > import javax.security.auth.login.AccountExpiredException; >+import javax.security.auth.login.Configuration; > import javax.security.auth.login.CredentialExpiredException; > import javax.security.auth.login.FailedLoginException; > import javax.security.auth.login.LoginContext; >@@ -122,7 +128,7 @@ > * > * @author Craig R. McClanahan > * @author Yoav Shapira >- * @version $Id: JAASRealm.java 1361770 2012-07-15 19:38:51Z markt $ >+ * @version $Id$ > */ > > public class JAASRealm >@@ -173,8 +179,29 @@ > protected boolean useContextClassLoader = true; > > >+ >+ /** >+ * Path to find a JAAS configuration file, if not set global JVM JAAS configuraion will be used >+ */ >+ protected String configfile; >+ > // ------------------------------------------------------------- Properties > >+ /** >+ * getter for the <code>configfile</code> member variable >+ */ >+ public String getConfigfile() { >+ return configfile; >+ } >+ >+ /** >+ * setter for the <code>configfile</code> member variable >+ */ >+ public void setConfigfile(String configfile) { >+ this.configfile = configfile; >+ } >+ >+ > > /** > * setter for the <code>appName</code> member variable >@@ -389,7 +416,8 @@ > } > > try { >- loginContext = new LoginContext(appName, callbackHandler); >+ Configuration config = getConfig(); >+ loginContext = new LoginContext(appName, null, callbackHandler, config); > } catch (Throwable e) { > ExceptionUtils.handleThrowable(e); > log.error(sm.getString("jaasRealm.unexpectedError"), e); >@@ -605,4 +633,48 @@ > > super.startInternal(); > } >+ protected Configuration jaasConfiguration; >+ protected volatile boolean jaasConfigurationLoaded = false; >+ >+ /** >+ * Load custom JAAS Configuration >+ */ >+ protected Configuration getConfig() { >+ try { >+ if (jaasConfigurationLoaded) { >+ return jaasConfiguration; >+ } >+ synchronized (this) { >+ if (configfile == null) { >+ jaasConfigurationLoaded = true; >+ return null; >+ } >+ URL resource = Thread.currentThread().getContextClassLoader().getResource(configfile); >+ URI uri = resource.toURI(); >+ Class sunConfigFile = Class.forName("com.sun.security.auth.login.ConfigFile"); >+ Constructor<Configuration> constructor = sunConfigFile.getConstructor(URI.class); >+ Configuration config = constructor.newInstance(uri); >+ this.jaasConfiguration = config; >+ this.jaasConfigurationLoaded = true; >+ return this.jaasConfiguration; >+ } >+ } catch (URISyntaxException ex) { >+ throw new RuntimeException(ex); >+ } catch (NoSuchMethodException ex) { >+ throw new RuntimeException(ex); >+ } catch (SecurityException ex) { >+ throw new RuntimeException(ex); >+ } catch (InstantiationException ex) { >+ throw new RuntimeException(ex); >+ } catch (IllegalAccessException ex) { >+ throw new RuntimeException(ex); >+ } catch (IllegalArgumentException ex) { >+ throw new RuntimeException(ex); >+ } catch (InvocationTargetException ex) { >+ throw new RuntimeException(ex.getCause()); >+ } catch (ClassNotFoundException ex) { >+ throw new RuntimeException(ex); >+ } >+ >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 53777
:
29274
|
29275
| 29280