Finalized implementation and testing of LDAP-173.
This commit is contained in:
@@ -24,13 +24,13 @@ import javax.naming.directory.DirContext;
|
||||
* Authentication strategy for LDAP DIGEST-MD5 SASL mechanism.
|
||||
*
|
||||
* @author Marvin S. Addison
|
||||
* @since 1.3.1
|
||||
*/
|
||||
public class DigestMd5DirContextAuthenticationStrategy implements DirContextAuthenticationStrategy {
|
||||
|
||||
/** Authentication type for DIGEST-MD5 auth */
|
||||
private static final String DIGEST_MD5_AUTHENTICATION = "DIGEST-MD5";
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.ldap.core.support.DirContextAuthenticationStrategy#processContextAfterCreation(javax.naming.directory.DirContext,
|
||||
|
||||
@@ -9,34 +9,30 @@ import javax.naming.directory.DirContext;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.NamingException;
|
||||
import org.springframework.ldap.AuthenticationException;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
/**
|
||||
* Integration test to verify DIGEST-MD5 authentication support.
|
||||
*
|
||||
*
|
||||
* @author Marvin S. Addison
|
||||
* @version $Revision$
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration(locations = { "/conf/ldapTemplateDigestMd5TestContext.xml" })
|
||||
public class DigestMd5AuthenticationITest extends AbstractJUnit4SpringContextTests {
|
||||
@Autowired
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
|
||||
@Test
|
||||
public void testAuthenticate() {
|
||||
try {
|
||||
DirContext ctxt = ldapTemplate.getContextSource().getContext("admin", "secret");
|
||||
DirContext ctxt = ldapTemplate.getContextSource().getContext("some.person", "password");
|
||||
Assert.assertNotNull(ctxt);
|
||||
} catch (NamingException e) {
|
||||
Assert.fail("DIGEST-MD5 authentication failed: " + e);
|
||||
}
|
||||
|
||||
catch (AuthenticationException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ userDn=cn=admin,dc=jayway,dc=se
|
||||
password=secret
|
||||
base=dc=jayway,dc=se
|
||||
|
||||
aws.ami=ami-56ec083f
|
||||
aws.ami=ami-889c6be1
|
||||
aws.keypair=spring-ldap-keypair
|
||||
aws.security.group=spring-ldap
|
||||
aws.security.group=spring-ldap
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
<property name="location" value="/conf/ldap.properties" />
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
</bean>
|
||||
|
||||
<bean id="contextSource" class="org.springframework.ldap.DigestMd5ContextSourceEc2InstanceLaunchingFactoryBean">
|
||||
<property name="awsKey" value="${AWS_KEY}" />
|
||||
<property name="awsSecretKey" value="${AWS_SECRET_KEY}" />
|
||||
@@ -18,7 +17,6 @@
|
||||
<property name="userDn" value="${userDn}" />
|
||||
<property name="password" value="${password}" />
|
||||
</bean>
|
||||
|
||||
<bean id="ldapTemplate"
|
||||
class="org.springframework.ldap.core.LdapTemplate">
|
||||
<constructor-arg ref="contextSource" />
|
||||
|
||||
Reference in New Issue
Block a user