You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2013/05/23 01:08:52 UTC
svn commit: r1485484 - in /directory/apacheds/trunk: ./ kerberos-client/
kerberos-client/src/test/java/org/apache/directory/kerberos/client/
kerberos-test/
kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/
server-integ/ server-integ...
Author: seelmann
Date: Wed May 22 23:08:51 2013
New Revision: 1485484
URL: http://svn.apache.org/r1485484
Log:
Fix another failing Kerberos test. Make code that fixes service principal reusable.
Modified:
directory/apacheds/trunk/kerberos-client/pom.xml
directory/apacheds/trunk/kerberos-client/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java
directory/apacheds/trunk/kerberos-test/pom.xml
directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
directory/apacheds/trunk/pom.xml
directory/apacheds/trunk/server-integ/pom.xml
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
Modified: directory/apacheds/trunk/kerberos-client/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-client/pom.xml?rev=1485484&r1=1485483&r2=1485484&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-client/pom.xml (original)
+++ directory/apacheds/trunk/kerberos-client/pom.xml Wed May 22 23:08:51 2013
@@ -58,6 +58,13 @@
<artifactId>apacheds-interceptor-kerberos</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apacheds-kerberos-test</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Modified: directory/apacheds/trunk/kerberos-client/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-client/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java?rev=1485484&r1=1485483&r2=1485484&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-client/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java (original)
+++ directory/apacheds/trunk/kerberos-client/src/test/java/org/apache/directory/kerberos/client/KdcConnectionTest.java Wed May 22 23:08:51 2013
@@ -28,6 +28,7 @@ import static org.junit.Assert.fail;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.server.annotations.CreateChngPwdServer;
import org.apache.directory.server.annotations.CreateKdcServer;
import org.apache.directory.server.annotations.CreateLdapServer;
@@ -40,6 +41,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.server.core.kerberos.KeyDerivationInterceptor;
+import org.apache.directory.server.kerberos.kdc.KerberosTestUtils;
import org.apache.directory.server.protocol.shared.transport.Transport;
import org.apache.directory.server.protocol.shared.transport.UdpTransport;
import org.apache.directory.shared.kerberos.exceptions.KerberosException;
@@ -139,11 +141,11 @@ public class KdcConnectionTest extends A
private static KdcConnection conn;
- private String userPassword = "secret";
+ private static String userPassword = "secret";
- private String principalName = "will@EXAMPLE.COM";
+ private static String principalName = "will@EXAMPLE.COM";
- private String serverPrincipal = "ldap/localhost@EXAMPLE.COM";
+ private static String serverPrincipal;
@Before
@@ -166,6 +168,11 @@ public class KdcConnectionTest extends A
config.setTimeout( Integer.MAX_VALUE );
conn = new KdcConnection( config );
}
+ if ( serverPrincipal == null )
+ {
+ serverPrincipal = KerberosTestUtils.fixServicePrincipalName( "ldap/localhost@EXAMPLE.COM", new Dn(
+ "uid=ldap,dc=example,dc=com" ), getLdapServer() );
+ }
}
Modified: directory/apacheds/trunk/kerberos-test/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/pom.xml?rev=1485484&r1=1485483&r2=1485484&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/pom.xml (original)
+++ directory/apacheds/trunk/kerberos-test/pom.xml Wed May 22 23:08:51 2013
@@ -116,7 +116,24 @@
</systemPropertyVariables>
</configuration>
</plugin>
-
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <addMavenDescriptor>false</addMavenDescriptor>
+ </archive>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-tests</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java?rev=1485484&r1=1485483&r2=1485484&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java (original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java Wed May 22 23:08:51 2013
@@ -36,13 +36,20 @@ 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;
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.message.ModifyRequest;
+import org.apache.directory.api.ldap.model.message.ModifyRequestImpl;
+import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Strings;
import org.apache.directory.ldap.client.api.Krb5LoginConfiguration;
+import org.apache.directory.server.core.api.DirectoryService;
import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.server.ldap.LdapServer;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
@@ -413,4 +420,39 @@ public class KerberosTestUtils
return new Oid( "1.2.840.113554.1.2.2" );
}
}
+
+
+ /**
+ * 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".
+ * This method fixes the SASL principal name of the service entry
+ * within the LDAP server.
+ *
+ * @param servicePrincipalName the "original" service principal name
+ * @param serviceEntryDn the service entry in LDAP
+ * @param ldapServer the LDAP server instance
+ * @return the fixed service principal name
+ * @throws LdapException
+ */
+ public static String fixServicePrincipalName( String servicePrincipalName, Dn serviceEntryDn, LdapServer ldapServer )
+ throws LdapException
+ {
+ KerberosPrincipal servicePrincipal = new KerberosPrincipal( servicePrincipalName,
+ KerberosPrincipal.KRB_NT_SRV_HST );
+ servicePrincipalName = servicePrincipal.getName();
+
+ ldapServer.setSaslPrincipal( servicePrincipalName );
+
+ if ( serviceEntryDn != null )
+ {
+ ModifyRequest modifyRequest = new ModifyRequestImpl();
+ modifyRequest.setName( serviceEntryDn );
+ modifyRequest.replace( "userPassword", "randall" );
+ modifyRequest.replace( "krb5PrincipalName", servicePrincipalName );
+ ldapServer.getDirectoryService().getAdminSession().modify( modifyRequest );
+ }
+
+ return servicePrincipalName;
+ }
}
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=1485484&r1=1485483&r2=1485484&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 23:08:51 2013
@@ -44,7 +44,6 @@ 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;
@@ -166,13 +165,7 @@ public class SaslGssapiBindITest extends
@Before
public void setUp() throws Exception
{
- // 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 );
+ String servicePrincipalName = KerberosTestUtils.fixServicePrincipalName( "ldap/localhost@EXAMPLE.COM", null, getLdapServer() );
Attributes attrs;
Modified: directory/apacheds/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/pom.xml?rev=1485484&r1=1485483&r2=1485484&view=diff
==============================================================================
--- directory/apacheds/trunk/pom.xml (original)
+++ directory/apacheds/trunk/pom.xml Wed May 22 23:08:51 2013
@@ -723,6 +723,13 @@
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apacheds-kerberos-test</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apacheds-ldap-client-test</artifactId>
<version>${project.version}</version>
</dependency>
Modified: directory/apacheds/trunk/server-integ/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/pom.xml?rev=1485484&r1=1485483&r2=1485484&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/pom.xml (original)
+++ directory/apacheds/trunk/server-integ/pom.xml Wed May 22 23:08:51 2013
@@ -90,6 +90,13 @@
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apacheds-kerberos-test</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>ldapsdk</groupId>
<artifactId>ldapsdk</artifactId>
</dependency>
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=1485484&r1=1485483&r2=1485484&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 23:08:51 2013
@@ -32,7 +32,6 @@ 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;
@@ -50,8 +49,6 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.message.BindRequestImpl;
import org.apache.directory.api.ldap.model.message.BindResponse;
import org.apache.directory.api.ldap.model.message.Message;
-import org.apache.directory.api.ldap.model.message.ModifyRequest;
-import org.apache.directory.api.ldap.model.message.ModifyRequestImpl;
import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
@@ -72,6 +69,7 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.server.core.kerberos.KeyDerivationInterceptor;
+import org.apache.directory.server.kerberos.kdc.KerberosTestUtils;
import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
import org.apache.directory.server.ldap.handlers.sasl.cramMD5.CramMd5MechanismHandler;
import org.apache.directory.server.ldap.handlers.sasl.digestMD5.DigestMd5MechanismHandler;
@@ -79,6 +77,7 @@ import org.apache.directory.server.ldap.
import org.apache.directory.server.ldap.handlers.sasl.ntlm.NtlmMechanismHandler;
import org.apache.directory.server.ldap.handlers.sasl.plain.PlainMechanismHandler;
import org.apache.directory.shared.kerberos.KerberosAttribute;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -201,22 +200,11 @@ public class SaslBindIT extends Abstract
public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE );
- public SaslBindIT() throws Exception
+ @Before
+ public void init() throws Exception
{
- // 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 );
-
- ModifyRequest modifyRequest = new ModifyRequestImpl();
- modifyRequest.setName( new Dn( "uid=ldap,ou=users,dc=example,dc=com" ) );
- modifyRequest.replace( "userPassword", "randall" );
- modifyRequest.replace( "krb5PrincipalName", servicePrincipalName );
- getService().getAdminSession().modify( modifyRequest );
+ KerberosTestUtils.fixServicePrincipalName( "ldap/localhost@EXAMPLE.COM", new Dn(
+ "uid=ldap,ou=users,dc=example,dc=com" ), getLdapServer() );
}