Class OAuth2FeignRequestInterceptor

java.lang.Object
org.springframework.cloud.openfeign.security.OAuth2FeignRequestInterceptor
All Implemented Interfaces:
feign.RequestInterceptor

@Deprecated public class OAuth2FeignRequestInterceptor extends Object implements feign.RequestInterceptor
Deprecated.
Pre-defined custom RequestInterceptor for Feign Requests. It uses the OAuth2ClientContext provided from the environment and construct a new header on the request before it is made by Feign.
Since:
3.0.0
Author:
Joao Pedro Evangelista, Tim Ysewyn
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Deprecated.
    The name of the header.
    static final String
    Deprecated.
    The name of the token.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OAuth2FeignRequestInterceptor(org.springframework.security.oauth2.client.OAuth2ClientContext oAuth2ClientContext, org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails resource)
    Deprecated.
    Default constructor which uses the provided OAuth2ClientContext and Bearer tokens within Authorization header.
    OAuth2FeignRequestInterceptor(org.springframework.security.oauth2.client.OAuth2ClientContext oAuth2ClientContext, org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails resource, String tokenType, String header)
    Deprecated.
    Fully customizable constructor for changing token type and header name, in cases of Bearer and Authorization is not the default such as "bearer", "authorization".
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.springframework.security.oauth2.common.OAuth2AccessToken
    Deprecated.
    Try to acquire the token using a access token provider.
    void
    apply(feign.RequestTemplate template)
    Deprecated.
    Create a template with the header of provided name and extracted extract.
    protected String
    extract(String tokenType)
    Deprecated.
    Extracts the token extract id the access token exists or returning an empty extract if there is no one on the context it may occasionally causes Unauthorized response since the token extract is empty.
    org.springframework.security.oauth2.common.OAuth2AccessToken
    Deprecated.
    Extract the access token within the request or try to acquire a new one by delegating it to acquireAccessToken().
    void
    setAccessTokenProvider(org.springframework.security.oauth2.client.token.AccessTokenProvider accessTokenProvider)
    Deprecated.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • OAuth2FeignRequestInterceptor

      public OAuth2FeignRequestInterceptor(org.springframework.security.oauth2.client.OAuth2ClientContext oAuth2ClientContext, org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails resource)
      Deprecated.
      Default constructor which uses the provided OAuth2ClientContext and Bearer tokens within Authorization header.
      Parameters:
      oAuth2ClientContext - provided context
      resource - type of resource to be accessed
    • OAuth2FeignRequestInterceptor

      public OAuth2FeignRequestInterceptor(org.springframework.security.oauth2.client.OAuth2ClientContext oAuth2ClientContext, org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails resource, String tokenType, String header)
      Deprecated.
      Fully customizable constructor for changing token type and header name, in cases of Bearer and Authorization is not the default such as "bearer", "authorization".
      Parameters:
      oAuth2ClientContext - current oAuth2 Context
      resource - type of resource to be accessed
      tokenType - type of token e.g. "token", "Bearer"
      header - name of the header e.g. "Authorization", "authorization"
  • Method Details

    • apply

      public void apply(feign.RequestTemplate template)
      Deprecated.
      Create a template with the header of provided name and extracted extract.
      Specified by:
      apply in interface feign.RequestInterceptor
      See Also:
      • RequestInterceptor.apply(RequestTemplate)
    • extract

      protected String extract(String tokenType)
      Deprecated.
      Extracts the token extract id the access token exists or returning an empty extract if there is no one on the context it may occasionally causes Unauthorized response since the token extract is empty.
      Parameters:
      tokenType - type name of token
      Returns:
      token value from context if it exists otherwise empty String
    • getToken

      public org.springframework.security.oauth2.common.OAuth2AccessToken getToken()
      Deprecated.
      Extract the access token within the request or try to acquire a new one by delegating it to acquireAccessToken().
      Returns:
      valid token
    • acquireAccessToken

      protected org.springframework.security.oauth2.common.OAuth2AccessToken acquireAccessToken() throws org.springframework.security.oauth2.client.resource.UserRedirectRequiredException
      Deprecated.
      Try to acquire the token using a access token provider.
      Returns:
      valid access token
      Throws:
      org.springframework.security.oauth2.client.resource.UserRedirectRequiredException - in case the user needs to be redirected to an approval page or login page
    • setAccessTokenProvider

      public void setAccessTokenProvider(org.springframework.security.oauth2.client.token.AccessTokenProvider accessTokenProvider)
      Deprecated.