public final class OAuthContext
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
getAccessToken(java.lang.String endpointUrl,
java.lang.String clientId,
java.lang.String code,
IAuthenticationCallback callback)
Acquires a security token from the token endpoint using OAuth authorization_code grant type.
|
void |
getAccessToken(java.lang.String endpointUrl,
java.lang.String clientId,
java.lang.String code,
java.util.Map<java.lang.String,java.lang.Object> params,
IAuthenticationCallback callback)
Acquires a security token from the token endpoint using OAuth authorization_code grant type.
|
void |
getAccessToken(java.lang.String endpointUrl,
java.lang.String clientId,
java.lang.String username,
java.lang.String password,
IAuthenticationCallback callback)
Acquires a security token from the token endpoint using OAuth resource owner password grant type.
|
void |
getAccessToken(java.lang.String endpointUrl,
java.lang.String clientId,
java.lang.String username,
java.lang.String password,
java.util.Map<java.lang.String,java.lang.Object> params,
IAuthenticationCallback callback)
Acquires a security token from the token endpoint using OAuth resource owner password grant type.
|
java.util.HashMap<java.lang.String,java.lang.String> |
getHeaders()
Returns a HashMap of custom headers to be added to each http/s request
|
javax.net.ssl.SSLContext |
getSslContext()
Returns the
SSLContext object. |
void |
refreshAccessToken(java.lang.String endpointUrl,
java.lang.String clientId,
java.lang.String refreshToken,
IAuthenticationCallback callback)
Acquires a security refresh token from the token endpoint using OAuth refresh_token grant type.
|
void |
refreshAccessToken(java.lang.String endpointUrl,
java.lang.String clientId,
java.lang.String refreshToken,
java.util.Map<java.lang.String,java.lang.Object> params,
IAuthenticationCallback callback)
Acquires a security refresh token from the token endpoint using OAuth refresh_token grant type.
|
void |
setClientSecret(java.lang.String clientSecret)
Sets the secret between the service and the app.
|
void |
setConnectionTimeOut(int connectionTimeOut)
Sets the connection timeout to a specified timeout, in milliseconds.
|
void |
setHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
Sets the
HostnameVerifier to use self-signed or unknown certificates for HttpsURLConnection ,
hat the host name is an acceptable match with the server's authentication scheme. |
void |
setReadTimeOut(int readTimeOut)
Sets the read timeout to a specified timeout, in milliseconds.
|
void |
setScope(java.lang.String[] scope)
Sets an array of
String of scopes to be authorized. |
void |
setSslContext(javax.net.ssl.SSLContext sslContext)
Sets the
SSLContext to use self-signed or unknown certificates for HttpsURLConnection . |
static OAuthContext |
sharedInstance()
Returns the shared defaults object.
|
public static OAuthContext sharedInstance()
public void setClientSecret(java.lang.String clientSecret)
clientSecret
- the secret between the service and the app.public java.util.HashMap<java.lang.String,java.lang.String> getHeaders()
public void setScope(java.lang.String[] scope)
String
of scopes to be authorized.scope
- an array of String
of scopes to be authorizedFor OpenID Connect registration using ROPC, a scope must contain oidc
public void getAccessToken(java.lang.String endpointUrl, java.lang.String clientId, java.lang.String username, java.lang.String password, IAuthenticationCallback callback)
endpointUrl
- the location to the OAuth endpointclientId
- the unique identifier between the service and the appusername
- the usernamepassword
- the password for usernamecallback
- the function delegate that is invoked with a OAuthResult
.java.lang.IllegalArgumentException
- if callback is nullpublic void getAccessToken(java.lang.String endpointUrl, java.lang.String clientId, java.lang.String username, java.lang.String password, java.util.Map<java.lang.String,java.lang.Object> params, IAuthenticationCallback callback)
endpointUrl
- the location to the OAuth endpointclientId
- the unique identifier between the service and the appusername
- the usernamepassword
- the password for usernameparams
- Additional parameters associated with the requestcallback
- the function delegate that is invoked with a OAuthResult
java.lang.IllegalArgumentException
- if callback is nullpublic void getAccessToken(java.lang.String endpointUrl, java.lang.String clientId, java.lang.String code, IAuthenticationCallback callback)
endpointUrl
- the location to the OAuth endpointclientId
- the unique identifier between the service and the appcode
- the authorisation code provided by the OAuth endpointcallback
- the function delegate that is invoked with a OAuthResult
java.lang.IllegalArgumentException
- if callback is nullpublic void getAccessToken(java.lang.String endpointUrl, java.lang.String clientId, java.lang.String code, java.util.Map<java.lang.String,java.lang.Object> params, IAuthenticationCallback callback)
endpointUrl
- the location to the OAuth endpointclientId
- the unique identifier between the service and the appcode
- the authorisation code provided by the OAuth endpointparams
- Additional parameters associated with the requestcallback
- the function delegate that is invoked with a OAuthResult
java.lang.IllegalArgumentException
- if callback is nullpublic void refreshAccessToken(java.lang.String endpointUrl, java.lang.String clientId, java.lang.String refreshToken, IAuthenticationCallback callback)
endpointUrl
- the location to the OAuth endpointclientId
- the unique identifier between the service and the apprefreshToken
- the refresh tokencallback
- the function delegate that is invoked with a OAuthResult
java.lang.IllegalArgumentException
- if callback is nullpublic void refreshAccessToken(java.lang.String endpointUrl, java.lang.String clientId, java.lang.String refreshToken, java.util.Map<java.lang.String,java.lang.Object> params, IAuthenticationCallback callback)
endpointUrl
- the location to the OAuth endpointclientId
- the unique identifier between the service and the apprefreshToken
- the refresh tokenparams
- Additional parameters associated with the requestcallback
- the function delegate that is invoked with a OAuthResult
java.lang.IllegalArgumentException
- if callback is nullpublic void setReadTimeOut(int readTimeOut) throws java.lang.IllegalArgumentException
30000
.readTimeOut
- time out in millisecondsjava.lang.IllegalArgumentException
- if parameter is <= 0public void setConnectionTimeOut(int connectionTimeOut) throws java.lang.IllegalArgumentException
30000
.connectionTimeOut
- time out in millisecondsjava.lang.IllegalArgumentException
- if parameter is <= 0public javax.net.ssl.SSLContext getSslContext()
SSLContext
object.SSLContext
public void setSslContext(javax.net.ssl.SSLContext sslContext)
SSLContext
to use self-signed or unknown certificates for HttpsURLConnection
.
If sslContext is not null, it will be used to validate the HttpsURLConnection
,
otherwise it won't be set.
One way to provide a sslContext is described here
sslContext
- A SSLContext instance that contains the list of certificates.public void setHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
HostnameVerifier
to use self-signed or unknown certificates for HttpsURLConnection
,
hat the host name is an acceptable match with the server's authentication scheme.
hostnameVerifier
will only be set if BaseNetworkContext.sslContext
is set as well (not null).
If hostnameVerifier is not null, the overwritten HostnameVerifier.verify(String, SSLSession)
method will be invoked to verify the host name. Otherwise the inherited HostnameVerifier
instance is used.
hostnameVerifier
- A HostnameVerifier
instance that contains an overwritten
HostnameVerifier.verify(String, SSLSession)
method