Skip to content

Commit 872f77e

Browse files
amm0124jzheaux
authored andcommitted
Add authRequest field to AuthenticationException
Store the authentication request details in the `authRequest` field of `AuthenticationException` when an authentication exception occurs. Closes gh-16444 Signed-off-by: amm0124 <[email protected]>
1 parent e63ef3c commit 872f77e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/src/main/java/org/springframework/security/core/AuthenticationException.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public abstract class AuthenticationException extends RuntimeException {
2929
@Serial
3030
private static final long serialVersionUID = 2018827803361503060L;
3131

32+
private final Authentication authRequest;
33+
3234
/**
3335
* Constructs an {@code AuthenticationException} with the specified message and root
3436
* cause.
@@ -37,6 +39,7 @@ public abstract class AuthenticationException extends RuntimeException {
3739
*/
3840
public AuthenticationException(String msg, Throwable cause) {
3941
super(msg, cause);
42+
this.authRequest = null;
4043
}
4144

4245
/**
@@ -46,6 +49,12 @@ public AuthenticationException(String msg, Throwable cause) {
4649
*/
4750
public AuthenticationException(String msg) {
4851
super(msg);
52+
this.authRequest = null;
53+
}
54+
55+
public AuthenticationException(String msg, Authentication authRequest) {
56+
super(msg);
57+
this.authRequest = authRequest;
4958
}
5059

5160
}

0 commit comments

Comments
 (0)