Search in sources :

Example 1 with ReflectiveMethodInvocation

use of org.springframework.aop.framework.ReflectiveMethodInvocation in project zhcet-web by zhcet-amu.

the class PathAuthorizationAuditListener method onAuthorizationFailureEvent.

private void onAuthorizationFailureEvent(AuthorizationFailureEvent event) {
    Map<String, Object> data = new HashMap<>();
    data.put("authorities", event.getAuthentication().getAuthorities());
    data.put("type", event.getAccessDeniedException().getClass().getName());
    data.put("message", event.getAccessDeniedException().getMessage());
    if (event.getSource() instanceof FilterInvocation)
        data.put("requestUrl", ((FilterInvocation) event.getSource()).getRequestUrl());
    else if (event.getSource() instanceof ReflectiveMethodInvocation)
        data.put("source", event.getSource());
    if (event.getAuthentication().getDetails() != null) {
        data.put("details", event.getAuthentication().getDetails());
    }
    publish(new AuditEvent(event.getAuthentication().getName(), AuthorizationAuditListener.AUTHORIZATION_FAILURE, data));
}
Also used : HashMap(java.util.HashMap) ReflectiveMethodInvocation(org.springframework.aop.framework.ReflectiveMethodInvocation) AuditEvent(org.springframework.boot.actuate.audit.AuditEvent) FilterInvocation(org.springframework.security.web.FilterInvocation)

Example 2 with ReflectiveMethodInvocation

use of org.springframework.aop.framework.ReflectiveMethodInvocation in project zhcet-web by zhcet-amu.

the class PathAuthorizationAuditListener method onAuthenticationCredentialsNotFoundEvent.

private void onAuthenticationCredentialsNotFoundEvent(AuthenticationCredentialsNotFoundEvent event) {
    Map<String, Object> data = new HashMap<>();
    data.put("type", event.getCredentialsNotFoundException().getClass().getName());
    data.put("message", event.getCredentialsNotFoundException().getMessage());
    if (event.getSource() instanceof FilterInvocation)
        data.put("requestUrl", ((FilterInvocation) event.getSource()).getRequestUrl());
    else if (event.getSource() instanceof ReflectiveMethodInvocation)
        data.put("source", event.getSource());
    publish(new AuditEvent("<unknown>", AuthenticationAuditListener.AUTHENTICATION_FAILURE, data));
}
Also used : HashMap(java.util.HashMap) ReflectiveMethodInvocation(org.springframework.aop.framework.ReflectiveMethodInvocation) AuditEvent(org.springframework.boot.actuate.audit.AuditEvent) FilterInvocation(org.springframework.security.web.FilterInvocation)

Aggregations

HashMap (java.util.HashMap)2 ReflectiveMethodInvocation (org.springframework.aop.framework.ReflectiveMethodInvocation)2 AuditEvent (org.springframework.boot.actuate.audit.AuditEvent)2 FilterInvocation (org.springframework.security.web.FilterInvocation)2