geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject cvs commit: incubator-geronimo/modules/jmx-remoting/src/test/org/apache/geronimo/jmxremoting AuthenticatorTest.java
Date Sat, 05 Jun 2004 16:54:35 GMT
jboynes     2004/06/05 09:54:35

  Modified:    modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting
                        Authenticator.java JMXConnector.java
               modules/jmx-remoting/src/test/org/apache/geronimo/jmxremoting
                        AuthenticatorTest.java
  Log:
  Use GBean's classloader to load LoginModules
  
  Revision  Changes    Path
  1.3       +8 -2      incubator-geronimo/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/Authenticator.java
  
  Index: Authenticator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/Authenticator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Authenticator.java	2 Jun 2004 06:47:56 -0000	1.2
  +++ Authenticator.java	5 Jun 2004 16:54:35 -0000	1.3
  @@ -28,13 +28,15 @@
    */
   public class Authenticator implements JMXAuthenticator {
       private final String configName;
  +    private final ClassLoader cl;
   
       /**
        * Constructor indicating which JAAS Application Configuration Entry to use.
        * @param configName the JAAS config name
        */
  -    public Authenticator(String configName) {
  +    public Authenticator(String configName, ClassLoader cl) {
           this.configName = configName;
  +        this.cl = cl;
       }
   
       public Subject authenticate(Object o) throws SecurityException {
  @@ -46,8 +48,11 @@
               throw new IllegalArgumentException("Expected String[2] but length was " + params.length);
           }
   
  +        Thread thread = Thread.currentThread();
  +        ClassLoader oldCL = thread.getContextClassLoader();
           Credentials credentials = new Credentials(params[0], params[1]);
           try {
  +            thread.setContextClassLoader(cl);
               LoginContext context = new LoginContext(configName, credentials);
               context.login();
               return context.getSubject();
  @@ -56,6 +61,7 @@
               throw new SecurityException("Invalid login");
           } finally {
               credentials.clear();
  +            thread.setContextClassLoader(oldCL);
           }
       }
   }
  
  
  
  1.7       +13 -7     incubator-geronimo/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java
  
  Index: JMXConnector.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JMXConnector.java	5 Jun 2004 07:53:22 -0000	1.6
  +++ JMXConnector.java	5 Jun 2004 16:54:35 -0000	1.7
  @@ -32,24 +32,29 @@
   
   /**
    * A Connector that supports the server sideof JSR 160 JMX Remoting.
  - * 
  + *
    * @version $Revision$ $Date$
    */
   public class JMXConnector implements GBeanLifecycle {
       private final Kernel kernel;
       private final Log log;
  +    private final ClassLoader classLoader;
       private String url;
       private String applicationConfigName;
   
       private JMXConnectorServer server;
   
       /**
  -     * Constructor for creating the connector
  +     * Constructor for creating the connector. The ClassLoader must be
  +     * able to load all the LoginModules used in the JAAS login
        *
        * @param kernel a reference to the kernel
  +     * @param objectName this connector's object name
  +     * @param classLoader the classLoader used to create this connector
        */
  -    public JMXConnector(Kernel kernel, String objectName) {
  +    public JMXConnector(Kernel kernel, String objectName, ClassLoader classLoader) {
           this.kernel = kernel;
  +        this.classLoader = classLoader;
           log = LogFactory.getLog(objectName);
       }
   
  @@ -97,7 +102,7 @@
           JMXServiceURL serviceURL = new JMXServiceURL(url);
           Map env = new HashMap();
           if (applicationConfigName != null) {
  -            env.put(JMXConnectorServer.AUTHENTICATOR, new Authenticator(applicationConfigName));
  +            env.put(JMXConnectorServer.AUTHENTICATOR, new Authenticator(applicationConfigName,
classLoader));
           } else {
               log.warn("Starting unauthenticating JMXConnector for " + serviceURL);
           }
  @@ -125,11 +130,12 @@
   
       static {
           GBeanInfoFactory infoFactory = new GBeanInfoFactory(JMXConnector.class);
  -        infoFactory.addAttribute("objectName", String.class, false);
           infoFactory.addAttribute("URL", String.class, true);
           infoFactory.addAttribute("ApplicationConfigName", String.class, true);
           infoFactory.addAttribute("kernel", Kernel.class, false);
  -        infoFactory.setConstructor(new String[]{"kernel", "objectName"});
  +        infoFactory.addAttribute("objectName", String.class, false);
  +        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
  +        infoFactory.setConstructor(new String[]{"kernel", "objectName", "classLoader"});
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
   
  
  
  
  1.3       +2 -2      incubator-geronimo/modules/jmx-remoting/src/test/org/apache/geronimo/jmxremoting/AuthenticatorTest.java
  
  Index: AuthenticatorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jmx-remoting/src/test/org/apache/geronimo/jmxremoting/AuthenticatorTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AuthenticatorTest.java	2 Jun 2004 06:47:56 -0000	1.2
  +++ AuthenticatorTest.java	5 Jun 2004 16:54:35 -0000	1.3
  @@ -67,7 +67,7 @@
           Configuration.setConfiguration(loginConfig);
   
           credentials = new String[]{"username", "password"};
  -        authenticator = new Authenticator(CONFIG_NAME);
  +        authenticator = new Authenticator(CONFIG_NAME, getClass().getClassLoader());
       }
   
       protected void tearDown() throws Exception {
  
  
  

Mime
View raw message