diff --git a/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationManager.java b/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationManager.java index 5574ebb7c4..8aac51e369 100644 --- a/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationManager.java +++ b/core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationManager.java @@ -77,7 +77,9 @@ public abstract class AbstractAuthenticationManager implements AuthenticationMan * be serialized to the client. Defaults to 'false'. * * @see org.springframework.security.core.AuthenticationException#getExtraInformation() + * @deprecated the {@code extraInformation} property is deprecated */ + @Deprecated public void setClearExtraInformation(boolean clearExtraInformation) { this.clearExtraInformation = clearExtraInformation; } diff --git a/core/src/main/java/org/springframework/security/authentication/AccountStatusException.java b/core/src/main/java/org/springframework/security/authentication/AccountStatusException.java index bf3e1d9955..57c64b47be 100644 --- a/core/src/main/java/org/springframework/security/authentication/AccountStatusException.java +++ b/core/src/main/java/org/springframework/security/authentication/AccountStatusException.java @@ -17,6 +17,7 @@ public abstract class AccountStatusException extends AuthenticationException { super(msg, t); } + @Deprecated protected AccountStatusException(String msg, Object extraInformation) { super(msg, extraInformation); } diff --git a/core/src/main/java/org/springframework/security/authentication/BadCredentialsException.java b/core/src/main/java/org/springframework/security/authentication/BadCredentialsException.java index 7733942fa6..9543a90e69 100644 --- a/core/src/main/java/org/springframework/security/authentication/BadCredentialsException.java +++ b/core/src/main/java/org/springframework/security/authentication/BadCredentialsException.java @@ -36,6 +36,7 @@ public class BadCredentialsException extends AuthenticationException { super(msg); } + @Deprecated public BadCredentialsException(String msg, Object extraInformation) { super(msg, extraInformation); } 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 5f1490050a..d6a5a642f7 100644 --- a/core/src/main/java/org/springframework/security/core/AuthenticationException.java +++ b/core/src/main/java/org/springframework/security/core/AuthenticationException.java @@ -25,12 +25,12 @@ public abstract class AuthenticationException extends RuntimeException { //~ Instance fields ================================================================================================ private Authentication authentication; - private Object extraInformation; + private transient Object extraInformation; //~ Constructors =================================================================================================== /** - * Constructs an AuthenticationException with the specified message and root cause. + * Constructs an {@code AuthenticationException} with the specified message and root cause. * * @param msg the detail message * @param t the root cause @@ -40,7 +40,7 @@ public abstract class AuthenticationException extends RuntimeException { } /** - * Constructs an AuthenticationException with the specified message and no root cause. + * Constructs an {@code AuthenticationException} with the specified message and no root cause. * * @param msg the detail message */ @@ -48,15 +48,22 @@ public abstract class AuthenticationException extends RuntimeException { super(msg); } + /** + * @deprecated Use the exception message or use a custom exception if you really need additional information. + */ + @Deprecated public AuthenticationException(String msg, Object extraInformation) { super(msg); + if (extraInformation instanceof CredentialsContainer) { + ((CredentialsContainer) extraInformation).eraseCredentials(); + } this.extraInformation = extraInformation; } //~ Methods ======================================================================================================== /** - * The authentication request which this exception corresponds to (may be null) + * The authentication request which this exception corresponds to (may be {@code null}) */ public Authentication getAuthentication() { return authentication; @@ -67,14 +74,17 @@ public abstract class AuthenticationException extends RuntimeException { } /** - * Any additional information about the exception. Generally a UserDetails object. + * Any additional information about the exception. Generally a {@code UserDetails} object. * - * @return extra information or null + * @return extra information or {@code null} + * @deprecated Use the exception message or use a custom exception if you really need additional information. */ + @Deprecated public Object getExtraInformation() { return extraInformation; } + @Deprecated public void clearExtraInformation() { this.extraInformation = null; } diff --git a/core/src/main/java/org/springframework/security/core/userdetails/UsernameNotFoundException.java b/core/src/main/java/org/springframework/security/core/userdetails/UsernameNotFoundException.java index 30080cbb2c..b2fd117994 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/UsernameNotFoundException.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/UsernameNotFoundException.java @@ -37,19 +37,19 @@ public class UsernameNotFoundException extends AuthenticationException { } /** - * Constructs a UsernameNotFoundException, making use of the extraInformation + * Constructs a {@code UsernameNotFoundException}, making use of the {@code extraInformation} * property of the superclass. * * @param msg the detail message * @param extraInformation additional information such as the username. */ + @Deprecated public UsernameNotFoundException(String msg, Object extraInformation) { super(msg, extraInformation); } /** - * Constructs a UsernameNotFoundException with the specified - * message and root cause. + * Constructs a {@code UsernameNotFoundException} with the specified message and root cause. * * @param msg the detail message. * @param t root cause