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 Details

  • Constructor Details

    • SecurityEventAuthenticationEventPublisher

      public SecurityEventAuthenticationEventPublisher()
  • Method Details

    • publishAuthenticationSuccess

      public void publishAuthenticationSuccess(org.springframework.security.core.Authentication authentication)
      Specified by:
      publishAuthenticationSuccess in interface org.springframework.security.authentication.AuthenticationEventPublisher
    • publishAuthenticationFailure

      public void publishAuthenticationFailure(org.springframework.security.core.AuthenticationException exception, org.springframework.security.core.Authentication authentication)
      Specified by:
      publishAuthenticationFailure in interface org.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:
      false for a client authentication or a bearer token.
    • nameOf

      private static String nameOf(org.springframework.security.core.Authentication authentication)
      Gets the name the user presented.
      Parameters:
      authentication - the authentication.
      Returns:
      the name, or null when blank.