Class SecurityEventAuthenticationEventPublisher
java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.SecurityEventAuthenticationEventPublisher
- All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationEventPublisher
@Component
public class SecurityEventAuthenticationEventPublisher
extends Object
implements org.springframework.security.authentication.AuthenticationEventPublisher
Records the authentications of users as security events: a success as
SecurityEventType.LOGIN_SUCCESS and a
failure as SecurityEventType.LOGIN_FAILURE. Authentications that are not a user signing in (OAuth2 client
authentication and bearer tokens of the API) are not recorded. Only the name presented and the type of the failure
are stored, never credentials nor the message of the exception.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanisUserAuthentication(org.springframework.security.core.Authentication authentication) Tells whether an authentication is a user signing in.private static StringnameOf(org.springframework.security.core.Authentication authentication) Gets the name the user presented.voidpublishAuthenticationFailure(org.springframework.security.core.AuthenticationException exception, org.springframework.security.core.Authentication authentication) voidpublishAuthenticationSuccess(org.springframework.security.core.Authentication authentication)
-
Field Details
-
recordSecurityEventUseCase
Records the events.
-
-
Constructor Details
-
SecurityEventAuthenticationEventPublisher
public SecurityEventAuthenticationEventPublisher()
-
-
Method Details
-
publishAuthenticationSuccess
public void publishAuthenticationSuccess(org.springframework.security.core.Authentication authentication) - Specified by:
publishAuthenticationSuccessin interfaceorg.springframework.security.authentication.AuthenticationEventPublisher
-
publishAuthenticationFailure
public void publishAuthenticationFailure(org.springframework.security.core.AuthenticationException exception, org.springframework.security.core.Authentication authentication) - Specified by:
publishAuthenticationFailurein interfaceorg.springframework.security.authentication.AuthenticationEventPublisher
-
isUserAuthentication
private static boolean isUserAuthentication(org.springframework.security.core.Authentication authentication) Tells whether an authentication is a user signing in.- Parameters:
authentication- the authentication.- Returns:
falsefor a client authentication or a bearer token.
-
nameOf
Gets the name the user presented.- Parameters:
authentication- the authentication.- Returns:
- the name, or
nullwhen blank.
-