use of org.apache.jackrabbit.oak.spi.security.authentication.Authentication in project jackrabbit-oak by apache.
the class UserAuthenticationFactoryImplTest method testGetAuthentication.
@Test
public void testGetAuthentication() throws Exception {
Authentication authentication = factory.getAuthentication(getUserConfiguration(), root, userId);
assertNotNull(authentication);
assertTrue(authentication instanceof UserAuthentication);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.Authentication in project jackrabbit-oak by apache.
the class PasswordExpiryAndForceInitialChangeTest method testChangePasswordReset.
@Test
public void testChangePasswordReset() throws Exception {
// once the user changes the password, the login should succeed
User user = getTestUser();
user.changePassword(userId);
root.commit();
PropertyState p = root.getTree(user.getPath()).getChild(UserConstants.REP_PWD).getProperty(UserConstants.REP_PASSWORD_LAST_MODIFIED);
long newModTime = p.getValue(Type.LONG);
assertTrue(newModTime > 0);
Authentication a = new UserAuthentication(getUserConfiguration(), root, userId);
// during user creation pw last modified is set, thus it shouldn't expire
a.authenticate(new SimpleCredentials(userId, userId.toCharArray()));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.Authentication in project jackrabbit-oak by apache.
the class PasswordExpiryHistoryTest method testAuthenticatePasswordExpiredAndInHistory.
@Test
public void testAuthenticatePasswordExpiredAndInHistory() throws Exception {
User user = getTestUser();
user.changePassword("pw12345678");
Authentication a = new UserAuthentication(getUserConfiguration(), root, userId);
// set password last modified to beginning of epoch
root.getTree(user.getPath()).getChild(UserConstants.REP_PWD).setProperty(UserConstants.REP_PASSWORD_LAST_MODIFIED, 0);
root.commit();
try {
a.authenticate(new SimpleCredentials(userId, "pw12345678".toCharArray()));
fail("Credentials should be expired");
} catch (CredentialExpiredException e) {
// success, credentials are expired
// try to change password to the same one, this should fail due pw history
SimpleCredentials pwChangeCreds = new SimpleCredentials(userId, "pw12345678".toCharArray());
try {
pwChangeCreds.setAttribute(UserConstants.CREDENTIALS_ATTRIBUTE_NEWPASSWORD, user.getID());
a.authenticate(pwChangeCreds);
fail("User password changed in spite of enabled pw history");
} catch (CredentialExpiredException c) {
// success, pw found in history
Object attr = pwChangeCreds.getAttribute(PasswordHistoryException.class.getSimpleName());
assertEquals("credentials should contain pw change failure reason", "New password was found in password history.", attr);
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.Authentication in project jackrabbit-oak by apache.
the class PasswordExpiryTest method testAuthenticatePasswordExpiredNewUser.
@Test
public void testAuthenticatePasswordExpiredNewUser() throws Exception {
Authentication a = new UserAuthentication(getUserConfiguration(), root, userId);
// during user creation pw last modified is set, thus it shouldn't expire
a.authenticate(new SimpleCredentials(userId, userId.toCharArray()));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.Authentication in project jackrabbit-oak by apache.
the class PasswordForceInitialPasswordChangeTest method testAuthenticateMustChangePassword.
@Test
public void testAuthenticateMustChangePassword() throws Exception {
Authentication a = new UserAuthentication(getUserConfiguration(), root, userId);
try {
a.authenticate(new SimpleCredentials(userId, userId.toCharArray()));
fail("Credentials should be expired");
} catch (CredentialExpiredException e) {
// success
}
}
Aggregations