public final class OAuthClientUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
createAuthorizationHeader(ClientAccessToken accessToken)
Creates OAuth Authorization header with Bearer scheme
|
static String |
createAuthorizationHeader(ClientAccessToken accessToken,
HttpRequestProperties httpProps)
Creates OAuth Authorization header with the scheme that
may require an access to the current HTTP request properties
|
static ClientAccessToken |
fromMapToClientToken(Map<String,String> map) |
static ClientAccessToken |
fromMapToClientToken(Map<String,String> map,
String defaultTokenType) |
static ClientAccessToken |
getAccessToken(String accessTokenServiceUri,
Consumer consumer,
AccessTokenGrant grant,
boolean setAuthorizationHeader)
Obtains the access token from OAuth AccessToken Service
|
static ClientAccessToken |
getAccessToken(WebClient accessTokenService,
AccessTokenGrant grant)
Obtains the access token from OAuth AccessToken Service
using the initialized web client
|
static ClientAccessToken |
getAccessToken(WebClient accessTokenService,
AccessTokenGrant grant,
Map<String,String> extraParams)
Obtains the access token from OAuth AccessToken Service
using the initialized web client
|
static ClientAccessToken |
getAccessToken(WebClient accessTokenService,
Consumer consumer,
AccessTokenGrant grant)
Obtains the access token from OAuth AccessToken Service
using the initialized web client
|
static ClientAccessToken |
getAccessToken(WebClient accessTokenService,
Consumer consumer,
AccessTokenGrant grant,
boolean setAuthorizationHeader)
Obtains the access token from OAuth AccessToken Service
using the initialized web client
|
static ClientAccessToken |
getAccessToken(WebClient accessTokenService,
Consumer consumer,
AccessTokenGrant grant,
Map<String,String> extraParams,
boolean setAuthorizationHeader)
Obtains the access token from OAuth AccessToken Service
using the initialized web client
|
static ClientAccessToken |
getAccessToken(WebClient accessTokenService,
Consumer consumer,
AccessTokenGrant grant,
Map<String,String> extraParams,
String defaultTokenType,
boolean setAuthorizationHeader)
Obtains the access token from OAuth AccessToken Service
using the initialized web client
|
static URI |
getAuthorizationURI(String authorizationServiceURI,
String clientId,
String redirectUri,
String state,
String scope)
Builds a complete URI for redirecting to OAuth Authorization Service
|
static javax.ws.rs.core.UriBuilder |
getAuthorizationURIBuilder(String authorizationServiceURI,
String clientId,
String scope)
Creates the builder for building OAuth AuthorizationService URIs
|
static ClientAccessToken |
refreshAccessToken(WebClient accessTokenService,
ClientAccessToken at) |
static ClientAccessToken |
refreshAccessToken(WebClient accessTokenService,
Consumer consumer,
ClientAccessToken at) |
static ClientAccessToken |
refreshAccessToken(WebClient accessTokenService,
Consumer consumer,
ClientAccessToken at,
String scope,
boolean setAuthorizationHeader) |
static void |
setAuthorizationHeader(WebClient wc,
ClientAccessToken accessToken) |
static void |
setAuthorizationHeader(WebClient wc,
ClientAccessToken accessToken,
String httpVerb) |
public static URI getAuthorizationURI(String authorizationServiceURI, String clientId, String redirectUri, String state, String scope)
authorizationServiceURI
- the service endpoint addressclientId
- client registration idredirectUri
- the uri the authorization code will be posted tostate
- the client state, example the key or the encrypted token
representing the info about the current end user's requestpublic static javax.ws.rs.core.UriBuilder getAuthorizationURIBuilder(String authorizationServiceURI, String clientId, String scope)
authorizationServiceURI
- the service endpoint addressclientId
- client registration idscope
- the optional scope; if not specified then the authorization
service will allocate the default scopepublic static ClientAccessToken getAccessToken(WebClient accessTokenService, Consumer consumer, AccessTokenGrant grant) throws OAuthServiceException
accessTokenService
- the AccessToken clientconsumer
- Consumer
representing the registered clientgrant
- AccessTokenGrant
grantClientAccessToken
access tokenOAuthServiceException
public static ClientAccessToken getAccessToken(String accessTokenServiceUri, Consumer consumer, AccessTokenGrant grant, boolean setAuthorizationHeader) throws OAuthServiceException
accessTokenServiceUri
- the AccessToken endpoint addressconsumer
- Consumer
representing the registered clientgrant
- AccessTokenGrant
grantsetAuthorizationHeader
- if set to true then HTTP Basic scheme
will be used to pass client id and secret, otherwise they will
be passed in the form payloadClientAccessToken
access tokenOAuthServiceException
public static ClientAccessToken getAccessToken(WebClient accessTokenService, Consumer consumer, AccessTokenGrant grant, boolean setAuthorizationHeader)
accessTokenService
- the AccessToken clientconsumer
- Consumer
representing the registered client.grant
- AccessTokenGrant
grantsetAuthorizationHeader
- if set to true then HTTP Basic scheme
will be used to pass client id and secret, otherwise they will
be passed in the form payloadClientAccessToken
access tokenOAuthServiceException
public static ClientAccessToken getAccessToken(WebClient accessTokenService, AccessTokenGrant grant) throws OAuthServiceException
accessTokenService
- the AccessToken clientgrant
- AccessTokenGrant
grantextraParams
- extra parametersClientAccessToken
access tokenOAuthServiceException
public static ClientAccessToken getAccessToken(WebClient accessTokenService, AccessTokenGrant grant, Map<String,String> extraParams) throws OAuthServiceException
accessTokenService
- the AccessToken clientgrant
- AccessTokenGrant
grantextraParams
- extra parametersClientAccessToken
access tokenOAuthServiceException
public static ClientAccessToken getAccessToken(WebClient accessTokenService, Consumer consumer, AccessTokenGrant grant, Map<String,String> extraParams, boolean setAuthorizationHeader) throws OAuthServiceException
accessTokenService
- the AccessToken clientconsumer
- Consumer
representing the registered client.grant
- AccessTokenGrant
grantextraParams
- extra parameterssetAuthorizationHeader
- if set to true then HTTP Basic scheme
will be used to pass client id and secret, otherwise they will
be passed in the form payloadClientAccessToken
access tokenOAuthServiceException
public static ClientAccessToken refreshAccessToken(WebClient accessTokenService, ClientAccessToken at)
public static ClientAccessToken refreshAccessToken(WebClient accessTokenService, Consumer consumer, ClientAccessToken at)
public static ClientAccessToken refreshAccessToken(WebClient accessTokenService, Consumer consumer, ClientAccessToken at, String scope, boolean setAuthorizationHeader) throws OAuthServiceException
OAuthServiceException
public static ClientAccessToken getAccessToken(WebClient accessTokenService, Consumer consumer, AccessTokenGrant grant, Map<String,String> extraParams, String defaultTokenType, boolean setAuthorizationHeader) throws OAuthServiceException
accessTokenService
- the AccessToken clientconsumer
- Consumer
representing the registered client.grant
- AccessTokenGrant
grantextraParams
- extra parametersdefaultTokenType
- default expected token type - some early
well-known OAuth2 services do not return a required token_type parametersetAuthorizationHeader
- if set to true then HTTP Basic scheme
will be used to pass client id and secret, otherwise they will
be passed in the form payloadClientAccessToken
access tokenOAuthServiceException
public static ClientAccessToken fromMapToClientToken(Map<String,String> map)
public static ClientAccessToken fromMapToClientToken(Map<String,String> map, String defaultTokenType)
public static String createAuthorizationHeader(ClientAccessToken accessToken) throws OAuthServiceException
accessToken
- the access tokenOAuthServiceException
public static String createAuthorizationHeader(ClientAccessToken accessToken, HttpRequestProperties httpProps) throws OAuthServiceException
accessToken
- the access tokenhttpProps
- http request properties, can be null for Bearer tokensOAuthServiceException
public static void setAuthorizationHeader(WebClient wc, ClientAccessToken accessToken)
public static void setAuthorizationHeader(WebClient wc, ClientAccessToken accessToken, String httpVerb)
Apache CXF