use of org.pac4j.core.credentials.UsernamePasswordCredentials in project pac4j by pac4j.
the class LdapProfileServiceTests method authentFailed.
@Test(expected = BadCredentialsException.class)
public void authentFailed() {
final LdapProfileService ldapProfileService = new LdapProfileService(connectionFactory, authenticator, LdapServer.BASE_PEOPLE_DN);
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(BAD_USERNAME, PASSWORD);
ldapProfileService.validate(credentials, null);
}
use of org.pac4j.core.credentials.UsernamePasswordCredentials in project pac4j by pac4j.
the class MongoProfileServiceIT method login.
private UsernamePasswordCredentials login(final String username, final String password, final String attribute) {
final MongoProfileService authenticator = new MongoProfileService(getClient(), attribute);
authenticator.setPasswordEncoder(MongoServer.PASSWORD_ENCODER);
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
authenticator.validate(credentials, null);
return credentials;
}
use of org.pac4j.core.credentials.UsernamePasswordCredentials in project pac4j by pac4j.
the class MongoProfileServiceIT method testNullPassword.
@Test
public void testNullPassword() {
final MongoProfileService authenticator = new MongoProfileService(getClient(), FIRSTNAME, MongoServer.PASSWORD_ENCODER);
authenticator.setPasswordAttribute(null);
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD);
TestsHelper.expectException(() -> authenticator.validate(credentials, null), TechnicalException.class, "passwordAttribute cannot be blank");
}
use of org.pac4j.core.credentials.UsernamePasswordCredentials in project pac4j by pac4j.
the class MongoProfileServiceIT method testGoodUsernameNoAttribute.
@Test
public void testGoodUsernameNoAttribute() {
final UsernamePasswordCredentials credentials = login(GOOD_USERNAME, PASSWORD, "");
final CommonProfile profile = credentials.getUserProfile();
assertNotNull(profile);
assertTrue(profile instanceof MongoProfile);
final MongoProfile dbProfile = (MongoProfile) profile;
assertEquals(GOOD_USERNAME, dbProfile.getId());
assertNull(dbProfile.getAttribute(FIRSTNAME));
}
use of org.pac4j.core.credentials.UsernamePasswordCredentials in project pac4j by pac4j.
the class DbProfileServiceTests method testGoodUsernameAttribute.
@Test
public void testGoodUsernameAttribute() {
final UsernamePasswordCredentials credentials = login(GOOD_USERNAME, PASSWORD, FIRSTNAME);
final CommonProfile profile = credentials.getUserProfile();
assertNotNull(profile);
assertTrue(profile instanceof DbProfile);
final DbProfile dbProfile = (DbProfile) profile;
assertEquals(GOOD_USERNAME, dbProfile.getId());
assertEquals(FIRSTNAME_VALUE, dbProfile.getAttribute(FIRSTNAME));
}
Aggregations