use of org.springframework.boot.actuate.audit.listener.AuditApplicationEvent in project spring-boot by spring-projects.
the class AuthorizationAuditListenerTests method testAuthorizationFailure.
@Test
void testAuthorizationFailure() {
AuditApplicationEvent event = handleAuthorizationEvent(new AuthorizationFailureEvent(this, Collections.singletonList(new SecurityConfig("USER")), new UsernamePasswordAuthenticationToken("user", "password"), new AccessDeniedException("Bad user")));
assertThat(event.getAuditEvent().getType()).isEqualTo(AuthorizationAuditListener.AUTHORIZATION_FAILURE);
}
use of org.springframework.boot.actuate.audit.listener.AuditApplicationEvent in project spring-boot by spring-projects.
the class AuthorizationAuditListenerTests method testAuthenticationCredentialsNotFound.
@Test
void testAuthenticationCredentialsNotFound() {
AuditApplicationEvent event = handleAuthorizationEvent(new AuthenticationCredentialsNotFoundEvent(this, Collections.singletonList(new SecurityConfig("USER")), new AuthenticationCredentialsNotFoundException("Bad user")));
assertThat(event.getAuditEvent().getType()).isEqualTo(AuthenticationAuditListener.AUTHENTICATION_FAILURE);
}
use of org.springframework.boot.actuate.audit.listener.AuditApplicationEvent in project spring-boot by spring-projects.
the class AuthenticationAuditListenerTests method testDetailsAreIncludedInAuditEvent.
@Test
void testDetailsAreIncludedInAuditEvent() {
Object details = new Object();
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken("user", "password");
authentication.setDetails(details);
AuditApplicationEvent event = handleAuthenticationEvent(new AuthenticationFailureExpiredEvent(authentication, new BadCredentialsException("Bad user")));
assertThat(event.getAuditEvent().getType()).isEqualTo(AuthenticationAuditListener.AUTHENTICATION_FAILURE);
assertThat(event.getAuditEvent().getData()).containsEntry("details", details);
}
use of org.springframework.boot.actuate.audit.listener.AuditApplicationEvent in project spring-boot by spring-projects.
the class AuthenticationAuditListenerTests method testAuthenticationSwitchBackToAnonymous.
@Test
void testAuthenticationSwitchBackToAnonymous() {
AuditApplicationEvent event = handleAuthenticationEvent(new AuthenticationSwitchUserEvent(new UsernamePasswordAuthenticationToken("user", "password"), null));
assertThat(event.getAuditEvent().getType()).isEqualTo(AuthenticationAuditListener.AUTHENTICATION_SWITCH);
}
use of org.springframework.boot.actuate.audit.listener.AuditApplicationEvent in project cas by apereo.
the class AbstractCasEventRepository method save.
@Override
public void save(final CasEvent event) throws Exception {
if (getEventRepositoryFilter().shouldSaveEvent(event)) {
saveInternal(event);
if (applicationEventPublisher != null) {
val auditEvent = new AuditEvent(event.getPrincipalId(), event.getType(), (Map) event.getProperties());
applicationEventPublisher.publishEvent(new AuditApplicationEvent(auditEvent));
}
}
}
Aggregations