diff --git a/core/src/main/java/org/springframework/security/core/AuthenticationException.java b/core/src/main/java/org/springframework/security/core/AuthenticationException.java index 9e1fb756086..0bd5bed1ef4 100644 --- a/core/src/main/java/org/springframework/security/core/AuthenticationException.java +++ b/core/src/main/java/org/springframework/security/core/AuthenticationException.java @@ -29,6 +29,8 @@ public abstract class AuthenticationException extends RuntimeException { @Serial private static final long serialVersionUID = 2018827803361503060L; + private final Authentication authRequest; + /** * Constructs an {@code AuthenticationException} with the specified message and root * cause. @@ -37,6 +39,7 @@ public abstract class AuthenticationException extends RuntimeException { */ public AuthenticationException(String msg, Throwable cause) { super(msg, cause); + this.authRequest = null; } /** @@ -46,6 +49,12 @@ public AuthenticationException(String msg, Throwable cause) { */ public AuthenticationException(String msg) { super(msg); + this.authRequest = null; + } + + public AuthenticationException(String msg, Authentication authRequest) { + super(msg); + this.authRequest = authRequest; } }