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 Wed, 02 Jun 2004 06:47:56 GMT
jboynes     2004/06/01 23:47:56

  Modified:    modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting
                        Authenticator.java
               modules/jmx-remoting/src/test/org/apache/geronimo/jmxremoting
                        AuthenticatorTest.java
  Log:
  Don't pass Credentials, pass a String[2] as suggested by the spec
  
  Revision  Changes    Path
  1.2       +8 -4      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Authenticator.java	30 May 2004 19:48:01 -0000	1.1
  +++ Authenticator.java	2 Jun 2004 06:47:56 -0000	1.2
  @@ -38,11 +38,15 @@
       }
   
       public Subject authenticate(Object o) throws SecurityException {
  -        if (o instanceof Credentials == false) {
  -            throw new IllegalArgumentException("Expected Credentials, got " + o == null
? null : o.getClass().getName());
  +        if (o instanceof String[] == false) {
  +            throw new IllegalArgumentException("Expected String[2], got " + o == null ?
null : o.getClass().getName());
  +        }
  +        String[] params = (String[]) o;
  +        if (params.length != 2) {
  +            throw new IllegalArgumentException("Expected String[2] but length was " + params.length);
           }
   
  -        Credentials credentials = (Credentials) o;
  +        Credentials credentials = new Credentials(params[0], params[1]);
           try {
               LoginContext context = new LoginContext(configName, credentials);
               context.login();
  
  
  
  1.2       +6 -7      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AuthenticatorTest.java	30 May 2004 19:48:01 -0000	1.1
  +++ AuthenticatorTest.java	2 Jun 2004 06:47:56 -0000	1.2
  @@ -16,21 +16,20 @@
    */
   package org.apache.geronimo.jmxremoting;
   
  +import java.security.Principal;
   import java.util.HashMap;
   import java.util.Map;
  -import java.util.Arrays;
   import java.util.Set;
  -import java.security.Principal;
   import javax.security.auth.Subject;
  +import javax.security.auth.callback.Callback;
   import javax.security.auth.callback.CallbackHandler;
   import javax.security.auth.callback.NameCallback;
   import javax.security.auth.callback.PasswordCallback;
  -import javax.security.auth.callback.Callback;
   import javax.security.auth.callback.UnsupportedCallbackException;
  -import javax.security.auth.spi.LoginModule;
   import javax.security.auth.login.AppConfigurationEntry;
   import javax.security.auth.login.Configuration;
   import javax.security.auth.login.LoginException;
  +import javax.security.auth.spi.LoginModule;
   
   import junit.framework.TestCase;
   
  @@ -43,7 +42,7 @@
       private static final String CONFIG_NAME = "testConfig";
       private Configuration oldConfiguration;
       private Configuration loginConfig;
  -    private Credentials credentials;
  +    private String[] credentials;
       private Authenticator authenticator;
   
       public void testAuthenticateWithValidPassword() {
  @@ -67,7 +66,7 @@
           loginConfig = new MockConfiguration();
           Configuration.setConfiguration(loginConfig);
   
  -        credentials = new Credentials("username", "password");
  +        credentials = new String[]{"username", "password"};
           authenticator = new Authenticator(CONFIG_NAME);
       }
   
  
  
  

Mime
View raw message