use of org.springframework.boot.actuate.audit.AuditEvent in project uplace.es by Uplace.
the class AuditResource method getAll.
/**
* GET /audits : get a page of AuditEvents.
*
* @param pageable the pagination information
* @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body
*/
@GetMapping
public ResponseEntity<List<AuditEvent>> getAll(Pageable pageable) {
Page<AuditEvent> page = auditEventService.findAll(pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/management/audits");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
use of org.springframework.boot.actuate.audit.AuditEvent in project zhcet-web by zhcet-amu.
the class LoginAttemptListener method auditEventHappened.
@EventListener
public void auditEventHappened(AuditApplicationEvent auditApplicationEvent) {
AuditEvent auditEvent = auditApplicationEvent.getAuditEvent();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Principal ").append(auditEvent.getPrincipal()).append(" - ").append(auditEvent.getType());
stringBuilder.append("\n Authorities: ").append(auditEvent.getData().get("authorities"));
WebAuthenticationDetails details = (WebAuthenticationDetails) auditEvent.getData().get("details");
loginAttemptService.loginAttempt(auditEvent, details);
if (details != null) {
stringBuilder.append("\n Remote IP address: ").append(details.getRemoteAddress());
stringBuilder.append("\n Session ID: ").append(details.getSessionId());
}
stringBuilder.append("\n Request URL: ").append(auditEvent.getData().get("requestUrl"));
stringBuilder.append("\n Source: ").append(auditEvent.getData().get("source"));
String message = stringBuilder.toString();
if (auditEvent.getType().equals(AuthenticationAuditListener.AUTHENTICATION_FAILURE)) {
log.warn(message);
} else {
log.info(message);
}
}
use of org.springframework.boot.actuate.audit.AuditEvent in project spring-boot by spring-projects.
the class AuthenticationAuditListener method onAuthenticationFailureEvent.
private void onAuthenticationFailureEvent(AbstractAuthenticationFailureEvent event) {
Map<String, Object> data = new HashMap<>();
data.put("type", event.getException().getClass().getName());
data.put("message", event.getException().getMessage());
if (event.getAuthentication().getDetails() != null) {
data.put("details", event.getAuthentication().getDetails());
}
publish(new AuditEvent(event.getAuthentication().getName(), AUTHENTICATION_FAILURE, data));
}
use of org.springframework.boot.actuate.audit.AuditEvent in project spring-boot by spring-projects.
the class AuthenticationAuditListener method onAuthenticationSuccessEvent.
private void onAuthenticationSuccessEvent(AuthenticationSuccessEvent event) {
Map<String, Object> data = new HashMap<>();
if (event.getAuthentication().getDetails() != null) {
data.put("details", event.getAuthentication().getDetails());
}
publish(new AuditEvent(event.getAuthentication().getName(), AUTHENTICATION_SUCCESS, data));
}
use of org.springframework.boot.actuate.audit.AuditEvent in project spring-boot by spring-projects.
the class AuthorizationAuditListener method onAuthorizationFailureEvent.
private void onAuthorizationFailureEvent(AuthorizationFailureEvent event) {
Map<String, Object> data = new HashMap<>();
data.put("type", event.getAccessDeniedException().getClass().getName());
data.put("message", event.getAccessDeniedException().getMessage());
if (event.getAuthentication().getDetails() != null) {
data.put("details", event.getAuthentication().getDetails());
}
publish(new AuditEvent(event.getAuthentication().getName(), AUTHORIZATION_FAILURE, data));
}
Aggregations