Search in sources :

Example 1 with PlaintextPasswordEncoder

use of org.springframework.security.authentication.encoding.PlaintextPasswordEncoder in project spring-security by spring-projects.

the class PasswordComparisonAuthenticatorTests method setUp.

// ~ Methods
// ========================================================================================================
@Before
public void setUp() throws Exception {
    authenticator = new PasswordComparisonAuthenticator(getContextSource());
    authenticator.setPasswordEncoder(new PlaintextPasswordEncoder());
    authenticator.setUserDnPatterns(new String[] { "uid={0},ou=people" });
    bob = new UsernamePasswordAuthenticationToken("bob", "bobspassword");
    ben = new UsernamePasswordAuthenticationToken("ben", "benspassword");
}
Also used : PlaintextPasswordEncoder(org.springframework.security.authentication.encoding.PlaintextPasswordEncoder) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken)

Example 2 with PlaintextPasswordEncoder

use of org.springframework.security.authentication.encoding.PlaintextPasswordEncoder in project spring-security by spring-projects.

the class PasswordComparisonAuthenticatorTests method testWithUserSearch.

@Test
public void testWithUserSearch() {
    authenticator = new PasswordComparisonAuthenticator(getContextSource());
    authenticator.setPasswordEncoder(new PlaintextPasswordEncoder());
    assertThat(authenticator.getUserDns("Bob")).withFailMessage("User DN matches shouldn't be available").isEmpty();
    DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=Bob,ou=people"));
    ctx.setAttributeValue("userPassword", "bobspassword");
    authenticator.setUserSearch(new MockUserSearch(ctx));
    authenticator.authenticate(new UsernamePasswordAuthenticationToken("shouldntbeused", "bobspassword"));
}
Also used : PlaintextPasswordEncoder(org.springframework.security.authentication.encoding.PlaintextPasswordEncoder) DistinguishedName(org.springframework.ldap.core.DistinguishedName) DirContextAdapter(org.springframework.ldap.core.DirContextAdapter) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken)

Aggregations

UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)2 PlaintextPasswordEncoder (org.springframework.security.authentication.encoding.PlaintextPasswordEncoder)2 DirContextAdapter (org.springframework.ldap.core.DirContextAdapter)1 DistinguishedName (org.springframework.ldap.core.DistinguishedName)1