Package com.docusign.esign.client.auth
Class OAuth
- java.lang.Object
-
- com.docusign.esign.client.auth.OAuth
-
- All Implemented Interfaces:
Authentication
public class OAuth extends Object implements Authentication
OAuth class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOAuth.AccountAccount model with the below properties.static classOAuth.LinkLink model with the below properties.static classOAuth.OAuthTokenOAuthToken model with the following properties.static classOAuth.OrganizationOrganization model with the below properties.static classOAuth.UserInfoUserInfo model with the below properties.
-
Field Summary
Fields Modifier and Type Field Description static StringCODEused by public/native client applications.static StringDEMO_OAUTH_BASEPATHsandbox/demo base path.static StringGRANT_TYPE_JWTJWT grant type.static StringPRODUCTION_OAUTH_BASEPATHlive/production base path.static StringScope_EXTENDEDobtain a refresh token with an extended lifetime.static StringScope_IMPERSONATIONobtain access to the user’s account when the user is not present.static StringScope_SIGNATUREcreate and send envelopes, and obtain links for starting signing sessions.static StringSTAGE_OAUTH_BASEPATHstage base path.static StringTOKENused by private/trusted client application.
-
Constructor Summary
Constructors Constructor Description OAuth()OAuth constructor.OAuth(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes)OAuth constructor.OAuth(jakarta.ws.rs.client.Client httpClient)OAuth(jakarta.ws.rs.client.Client client, OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes)OAuth constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyToParams(List<Pair> queryParams, Map<String,String> headerParams)applyToParams method.protected Map<String,List<String>>buildResponseHeaders(jakarta.ws.rs.core.Response response)<T> Tdeserialize(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> returnType)Deserialize response body to Java object according to the Content-Type.OAuth.OAuthTokengenerateAccessToken()Helper method to configure the OAuth accessCode/implicit flow parameters.StringgetAccessToken()getAccessToken method.StringgetAuthCode()StringgetAuthorizationUrl()StringgetClientId()StringgetClientSecret()LonggetExpirationTimeMillis()OAuthFlowgetGrantType()StringgetJwtAssertion()StringgetRedirectURI()StringgetScope()StringgetTokenUrl()StringparameterToString(Object param)Format the given parameter object into string.voidregisterAccessTokenListener(AccessTokenListener accessTokenListener)registerAccessTokenListener method.OAuth.OAuthTokenrequestJWTUserToken()Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign.jakarta.ws.rs.client.Entity<?>serialize(Object obj, Map<String,Object> formParams, String contentType)Serialize the given Java object into string entity according the given Content-Type (only JSON is supported for now).voidsetAccessToken(String accessToken, Long expiresIn)voidsetAuthCode(String authCode)voidsetAuthorizationUrl(String authorizationUrl)voidsetClientId(String clientId)voidsetClientSecret(String clientSecret)voidsetExpirationTimeMillis(Long expirationTimeMillis)voidsetGrantType(OAuthFlow grantType)voidsetJwtAssertion(String jwtAssertion)voidsetRedirectURI(String redirectURI)voidsetScope(String scope)voidsetTokenUrl(String tokenUrl)voidupdateAccessToken()updateAccessToken method.
-
-
-
Field Detail
-
Scope_SIGNATURE
public static final String Scope_SIGNATURE
create and send envelopes, and obtain links for starting signing sessions.- See Also:
- Constant Field Values
-
Scope_EXTENDED
public static final String Scope_EXTENDED
obtain a refresh token with an extended lifetime.- See Also:
- Constant Field Values
-
Scope_IMPERSONATION
public static final String Scope_IMPERSONATION
obtain access to the user’s account when the user is not present.- See Also:
- Constant Field Values
-
CODE
public static final String CODE
used by public/native client applications.- See Also:
- Constant Field Values
-
TOKEN
public static final String TOKEN
used by private/trusted client application.- See Also:
- Constant Field Values
-
PRODUCTION_OAUTH_BASEPATH
public static final String PRODUCTION_OAUTH_BASEPATH
live/production base path.- See Also:
- Constant Field Values
-
DEMO_OAUTH_BASEPATH
public static final String DEMO_OAUTH_BASEPATH
sandbox/demo base path.- See Also:
- Constant Field Values
-
STAGE_OAUTH_BASEPATH
public static final String STAGE_OAUTH_BASEPATH
stage base path.- See Also:
- Constant Field Values
-
GRANT_TYPE_JWT
public static final String GRANT_TYPE_JWT
JWT grant type.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OAuth
public OAuth()
OAuth constructor.
-
OAuth
public OAuth(jakarta.ws.rs.client.Client httpClient)
-
OAuth
public OAuth(jakarta.ws.rs.client.Client client, OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes)OAuth constructor.- Parameters:
client- The client to useflow- The OAuth flowauthorizationUrl- The auth urltokenUrl- The token URLscopes- The scopes to use
-
-
Method Detail
-
applyToParams
public void applyToParams(List<Pair> queryParams, Map<String,String> headerParams)
applyToParams method.- Specified by:
applyToParamsin interfaceAuthentication- Parameters:
queryParams- The query paramsheaderParams- The header params
-
updateAccessToken
public void updateAccessToken() throws ApiExceptionupdateAccessToken method.- Throws:
ApiException
-
requestJWTUserToken
public OAuth.OAuthToken requestJWTUserToken() throws IllegalArgumentException, ApiException, IOException
Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign.- Returns:
- OAuth.OAuthToken object.
- Throws:
IllegalArgumentException- if one of the arguments is invalidApiException- if there is an error while exchanging the JWT with an access tokenIOException- if there is an issue with either the public or private file
-
generateAccessToken
public OAuth.OAuthToken generateAccessToken() throws ApiException, IOException
Helper method to configure the OAuth accessCode/implicit flow parameters.- Returns:
- OAuth.OAuthToken object.
- Throws:
ApiException- if the HTTP call status is different than 2xx.IOException- if there is a problem while parsing the reponse object.- See Also:
OAuth.OAuthToken
-
registerAccessTokenListener
public void registerAccessTokenListener(AccessTokenListener accessTokenListener)
registerAccessTokenListener method.- Parameters:
accessTokenListener- The access token listener
-
getAccessToken
public String getAccessToken()
getAccessToken method.- Returns:
- String
-
getExpirationTimeMillis
public Long getExpirationTimeMillis()
-
setExpirationTimeMillis
public void setExpirationTimeMillis(Long expirationTimeMillis)
-
getClientId
public String getClientId()
-
setClientId
public void setClientId(String clientId)
-
getClientSecret
public String getClientSecret()
-
setClientSecret
public void setClientSecret(String clientSecret)
-
getAuthorizationUrl
public String getAuthorizationUrl()
-
setAuthorizationUrl
public void setAuthorizationUrl(String authorizationUrl)
-
getTokenUrl
public String getTokenUrl()
-
setTokenUrl
public void setTokenUrl(String tokenUrl)
-
getRedirectURI
public String getRedirectURI()
-
setRedirectURI
public void setRedirectURI(String redirectURI)
-
getScope
public String getScope()
-
setScope
public void setScope(String scope)
-
getGrantType
public OAuthFlow getGrantType()
-
setGrantType
public void setGrantType(OAuthFlow grantType)
-
getJwtAssertion
public String getJwtAssertion()
-
setJwtAssertion
public void setJwtAssertion(String jwtAssertion)
-
getAuthCode
public String getAuthCode()
-
setAuthCode
public void setAuthCode(String authCode)
-
buildResponseHeaders
protected Map<String,List<String>> buildResponseHeaders(jakarta.ws.rs.core.Response response)
-
serialize
public jakarta.ws.rs.client.Entity<?> serialize(Object obj, Map<String,Object> formParams, String contentType) throws ApiException
Serialize the given Java object into string entity according the given Content-Type (only JSON is supported for now).- Parameters:
obj- ObjectformParams- Form parameterscontentType- Context type- Returns:
- Entity
- Throws:
ApiException- API exception
-
parameterToString
public String parameterToString(Object param)
Format the given parameter object into string.- Parameters:
param- Object- Returns:
- Object in string format
-
deserialize
public <T> T deserialize(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> returnType) throws ApiExceptionDeserialize response body to Java object according to the Content-Type.- Type Parameters:
T- Type- Parameters:
response- ResponsereturnType- Return type- Returns:
- Deserialize object
- Throws:
ApiException- API exception
-
-