Class LoginErrorMessages

java.lang.Object
com.irurueta.authserver.authorization.api.web.login.LoginErrorMessages

@Component public class LoginErrorMessages extends Object
Maps the exception of a failed sign-in, which Spring Security keeps in the SPRING_SECURITY_LAST_EXCEPTION session attribute, to the key of the message the login page shows.

An unknown user and a wrong password (a BadCredentialsException or a UsernameNotFoundException) deliberately share the generic key, so the two responses are identical and the page never reveals whether an account exists. The account status messages (locked, disabled, expired) cannot reveal it either: the authentication provider of the password feature (PasswordAuthenticationConfiguration) only checks the status after a correct password, so a wrong password for a disabled account is reported as bad credentials too.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Key of the message shown for an expired account.
    static final String
    Key of the message shown for expired credentials.
    static final String
    Key of the message shown for a disabled account.
    static final String
    Key of the message shown for bad credentials, an unknown user and any unexpected failure.
    static final String
    Key of the message shown for a locked account.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    keyOf(org.springframework.security.core.AuthenticationException exception)
    Gets the key of the message that describes a failed sign-in.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • GENERIC

      public static final String GENERIC
      Key of the message shown for bad credentials, an unknown user and any unexpected failure.
      See Also:
    • LOCKED

      public static final String LOCKED
      Key of the message shown for a locked account.
      See Also:
    • ACCOUNT_EXPIRED

      public static final String ACCOUNT_EXPIRED
      Key of the message shown for an expired account.
      See Also:
    • CREDENTIALS_EXPIRED

      public static final String CREDENTIALS_EXPIRED
      Key of the message shown for expired credentials.
      See Also:
    • DISABLED

      public static final String DISABLED
      Key of the message shown for a disabled account.
      See Also:
  • Constructor Details

    • LoginErrorMessages

      public LoginErrorMessages()
  • Method Details

    • keyOf

      public String keyOf(org.springframework.security.core.AuthenticationException exception)
      Gets the key of the message that describes a failed sign-in.
      Parameters:
      exception - the exception of the failed sign-in; null when the session holds none.
      Returns:
      the message key; the generic one for bad credentials, an unknown user and anything unexpected.