Class OAuth2BearerFilter

java.lang.Object
ch.ivyteam.ivy.rest.client.oauth2.OAuth2BearerFilter
All Implemented Interfaces:
javax.ws.rs.client.ClientRequestFilter

@Provider public class OAuth2BearerFilter extends Object implements javax.ws.rs.client.ClientRequestFilter
Filter to simplify OAUTH2 authorization flows.

It initiates OAUTH2 authentication requests to resolve a 'Bearer' token which is sub-sequently added as 'Authorization' request header.

Since:
9.2
API:
This is a public API.
  • Constructor Details

    • OAuth2BearerFilter

      public OAuth2BearerFilter(OAuth2TokenRequester getToken, OAuth2UriProvider uriFactory)
      Parameters:
      getToken - a OAuth2TokenRequester implementation that actually does the 'accessToken' call to the OAUTH2 authority in case the current session has not already a valid accessToken.
      uriFactory - an OAuth2UriProvider to setup OAUTH2 authority URIs for the various requests that may must be fired (.e.g /auth, /token, /userinfo, ...)
      API:
      This public API is available in Java.
  • Method Details

    • tokenSuffix

      public OAuth2BearerFilter tokenSuffix(Supplier<String> tokenSuffix)
      Parameters:
      tokenSuffix - to uniquely identify and separate this token from other on the same restClient and session.
      Returns:
      this instance, for fluent building
      Since:
      10.0.3
      API:
      This public API is available in Java.
    • tokenScopeProperty

      public OAuth2BearerFilter tokenScopeProperty(String scopeProperty)
      Sets a rest-client property, that will be used to isolate your auth-token from other calls to the rest-service, that work with the same session.

      By default we read the rest-client property "AUTH.scope", if it exists and holds a value, it will be used.
      You can pass another property name, if you happen to have your own 'scope' property.

      Parameters:
      scopeProperty - the property of your rest client feature configuration, that holds the "scope" (permissions) to ask for.
      Returns:
      this instance, for fluent building
      Since:
      10.0.3
      API:
      This public API is available in Java.