directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1042573 - in /directory/apacheds/branches/apacheds-kerberos-codec-2.0: kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/jaas/ kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/
Date Mon, 06 Dec 2010 11:00:20 GMT
Author: kayyagari
Date: Mon Dec  6 11:00:20 2010
New Revision: 1042573

URL: http://svn.apache.org/viewvc?rev=1042573&view=rev
Log:
o moved the CallbackHandlerBean class to SaslGssapiBindITest
o removed the jaas package from kerberos-shared

Removed:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/jaas/
Modified:
    directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java

Modified: directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java?rev=1042573&r1=1042572&r2=1042573&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
(original)
+++ directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
Mon Dec  6 11:00:20 2010
@@ -23,6 +23,7 @@ package org.apache.directory.server.kerb
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.security.PrivilegedAction;
@@ -40,6 +41,11 @@ import javax.naming.directory.Modificati
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 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.UnsupportedCallbackException;
 import javax.security.auth.login.Configuration;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
@@ -60,7 +66,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.jndi.CoreContextFactory;
 import org.apache.directory.server.core.kerberos.KeyDerivationInterceptor;
-import org.apache.directory.server.kerberos.shared.jaas.CallbackHandlerBean;
+import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.kerberos.shared.store.KerberosAttribute;
 import org.apache.directory.server.ldap.handlers.bind.cramMD5.CramMd5MechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.digestMD5.DigestMd5MechanismHandler;
@@ -408,4 +414,50 @@ public class SaslGssapiBindITest extends
         schemaRoot = new InitialLdapContext( envFinal, null );
     }
     
+    
+    private class CallbackHandlerBean implements CallbackHandler
+    {
+        private String name;
+        private String password;
+
+
+        /**
+         * Creates a new instance of CallbackHandlerBean.
+         *
+         * @param name
+         * @param password
+         */
+        public CallbackHandlerBean( String name, String password )
+        {
+            this.name = name;
+            this.password = password;
+        }
+
+
+        public void handle( Callback[] callbacks ) throws UnsupportedCallbackException, IOException
+        {
+            for ( int ii = 0; ii < callbacks.length; ii++ )
+            {
+                Callback callBack = callbacks[ii];
+
+                // Handles username callback.
+                if ( callBack instanceof NameCallback )
+                {
+                    NameCallback nameCallback = ( NameCallback ) callBack;
+                    nameCallback.setName( name );
+                    // Handles password callback.
+                }
+                else if ( callBack instanceof PasswordCallback )
+                {
+                    PasswordCallback passwordCallback = ( PasswordCallback ) callBack;
+                    passwordCallback.setPassword( password.toCharArray() );
+                }
+                else
+                {
+                    throw new UnsupportedCallbackException( callBack, I18n.err( I18n.ERR_617
) );
+                }
+            }
+        }
+    }
+
 }



Mime
View raw message