use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class CheckPasswordExpiredCommandTest method testExecute_mustChangePasswordAndRequestNotDirectlyToSimba_redirectToChangePasswordWithRequestURLAsTarget.
@Test
public void testExecute_mustChangePasswordAndRequestNotDirectlyToSimba_redirectToChangePasswordWithRequestURLAsTarget() throws Exception {
when(credentialServiceMock.mustChangePasswordOnNextLogon(USER_NAME)).thenReturn(Boolean.TRUE);
when(contextMock.getRequestURL()).thenReturn("requestURL");
when(contextMock.getSimbaWebURL()).thenReturn("simbaWebURL");
State state = command.execute(contextMock);
assertEquals(State.FINISH, state);
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(MUST_CHANGE_PASSWORD, resultAuditLogEvent.getMessage());
verify(contextMock).redirectToChangePasswordWithFilter();
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class CheckPasswordExpiredCommandTest method testExecute_isChangePasswordRequest_continue.
@Test
public void testExecute_isChangePasswordRequest_continue() throws Exception {
when(contextMock.isChangePasswordRequest()).thenReturn(Boolean.TRUE);
State result = command.execute(contextMock);
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(SUCCESS + CHECK_PASSWORD_EXPIRED, resultAuditLogEvent.getMessage());
assertEquals(State.CONTINUE, result);
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class ExcludeResourceCommandTest method testExecute_resourceNotExcluded_continues.
@Test
public void testExecute_resourceNotExcluded_continues() throws Exception {
when(mockExcludedResourceService.isResourceExcluded(DUMMY_URL)).thenReturn(FALSE);
assertEquals(State.CONTINUE, command.execute(contextMock));
verify(auditMock).log(captor.capture());
AuditLogEvent resultAuditLogEvent = captor.getValue();
assertEquals(AuditLogEventCategory.AUTHENTICATION, resultAuditLogEvent.getCategory());
assertEquals(AuditMessages.NO_EXCLUDED_RESOURCE + DUMMY_URL, resultAuditLogEvent.getMessage());
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class CheckTokenCommand method existingUsersDoNotMatch.
private boolean existingUsersDoNotMatch(ChainContext context, User userFromEmail, User userFromToken) {
if (!userFromToken.equals(userFromEmail)) {
AuditLogEvent event = auditLogEventFactory.createEventForAuthentication(context, String.format("There was an unsuccessful reset password attempt for email address %s, but the user associated with the token [%s] was different from the user associated with the email address [%s].", userFromEmail.getEmail().asString(), userFromToken.getUserName(), userFromEmail.getUserName()));
audit.log(event);
context.redirectToWrongToken();
return true;
}
return false;
}
use of org.simbasecurity.core.audit.AuditLogEvent in project simba-os by cegeka.
the class CheckTokenCommand method noExistingUserForEmail.
private boolean noExistingUserForEmail(ChainContext context, Optional<User> userFromEmail) {
if (!userFromEmail.isPresent()) {
context.getEmail().ifPresent(emailInCtx -> {
AuditLogEvent event = auditLogEventFactory.createEventForAuthentication(context, String.format("There was an unsuccessful reset password attempt for email address %s, but there was no user found for that email address.", emailInCtx));
audit.log(event);
});
context.redirectToWrongToken();
return true;
}
return false;
}
Aggregations