Class AccessTokenContextRelay

java.lang.Object
org.springframework.cloud.commons.security.AccessTokenContextRelay

public class AccessTokenContextRelay extends Object
Convenience class for relaying an access token from the SecurityContext to the OAuth2ClientContext. If successful then subsequent calls to an OAuth2RestTemplate using the context contained here will use the same access token. This is mostly useful for relaying calls to a resource server downstream to other resource servers. If the access token expires there is no way to refresh it, so expect an exception from downstream (propagating it to the caller is the best strategy, so they can refresh it and try again).
Author:
Dave Syer
  • Constructor Details

    • AccessTokenContextRelay

      public AccessTokenContextRelay(org.springframework.security.oauth2.client.OAuth2ClientContext context)
  • Method Details

    • copyToken

      public boolean copyToken()
      Attempt to copy an access token from the security context into the oauth2 context.
      Returns:
      true if the token was copied