public class AuthenticationContext extends Object
Constructor and Description |
---|
AuthenticationContext(String authority,
boolean validateAuthority,
ExecutorService service)
Constructor to create the context with the address of the authority.
|
Modifier and Type | Method and Description |
---|---|
Future<DeviceCode> |
acquireDeviceCode(String clientId,
String resource,
AuthenticationCallback<DeviceCode> callback)
Acquires a device code from the authority
|
Future<AuthenticationResult> |
acquireToken(String resource,
AsymmetricKeyCredential credential,
AuthenticationCallback callback)
Acquires security token from the authority.
|
Future<AuthenticationResult> |
acquireToken(String resource,
ClientAssertion clientAssertion,
AuthenticationCallback callback)
Acquires security token from the authority.
|
Future<AuthenticationResult> |
acquireToken(String resource,
ClientCredential credential,
AuthenticationCallback callback)
Acquires security token from the authority.
|
Future<AuthenticationResult> |
acquireToken(String resource,
String clientId,
String username,
String password,
AuthenticationCallback callback)
Acquires a security token from the authority using a username/password flow.
|
Future<AuthenticationResult> |
acquireToken(String resource,
UserAssertion userAssertion,
AsymmetricKeyCredential credential,
AuthenticationCallback callback)
Acquires an access token from the authority on behalf of a user.
|
Future<AuthenticationResult> |
acquireToken(String resource,
UserAssertion userAssertion,
ClientCredential credential,
AuthenticationCallback callback)
Acquires an access token from the authority on behalf of a user.
|
Future<AuthenticationResult> |
acquireTokenByAuthorizationCode(String authorizationCode,
String resource,
String clientId,
URI redirectUri,
AuthenticationCallback callback)
Acquires security token from the authority using an authorization code
previously received.
|
Future<AuthenticationResult> |
acquireTokenByAuthorizationCode(String authorizationCode,
URI redirectUri,
AsymmetricKeyCredential credential,
AuthenticationCallback callback)
Acquires security token from the authority using an authorization code
previously received.
|
Future<AuthenticationResult> |
acquireTokenByAuthorizationCode(String authorizationCode,
URI redirectUri,
AsymmetricKeyCredential credential,
String resource,
AuthenticationCallback callback)
Acquires security token from the authority using an authorization code
previously received.
|
Future<AuthenticationResult> |
acquireTokenByAuthorizationCode(String authorizationCode,
URI redirectUri,
ClientAssertion clientAssertion,
AuthenticationCallback callback)
Acquires security token from the authority using an authorization code
previously received.
|
Future<AuthenticationResult> |
acquireTokenByAuthorizationCode(String authorizationCode,
URI redirectUri,
ClientAssertion clientAssertion,
String resource,
AuthenticationCallback callback)
Acquires security token from the authority using an authorization code
previously received.
|
Future<AuthenticationResult> |
acquireTokenByAuthorizationCode(String authorizationCode,
URI redirectUri,
ClientCredential credential,
AuthenticationCallback callback)
Acquires security token from the authority using an authorization code
previously received.
|
Future<AuthenticationResult> |
acquireTokenByAuthorizationCode(String authorizationCode,
URI redirectUri,
ClientCredential credential,
String resource,
AuthenticationCallback callback)
Acquires security token from the authority using an authorization code
previously received.
|
Future<AuthenticationResult> |
acquireTokenByDeviceCode(DeviceCode deviceCode,
AuthenticationCallback callback)
Acquires security token from the authority using an device code previously received.
|
Future<AuthenticationResult> |
acquireTokenByRefreshToken(String refreshToken,
AsymmetricKeyCredential credential,
AuthenticationCallback callback)
Acquires a security token from the authority using a Refresh Token
previously received.
|
Future<AuthenticationResult> |
acquireTokenByRefreshToken(String refreshToken,
AsymmetricKeyCredential credential,
String resource,
AuthenticationCallback callback)
Acquires a security token from the authority using a Refresh Token
previously received.
|
Future<AuthenticationResult> |
acquireTokenByRefreshToken(String refreshToken,
ClientCredential credential,
AuthenticationCallback callback)
Acquires a security token from the authority using a Refresh Token
previously received.
|
Future<AuthenticationResult> |
acquireTokenByRefreshToken(String refreshToken,
ClientCredential credential,
String resource,
AuthenticationCallback callback)
Acquires a security token from the authority using a Refresh Token
previously received.
|
Future<AuthenticationResult> |
acquireTokenByRefreshToken(String refreshToken,
String clientId,
AuthenticationCallback callback)
Acquires a security token from the authority using a Refresh Token
previously received.
|
Future<AuthenticationResult> |
acquireTokenByRefreshToken(String refreshToken,
String clientId,
ClientAssertion clientAssertion,
AuthenticationCallback callback)
Acquires a security token from the authority using a Refresh Token
previously received.
|
Future<AuthenticationResult> |
acquireTokenByRefreshToken(String refreshToken,
String clientId,
ClientAssertion clientAssertion,
String resource,
AuthenticationCallback callback)
Acquires a security token from the authority using a Refresh Token
previously received.
|
Future<AuthenticationResult> |
acquireTokenByRefreshToken(String refreshToken,
String clientId,
String resource,
AuthenticationCallback callback)
Acquires a security token from the authority using a Refresh Token
previously received.
|
String |
getAuthority()
Authority associated with the context instance
|
String |
getCorrelationId()
Returns the correlation id configured by the user.
|
Proxy |
getProxy()
Returns Proxy configuration
|
SSLSocketFactory |
getSslSocketFactory()
Returns SSLSocketFactory configuration object.
|
boolean |
isLogPii()
Returns logPii - boolean value, which determines
whether Pii (personally identifiable information) will be logged in
|
void |
setCorrelationId(String correlationId)
Set optional correlation id to be used by the API.
|
void |
setLogPii(boolean logPii)
Set logPii - boolean value, which determines
whether Pii (personally identifiable information) will be logged in
|
void |
setProxy(Proxy proxy)
Sets Proxy configuration to be used by the context for all network
communication.
|
void |
setSslSocketFactory(SSLSocketFactory sslSocketFactory)
Sets SSLSocketFactory object to be used by the context.
|
boolean |
shouldValidateAuthority()
Returns validateAuthority boolean value passed as a constructor
parameter.
|
public AuthenticationContext(String authority, boolean validateAuthority, ExecutorService service) throws MalformedURLException
authority
- URL of the authenticating authorityvalidateAuthority
- flag to enable/disable authority validation.service
- ExecutorService to be used to execute the requests. Developer
is responsible for maintaining the lifetime of the
ExecutorService.MalformedURLException
- thrown if URL is invalidpublic boolean isLogPii()
public void setLogPii(boolean logPii)
logPii
- boolean valuepublic Proxy getProxy()
public void setProxy(Proxy proxy)
proxy
- Proxy configuration objectpublic SSLSocketFactory getSslSocketFactory()
public void setSslSocketFactory(SSLSocketFactory sslSocketFactory)
sslSocketFactory
- The SSL factory object to setpublic Future<AuthenticationResult> acquireToken(String resource, String clientId, String username, String password, AuthenticationCallback callback)
clientId
- Name or ID of the client requesting the token.resource
- Identifier of the target resource that is the recipient of the
requested token.username
- Username of the managed or federated user.password
- Password of the managed or federated user.
If null, integrated authentication will be used.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireToken(String resource, ClientAssertion clientAssertion, AuthenticationCallback callback)
resource
- Identifier of the target resource that is the recipient of the
requested token.clientAssertion
- The client assertion to use for client authentication.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token and the Access Token's expiration time. Refresh Token
property will be null for this overload.public Future<AuthenticationResult> acquireToken(String resource, UserAssertion userAssertion, ClientCredential credential, AuthenticationCallback callback)
resource
- Identifier of the target resource that is the recipient of the
requested token.userAssertion
- userAssertion to use as Authorization grantcredential
- The client credential to use for token acquisition.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token and the Access Token's expiration time. Refresh Token
property will be null for this overload.AuthenticationException
- AuthenticationException
public Future<AuthenticationResult> acquireToken(String resource, UserAssertion userAssertion, AsymmetricKeyCredential credential, AuthenticationCallback callback)
resource
- Identifier of the target resource that is the recipient of the
requested token.userAssertion
- userAssertion to use as Authorization grantcredential
- The certificate based client credential to use for token acquisition.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token and the Access Token's expiration time. Refresh Token
property will be null for this overload.AuthenticationException
- AuthenticationException
public Future<AuthenticationResult> acquireToken(String resource, ClientCredential credential, AuthenticationCallback callback)
resource
- Identifier of the target resource that is the recipient of the
requested token.credential
- The client credential to use for token acquisition.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token and the Access Token's expiration time. Refresh Token
property will be null for this overload.public Future<AuthenticationResult> acquireToken(String resource, AsymmetricKeyCredential credential, AuthenticationCallback callback) throws AuthenticationException
resource
- Identifier of the target resource that is the recipient of the
requested token.credential
- object representing Private Key to use for token acquisition.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token and the Access Token's expiration time. Refresh Token
property will be null for this overload.AuthenticationException
- AuthenticationException
public Future<AuthenticationResult> acquireTokenByAuthorizationCode(String authorizationCode, String resource, String clientId, URI redirectUri, AuthenticationCallback callback)
authorizationCode
- The authorization code received from service authorizationresource
- Identifier of the target resource that is the recipient of the
requested token.clientId
- The client assertion to use for token acquisition endpoint.redirectUri
- The redirect address used for obtaining authorization code.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByAuthorizationCode(String authorizationCode, URI redirectUri, ClientAssertion clientAssertion, AuthenticationCallback callback)
authorizationCode
- The authorization code received from service authorization
endpoint.redirectUri
- The redirect address used for obtaining authorization code.clientAssertion
- The client assertion to use for client authentication.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByAuthorizationCode(String authorizationCode, URI redirectUri, ClientAssertion clientAssertion, String resource, AuthenticationCallback callback)
authorizationCode
- The authorization code received from service authorization
endpoint.redirectUri
- The redirect address used for obtaining authorization code.clientAssertion
- The client assertion to use for client authentication.resource
- Identifier of the target resource that is the recipient of the
requested token. It can be null if provided earlier to acquire
authorizationCode.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByAuthorizationCode(String authorizationCode, URI redirectUri, ClientCredential credential, AuthenticationCallback callback)
authorizationCode
- The authorization code received from service authorization
endpoint.redirectUri
- The redirect address used for obtaining authorization code.credential
- The client credential to use for token acquisition.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByAuthorizationCode(String authorizationCode, URI redirectUri, ClientCredential credential, String resource, AuthenticationCallback callback)
authorizationCode
- The authorization code received from service authorization
endpoint.redirectUri
- The redirect address used for obtaining authorization code.credential
- The client credential to use for token acquisition.resource
- Identifier of the target resource that is the recipient of the
requested token. It can be null if provided earlier to acquire
authorizationCode.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByAuthorizationCode(String authorizationCode, URI redirectUri, AsymmetricKeyCredential credential, AuthenticationCallback callback) throws AuthenticationException
authorizationCode
- The authorization code received from service authorization
endpoint.redirectUri
- The redirect address used for obtaining authorization code.credential
- object representing Private Key to use for token acquisition.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.AuthenticationException
- thrown if AsymmetricKeyCredential
fails to sign the
JWT token.public Future<AuthenticationResult> acquireTokenByAuthorizationCode(String authorizationCode, URI redirectUri, AsymmetricKeyCredential credential, String resource, AuthenticationCallback callback) throws AuthenticationException
authorizationCode
- The authorization code received from service authorization
endpoint.redirectUri
- The redirect address used for obtaining authorization code.credential
- object representing Private Key to use for token acquisition.resource
- Identifier of the target resource that is the recipient of the
requested token. It can be null if provided earlier to acquire
authorizationCode.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.AuthenticationException
- thrown if AsymmetricKeyCredential
fails to sign the
JWT token.public Future<DeviceCode> acquireDeviceCode(String clientId, String resource, AuthenticationCallback<DeviceCode> callback)
clientId
- Identifier of the client requesting the tokenresource
- Identifier of the target resource that is the recipient of the
requested token.callback
- optional callback object for non-blocking execution.Future
object representing the DeviceCode
of the call.
It contains device code, user code, its expiration date,
message which should be displayed to the user.AuthenticationException
- thrown if the device code is not acquired successfullypublic Future<AuthenticationResult> acquireTokenByDeviceCode(DeviceCode deviceCode, AuthenticationCallback callback) throws AuthenticationException
deviceCode
- The device code result received from calling acquireDeviceCode.callback
- optional callback object for non-blocking execution.Future
object representing the AuthenticationResult
of the call.
It contains AccessToken, Refresh Token and the Access Token's expiration time.AuthenticationException
- thrown if authorization is pending or another error occurred.
If the errorCode of the exception is AdalErrorCode.AUTHORIZATION_PENDING,
the call needs to be retried until the AccessToken is returned.
DeviceCode.interval - The minimum amount of time in seconds that the client
SHOULD wait between polling requests to the token endpoinpublic Future<AuthenticationResult> acquireTokenByRefreshToken(String refreshToken, String clientId, ClientAssertion clientAssertion, AuthenticationCallback callback)
refreshToken
- Refresh Token to use in the refresh flow.clientId
- Name or ID of the client requesting the token.clientAssertion
- The client assertion to use for client authentication.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByRefreshToken(String refreshToken, String clientId, ClientAssertion clientAssertion, String resource, AuthenticationCallback callback)
refreshToken
- Refresh Token to use in the refresh flow.clientId
- Name or ID of the client requesting the token.clientAssertion
- The client assertion to use for client authentication.resource
- Identifier of the target resource that is the recipient of the
requested token. If null, token is requested for the same
resource refresh token was originally issued for. If passed,
resource should match the original resource used to acquire
refresh token unless token service supports refresh token for
multiple resources.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByRefreshToken(String refreshToken, ClientCredential credential, AuthenticationCallback callback)
refreshToken
- Refresh Token to use in the refresh flow.credential
- The client credential used for token acquisition.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByRefreshToken(String refreshToken, ClientCredential credential, String resource, AuthenticationCallback callback)
refreshToken
- Refresh Token to use in the refresh flow.credential
- The client credential used for token acquisition.resource
- Identifier of the target resource that is the recipient of the
requested token. If null, token is requested for the same
resource refresh token was originally issued for. If passed,
resource should match the original resource used to acquire
refresh token unless token service supports refresh token for
multiple resources.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.public Future<AuthenticationResult> acquireTokenByRefreshToken(String refreshToken, AsymmetricKeyCredential credential, AuthenticationCallback callback) throws AuthenticationException
refreshToken
- Refresh Token to use in the refresh flow.credential
- object representing Private Key to use for token acquisition.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.AuthenticationException
- thrown if AsymmetricKeyCredential
fails to sign the
JWT token.public Future<AuthenticationResult> acquireTokenByRefreshToken(String refreshToken, AsymmetricKeyCredential credential, String resource, AuthenticationCallback callback) throws AuthenticationException
refreshToken
- Refresh Token to use in the refresh flow.credential
- object representing Private Key to use for token acquisition.resource
- Identifier of the target resource that is the recipient of the
requested token. If null, token is requested for the same
resource refresh token was originally issued for. If passed,
resource should match the original resource used to acquire
refresh token unless token service supports refresh token for
multiple resources.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.AuthenticationException
- thrown if AsymmetricKeyCredential
fails to sign the
JWT token.public Future<AuthenticationResult> acquireTokenByRefreshToken(String refreshToken, String clientId, AuthenticationCallback callback)
refreshToken
- Refresh Token to use in the refresh flow.clientId
- Name or ID of the client requesting the token.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.AuthenticationException
- thrown if the access token is not refreshed successfullypublic Future<AuthenticationResult> acquireTokenByRefreshToken(String refreshToken, String clientId, String resource, AuthenticationCallback callback)
refreshToken
- Refresh Token to use in the refresh flow.clientId
- Name or ID of the client requesting the token.resource
- Identifier of the target resource that is the recipient of the
requested token. If null, token is requested for the same
resource refresh token was originally issued for. If passed,
resource should match the original resource used to acquire
refresh token unless token service supports refresh token for
multiple resources.callback
- optional callback object for non-blocking execution.Future
object representing the
AuthenticationResult
of the call. It contains Access
Token, Refresh Token and the Access Token's expiration time.AuthenticationException
- thrown if the access token is not refreshed successfullypublic String getCorrelationId()
public void setCorrelationId(String correlationId)
correlationId
- String valuepublic boolean shouldValidateAuthority()
public String getAuthority()
Copyright © 2013–2019. All rights reserved.