geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r697480 - /geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/jaas/JaasConfigurationLoader.java
Date Sun, 21 Sep 2008 11:54:27 GMT
Author: jdillon
Date: Sun Sep 21 04:54:26 2008
New Revision: 697480

URL: http://svn.apache.org/viewvc?rev=697480&view=rev
Log:
Make aware of the bean container's classloader to find the resource

Modified:
    geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/jaas/JaasConfigurationLoader.java

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/jaas/JaasConfigurationLoader.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/jaas/JaasConfigurationLoader.java?rev=697480&r1=697479&r2=697480&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/jaas/JaasConfigurationLoader.java
(original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/jaas/JaasConfigurationLoader.java
Sun Sep 21 04:54:26 2008
@@ -19,12 +19,13 @@
 
 package org.apache.geronimo.gshell.remote.jaas;
 
-import java.net.URL;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.BeanClassLoaderAware;
+import org.springframework.util.ClassUtils;
 
 import javax.annotation.PostConstruct;
+import java.net.URL;
 
 /**
  * Component to configure JAAS.
@@ -32,13 +33,27 @@
  * @version $Rev$ $Date$
  */
 public class JaasConfigurationLoader
+    implements BeanClassLoaderAware
 {
     private static final String KEY = "java.security.auth.login.config";
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    private ClassLoader classLoader;
+
     private String resourceName;
 
+    public void setBeanClassLoader(final ClassLoader classLoader) {
+        // classLoader could be null
+
+        if (classLoader == null) {
+            this.classLoader = ClassUtils.getDefaultClassLoader();
+        }
+        else {
+            this.classLoader = classLoader;
+        }
+    }
+
     public String getResourceName() {
         return resourceName;
     }
@@ -57,15 +72,23 @@
         String path = System.getProperty(KEY);
 
         if (path == null) {
-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
-            URL resource = cl.getResource(resourceName);
+            URL resource = classLoader.getResource(resourceName);
 
+            //
+            // FIXME: This is not very friendly for threaded environments
+            //
+            
             if (resource != null) {
                 path = resource.toExternalForm();
                 System.setProperty(KEY, path);
             }
         }
 
-        log.debug("Using JAAS login config: {}", path);
+        if (path == null) {
+            log.warn("Unable to locate JAAS login config");
+        }
+        else {
+            log.info("Using JAAS login config: {}", path);
+        }
     }
 }
\ No newline at end of file



Mime
View raw message