Browse Source

Ensuring consistency in error handling of opaque providers/managers

The OpaqueTokenAuthenticationProvider now propagates the cause of
introspection exceptions in the same way that the reactive
OpaqueTokenReactiveAuthenticationManager does.

Fixed a final field warning on both OpaqueTokenAuthenticationProvider
and OpaqueTokenReactiveAuthenticationManager.
Ashley Scopes 4 years ago
parent
commit
7ccc915b2b

+ 3 - 3
oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/OpaqueTokenAuthenticationProvider.java

@@ -66,7 +66,7 @@ public final class OpaqueTokenAuthenticationProvider implements AuthenticationPr
 
 	private final Log logger = LogFactory.getLog(getClass());
 
-	private OpaqueTokenIntrospector introspector;
+	private final OpaqueTokenIntrospector introspector;
 
 	/**
 	 * Creates a {@code OpaqueTokenAuthenticationProvider} with the provided parameters
@@ -104,10 +104,10 @@ public final class OpaqueTokenAuthenticationProvider implements AuthenticationPr
 		}
 		catch (BadOpaqueTokenException failed) {
 			this.logger.debug("Failed to authenticate since token was invalid");
-			throw new InvalidBearerTokenException(failed.getMessage());
+			throw new InvalidBearerTokenException(failed.getMessage(), failed);
 		}
 		catch (OAuth2IntrospectionException failed) {
-			throw new AuthenticationServiceException(failed.getMessage());
+			throw new AuthenticationServiceException(failed.getMessage(), failed);
 		}
 	}
 

+ 1 - 1
oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/OpaqueTokenReactiveAuthenticationManager.java

@@ -61,7 +61,7 @@ import org.springframework.util.Assert;
  */
 public class OpaqueTokenReactiveAuthenticationManager implements ReactiveAuthenticationManager {
 
-	private ReactiveOpaqueTokenIntrospector introspector;
+	private final ReactiveOpaqueTokenIntrospector introspector;
 
 	/**
 	 * Creates a {@code OpaqueTokenReactiveAuthenticationManager} with the provided