directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1485095 - in /directory/apacheds/trunk: kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
Date Wed, 22 May 2013 07:14:02 GMT
Author: seelmann
Date: Wed May 22 07:14:02 2013
New Revision: 1485095

URL: http://svn.apache.org/r1485095
Log:
Another attempt to fix the GSSAPI bind tests on all platforms.

Modified:
    directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java

Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java?rev=1485095&r1=1485094&r2=1485095&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
(original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
Wed May 22 07:14:02 2013
@@ -44,6 +44,7 @@ import javax.security.auth.callback.Call
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.kerberos.KerberosPrincipal;
 import javax.security.auth.login.Configuration;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
@@ -165,12 +166,13 @@ public class SaslGssapiBindITest extends
     @Before
     public void setUp() throws Exception
     {
-        // On Windows 7 and Server 2008 the loopback address 127.0.0.1
-        // isn't resolved to localhost by default. In that case we need
-        // to use the IP address for the service principal.
-        String hostName = "localhost";
-        String servicePrincipal = "ldap/" + hostName + "@EXAMPLE.COM";
-        getLdapServer().setSaslPrincipal( servicePrincipal );
+        // Within the KerberosPrincipal/PrincipalName class a DNS lookup is done 
+        // to get the canonical name of the host. So the principal name
+        // may be extended to the form "ldap/localhost.example.com@EXAMPLE.COM"
+        KerberosPrincipal servicePrincipal = new KerberosPrincipal( "ldap/localhost@EXAMPLE.COM",
+            KerberosPrincipal.KRB_NT_SRV_HST );
+        String servicePrincipalName = servicePrincipal.getName();
+        getLdapServer().setSaslPrincipal( servicePrincipalName );
 
         Attributes attrs;
 
@@ -218,7 +220,7 @@ public class SaslGssapiBindITest extends
         attrs = getPrincipalAttributes( "Service", "KDC Service", "krbtgt", "secret", "krbtgt/EXAMPLE.COM@EXAMPLE.COM"
);
         users.createSubcontext( "uid=krbtgt", attrs );
 
-        attrs = getPrincipalAttributes( "Service", "LDAP Service", "ldap", "randall", servicePrincipal
);
+        attrs = getPrincipalAttributes( "Service", "LDAP Service", "ldap", "randall", servicePrincipalName
);
         users.createSubcontext( "uid=ldap", attrs );
     }
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java?rev=1485095&r1=1485094&r2=1485095&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
Wed May 22 07:14:02 2013
@@ -25,8 +25,6 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.lang.reflect.Field;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 
 import javax.naming.NamingEnumeration;
@@ -34,6 +32,7 @@ import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.InitialDirContext;
+import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.net.SocketClient;
@@ -204,28 +203,19 @@ public class SaslBindIT extends Abstract
 
     public SaslBindIT() throws Exception
     {
-        // On Windows 7 and Server 2008 the loopback address 127.0.0.1
-        // isn't resolved to localhost by default. In that case we need
-        // to use the IP address for the service principal.
-        String hostName;
+        // Within the KerberosPrincipal/PrincipalName class a DNS lookup is done 
+        // to get the canonical name of the host. So the principal name
+        // may be extended to the form "ldap/localhost.example.com@EXAMPLE.COM"
+        KerberosPrincipal servicePrincipal = new KerberosPrincipal( "ldap/localhost@EXAMPLE.COM",
+            KerberosPrincipal.KRB_NT_SRV_HST );
+        String servicePrincipalName = servicePrincipal.getName();
 
-        try
-        {
-            InetAddress loopback = InetAddress.getByName( "127.0.0.1" );
-            hostName = "localhost";
-        }
-        catch ( UnknownHostException e )
-        {
-            System.err.println( "Can't find loopback address '127.0.0.1', using hostname
'localhost'" );
-            hostName = "localhost";
-        }
-        String servicePrincipal = "ldap/" + hostName + "@EXAMPLE.COM";
-        getLdapServer().setSaslPrincipal( servicePrincipal );
+        getLdapServer().setSaslPrincipal( servicePrincipalName );
 
         ModifyRequest modifyRequest = new ModifyRequestImpl();
         modifyRequest.setName( new Dn( "uid=ldap,ou=users,dc=example,dc=com" ) );
         modifyRequest.replace( "userPassword", "randall" );
-        modifyRequest.replace( "krb5PrincipalName", servicePrincipal );
+        modifyRequest.replace( "krb5PrincipalName", servicePrincipalName );
         getService().getAdminSession().modify( modifyRequest );
     }
 



Mime
View raw message