Class AuthCodeGrantImpl.Builder
- java.lang.Object
-
- org.glassfish.jersey.client.oauth2.AuthCodeGrantImpl.Builder
-
- All Implemented Interfaces:
OAuth2CodeGrantFlow.Builder
- Enclosing class:
- AuthCodeGrantImpl
static class AuthCodeGrantImpl.Builder extends java.lang.Object implements OAuth2CodeGrantFlow.Builder
Builder implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>
accessTokenProperties
private java.lang.String
accessTokenUri
private java.util.Map<java.lang.String,java.lang.String>
authorizationProperties
private java.lang.String
authorizationUri
private java.lang.String
callbackUri
private javax.ws.rs.client.Client
client
private ClientIdentifier
clientIdentifier
private java.util.Map<java.lang.String,java.lang.String>
refreshTokenProperties
private java.lang.String
refreshTokenUri
private java.lang.String
scope
-
Constructor Summary
Constructors Constructor Description Builder()
Create a new builder.Builder(ClientIdentifier clientIdentifier, java.lang.String authorizationUri, java.lang.String accessTokenUri)
Create a new builder with defined URIs and client id.Builder(ClientIdentifier clientIdentifier, java.lang.String authorizationUri, java.lang.String accessTokenUri, java.lang.String callbackUri)
Create a new builder with defined URIs and client id and callback uri.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthCodeGrantImpl.Builder
accessTokenUri(java.lang.String accessTokenUri)
Set the access token URI on which the access token can be requested.AuthCodeGrantImpl.Builder
authorizationUri(java.lang.String authorizationUri)
Set the URI to which the user should be redirected to authorize our application.AuthCodeGrantImpl
build()
Build theOAuth2CodeGrantFlow
instance.AuthCodeGrantImpl.Builder
client(javax.ws.rs.client.Client client)
Set the client that should be used internally by theOAuth1AuthorizationFlow
to make requests to Authorization Server.AuthCodeGrantImpl.Builder
clientIdentifier(ClientIdentifier clientIdentifier)
Set client identifier of the application that should be authorized.(package private) java.util.Map<java.lang.String,java.lang.String>
getAccessTokenProperties()
(package private) java.lang.String
getAccessTokenUri()
(package private) java.util.Map<java.lang.String,java.lang.String>
getAuthorizationProperties()
(package private) java.lang.String
getAuthorizationUri()
(package private) java.lang.String
getCallbackUri()
(package private) javax.ws.rs.client.Client
getClient()
(package private) ClientIdentifier
getClientIdentifier()
(package private) java.util.Map<java.lang.String,java.lang.String>
getRefreshTokenProperties()
(package private) java.lang.String
getRefreshTokenUri()
(package private) java.lang.String
getScope()
AuthCodeGrantImpl.Builder
property(OAuth2CodeGrantFlow.Phase phase, java.lang.String key, java.lang.String value)
Set property (parameter) that will be added to requests or URIs as a query parameters during the Authorization Flow.AuthCodeGrantImpl.Builder
redirectUri(java.lang.String redirectUri)
Set the redirect URI to which the user (resource owner) should be redirected after he/she grants access to our application.AuthCodeGrantImpl.Builder
refreshTokenUri(java.lang.String refreshTokenUri)
Set the refresh token URI on which the access token can be refreshed using a refresh token.AuthCodeGrantImpl.Builder
scope(java.lang.String scope)
Set a scope to which the application will get authorization grant.
-
-
-
Field Detail
-
accessTokenUri
private java.lang.String accessTokenUri
-
refreshTokenUri
private java.lang.String refreshTokenUri
-
authorizationUri
private java.lang.String authorizationUri
-
callbackUri
private java.lang.String callbackUri
-
clientIdentifier
private ClientIdentifier clientIdentifier
-
client
private javax.ws.rs.client.Client client
-
scope
private java.lang.String scope
-
authorizationProperties
private java.util.Map<java.lang.String,java.lang.String> authorizationProperties
-
accessTokenProperties
private java.util.Map<java.lang.String,java.lang.String> accessTokenProperties
-
refreshTokenProperties
private java.util.Map<java.lang.String,java.lang.String> refreshTokenProperties
-
-
Constructor Detail
-
Builder
public Builder()
Create a new builder.
-
Builder
public Builder(ClientIdentifier clientIdentifier, java.lang.String authorizationUri, java.lang.String accessTokenUri)
Create a new builder with defined URIs and client id.
-
Builder
public Builder(ClientIdentifier clientIdentifier, java.lang.String authorizationUri, java.lang.String accessTokenUri, java.lang.String callbackUri)
Create a new builder with defined URIs and client id and callback uri.
-
-
Method Detail
-
accessTokenUri
public AuthCodeGrantImpl.Builder accessTokenUri(java.lang.String accessTokenUri)
Description copied from interface:OAuth2CodeGrantFlow.Builder
Set the access token URI on which the access token can be requested. The URI points to the authorization server and is defined by the Service Provider.- Specified by:
accessTokenUri
in interfaceOAuth2CodeGrantFlow.Builder
- Parameters:
accessTokenUri
- Access token URI.- Returns:
- Builder instance.
-
authorizationUri
public AuthCodeGrantImpl.Builder authorizationUri(java.lang.String authorizationUri)
Description copied from interface:OAuth2CodeGrantFlow.Builder
Set the URI to which the user should be redirected to authorize our application. The URI points to the authorization server and is defined by the Service Provider.- Specified by:
authorizationUri
in interfaceOAuth2CodeGrantFlow.Builder
- Parameters:
authorizationUri
- Authorization URI.- Returns:
- Builder instance.
-
redirectUri
public AuthCodeGrantImpl.Builder redirectUri(java.lang.String redirectUri)
Description copied from interface:OAuth2CodeGrantFlow.Builder
Set the redirect URI to which the user (resource owner) should be redirected after he/she grants access to our application. In most cases, the URI is under control of this application and request done on this URI will be used to extract query parametercode
andstate
that will be used inOAuth2CodeGrantFlow.finish(String, String)
method.If URI is not defined by this method, the default value
urn:ietf:wg:oauth:2.0:oob
will be used in the Authorization Flow which should cause thatcode
will be passed to application in other way than request redirection (for example shown to the user using html page).- Specified by:
redirectUri
in interfaceOAuth2CodeGrantFlow.Builder
- Parameters:
redirectUri
- URI that should receive authorization response from the Service Provider.- Returns:
- Builder instance.
-
clientIdentifier
public AuthCodeGrantImpl.Builder clientIdentifier(ClientIdentifier clientIdentifier)
Description copied from interface:OAuth2CodeGrantFlow.Builder
Set client identifier of the application that should be authorized.- Specified by:
clientIdentifier
in interfaceOAuth2CodeGrantFlow.Builder
- Parameters:
clientIdentifier
- Client identifier.- Returns:
- Builder instance.
-
scope
public AuthCodeGrantImpl.Builder scope(java.lang.String scope)
Description copied from interface:OAuth2CodeGrantFlow.Builder
Set a scope to which the application will get authorization grant. Values of this parameter are defined by the Service Provider and defines usually subset of resource and operations available in the Service Provider.The parameter is optional but ServiceProvider might require it.
- Specified by:
scope
in interfaceOAuth2CodeGrantFlow.Builder
- Parameters:
scope
- Scope string.- Returns:
- Builder instance.
-
client
public AuthCodeGrantImpl.Builder client(javax.ws.rs.client.Client client)
Description copied from interface:OAuth2CodeGrantFlow.Builder
Set the client that should be used internally by theOAuth1AuthorizationFlow
to make requests to Authorization Server. If this method is not called, it is up to the implementation to create or get any private client instance to perform these requests. This method could be used mainly for performance reasons to avoid creation of new client instances and have control about created client instances used in the application.- Specified by:
client
in interfaceOAuth2CodeGrantFlow.Builder
- Parameters:
client
- Client instance.- Returns:
- Builder instance.
-
refreshTokenUri
public AuthCodeGrantImpl.Builder refreshTokenUri(java.lang.String refreshTokenUri)
Description copied from interface:OAuth2CodeGrantFlow.Builder
Set the refresh token URI on which the access token can be refreshed using a refresh token. The URI points to the authorization server and is defined by the Service Provider. If the URI is not defined by this method it will be the same as URI defined inOAuth2CodeGrantFlow.Builder.accessTokenUri(String)
(which is the default value defined by the OAuth2 spec). Some providers do not support refreshing access tokens at all.- Specified by:
refreshTokenUri
in interfaceOAuth2CodeGrantFlow.Builder
- Parameters:
refreshTokenUri
- Refresh token URI.- Returns:
- Builder instance.
-
property
public AuthCodeGrantImpl.Builder property(OAuth2CodeGrantFlow.Phase phase, java.lang.String key, java.lang.String value)
Description copied from interface:OAuth2CodeGrantFlow.Builder
Set property (parameter) that will be added to requests or URIs as a query parameters during the Authorization Flow. Default parameters used during the Authorization Flow can be also overridden by this method.- Specified by:
property
in interfaceOAuth2CodeGrantFlow.Builder
- Parameters:
phase
- Phase of the flow in which the properties (parameters) should be used. For example by using aOAuth2CodeGrantFlow.Phase.ACCESS_TOKEN_REQUEST
, the parameter will be added only to the http request for access token.key
- Property key.value
- Property value.- Returns:
- Builder instance.
-
getAccessTokenUri
java.lang.String getAccessTokenUri()
-
getRefreshTokenUri
java.lang.String getRefreshTokenUri()
-
getAuthorizationUri
java.lang.String getAuthorizationUri()
-
getScope
java.lang.String getScope()
-
getCallbackUri
java.lang.String getCallbackUri()
-
getClientIdentifier
ClientIdentifier getClientIdentifier()
-
getClient
javax.ws.rs.client.Client getClient()
-
getAuthorizationProperties
java.util.Map<java.lang.String,java.lang.String> getAuthorizationProperties()
-
getAccessTokenProperties
java.util.Map<java.lang.String,java.lang.String> getAccessTokenProperties()
-
getRefreshTokenProperties
java.util.Map<java.lang.String,java.lang.String> getRefreshTokenProperties()
-
build
public AuthCodeGrantImpl build()
Description copied from interface:OAuth2CodeGrantFlow.Builder
Build theOAuth2CodeGrantFlow
instance.- Specified by:
build
in interfaceOAuth2CodeGrantFlow.Builder
- Returns:
- New instance of
OAuth2CodeGrantFlow
.
-
-