You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2013/04/04 18:46:59 UTC
svn commit: r1464625 - in /directory/apacheds/trunk:
protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java
server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
Author: elecharny
Date: Thu Apr 4 16:46:59 2013
New Revision: 1464625
URL: http://svn.apache.org/r1464625
Log:
o Fixed a NPE in the SASL PLAIN authentication
o Fixed the SASL PLAIN authent test
Modified:
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java?rev=1464625&r1=1464624&r2=1464625&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/bind/plain/PlainSaslServer.java Thu Apr 4 16:46:59 2013
@@ -32,6 +32,7 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.apache.directory.server.core.api.CoreSession;
+import org.apache.directory.server.core.api.OperationEnum;
import org.apache.directory.server.core.api.interceptor.context.BindOperationContext;
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.server.ldap.LdapSession;
@@ -240,13 +241,15 @@ public class PlainSaslServer extends Abs
/**
- * Try to authenticate the usr against the underlying LDAP server.
+ * Try to authenticate the user against the underlying LDAP server.
*/
private CoreSession authenticate( String user, String password ) throws InvalidNameException, Exception
{
BindOperationContext bindContext = new BindOperationContext( getLdapSession().getCoreSession() );
bindContext.setDn( new Dn( user ) );
bindContext.setCredentials( Strings.getBytesUtf8( password ) );
+ bindContext.setIoSession( getLdapSession().getIoSession() );
+ bindContext.setInterceptors( getAdminSession().getDirectoryService().getInterceptors( OperationEnum.BIND ) );
getAdminSession().getDirectoryService().getOperationManager().bind( bindContext );
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=1464625&r1=1464624&r2=1464625&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 Thu Apr 4 16:46:59 2013
@@ -73,7 +73,6 @@ 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.shared.kerberos.KerberosAttribute;
import org.apache.directory.server.ldap.handlers.bind.cramMD5.CramMd5MechanismHandler;
import org.apache.directory.server.ldap.handlers.bind.digestMD5.DigestMd5MechanismHandler;
import org.apache.directory.server.ldap.handlers.bind.gssapi.GssapiMechanismHandler;
@@ -151,22 +150,22 @@ import org.slf4j.LoggerFactory;
allowAnonAccess = false,
name = "SaslBindIT-class",
partitions =
- {
- @CreatePartition(
- name = "example",
- suffix = "dc=example,dc=com",
- contextEntry =
- @ContextEntry(
- entryLdif =
+ {
+ @CreatePartition(
+ name = "example",
+ suffix = "dc=example,dc=com",
+ contextEntry =
+ @ContextEntry(
+ entryLdif =
"dn: dc=example,dc=com\n" +
- "dc: example\n" +
- "objectClass: top\n" +
- "objectClass: domain\n\n"),
+ "dc: example\n" +
+ "objectClass: top\n" +
+ "objectClass: domain\n\n"),
indexes =
- {
- @CreateIndex(attribute = "objectClass"),
- @CreateIndex(attribute = "dc"),
- @CreateIndex(attribute = "ou")
+ {
+ @CreateIndex(attribute = "objectClass"),
+ @CreateIndex(attribute = "dc"),
+ @CreateIndex(attribute = "ou")
})
},
additionalInterceptors =
@@ -174,21 +173,21 @@ import org.slf4j.LoggerFactory;
@CreateLdapServer(transports =
{
@CreateTransport(protocol = "LDAP")
- },
+},
saslHost = "localhost",
saslPrincipal = "ldap/localhost@EXAMPLE.COM",
saslMechanisms =
- {
- @SaslMechanism(name = SupportedSaslMechanisms.PLAIN, implClass = PlainMechanismHandler.class),
- @SaslMechanism(name = SupportedSaslMechanisms.CRAM_MD5, implClass = CramMd5MechanismHandler.class),
- @SaslMechanism(name = SupportedSaslMechanisms.DIGEST_MD5, implClass = DigestMd5MechanismHandler.class),
- @SaslMechanism(name = SupportedSaslMechanisms.GSSAPI, implClass = GssapiMechanismHandler.class),
- @SaslMechanism(name = SupportedSaslMechanisms.NTLM, implClass = NtlmMechanismHandler.class),
- @SaslMechanism(name = SupportedSaslMechanisms.GSS_SPNEGO, implClass = NtlmMechanismHandler.class)
+ {
+ @SaslMechanism(name = SupportedSaslMechanisms.PLAIN, implClass = PlainMechanismHandler.class),
+ @SaslMechanism(name = SupportedSaslMechanisms.CRAM_MD5, implClass = CramMd5MechanismHandler.class),
+ @SaslMechanism(name = SupportedSaslMechanisms.DIGEST_MD5, implClass = DigestMd5MechanismHandler.class),
+ @SaslMechanism(name = SupportedSaslMechanisms.GSSAPI, implClass = GssapiMechanismHandler.class),
+ @SaslMechanism(name = SupportedSaslMechanisms.NTLM, implClass = NtlmMechanismHandler.class),
+ @SaslMechanism(name = SupportedSaslMechanisms.GSS_SPNEGO, implClass = NtlmMechanismHandler.class)
},
extendedOpHandlers =
- {
- StoredProcedureExtendedOperationHandler.class
+ {
+ StoredProcedureExtendedOperationHandler.class
},
ntlmProvider = BogusNtlmProvider.class)
@CreateKdcServer(
@@ -196,7 +195,7 @@ import org.slf4j.LoggerFactory;
{
@CreateTransport(protocol = "UDP", port = 6088),
@CreateTransport(protocol = "TCP", port = 6088)
- })
+ })
public class SaslBindIT extends AbstractLdapTestUnit
{
@Rule
@@ -263,14 +262,14 @@ public class SaslBindIT extends Abstract
* Tests to make sure PLAIN-binds works
*/
@Test
- @Ignore
+ //@Ignore
// The SASL Plain mechanism is not supported
public void testSaslBindPLAIN() throws Exception
{
Dn userDn = new Dn( "uid=hnelson,ou=users,dc=example,dc=com" );
LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
BindRequest bindReq = new BindRequestImpl();
- bindReq.setCredentials( "secret" );
+ bindReq.setCredentials( '\0' + "uid=hnelson,ou=users,dc=example,dc=com" + '\0' + "secret" );
bindReq.setDn( userDn );
bindReq.setSaslMechanism( SupportedSaslMechanisms.PLAIN );
@@ -505,7 +504,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
kdcServer.getConfig().setPaEncTimestampRequired( false );
-
+
GssApiRequest request = new GssApiRequest();
request.setUsername( userDn.getRdn().getValue().getString() );
request.setCredentials( "secret" );