public class ConfidentialClientApplication extends Object implements IConfidentialClientApplication
IConfidentialClientApplication
Conditionally thread-safe
Modifier and Type | Class and Description |
---|---|
static class |
ConfidentialClientApplication.Builder |
Modifier and Type | Field and Description |
---|---|
protected com.microsoft.aad.msal4j.Authority |
authenticationAuthority |
static String |
DEFAULT_AUTHORITY |
protected org.slf4j.Logger |
log |
protected TokenCache |
tokenCache |
Modifier and Type | Method and Description |
---|---|
com.microsoft.aad.msal4j.AadInstanceDiscoveryResponse |
aadAadInstanceDiscoveryResponse() |
CompletableFuture<IAuthenticationResult> |
acquireToken(AuthorizationCodeParameters parameters)
Acquires security token from the authority using an authorization code previously received.
|
CompletableFuture<IAuthenticationResult> |
acquireToken(AuthorizationCodeParameters parameters)
Acquires security token from the authority using an authorization code previously received.
|
CompletableFuture<IAuthenticationResult> |
acquireToken(ClientCredentialParameters parameters)
Acquires tokens from the authority configured in the application, for the confidential client
itself.
|
CompletableFuture<IAuthenticationResult> |
acquireToken(OnBehalfOfParameters parameters)
Acquires an access token for this application (usually a Web API) from the authority configured
in the application, in order to access another downstream protected Web API on behalf of a user
using the On-Behalf-Of flow.
|
CompletableFuture<IAuthenticationResult> |
acquireToken(RefreshTokenParameters parameters)
Acquires a security token from the authority using a refresh token previously received.
|
CompletableFuture<IAuthenticationResult> |
acquireToken(RefreshTokenParameters parameters)
Acquires a security token from the authority using a refresh token previously received.
|
CompletableFuture<IAuthenticationResult> |
acquireTokenSilently(SilentParameters parameters)
Returns tokens from cache if present and not expired or acquires new tokens from the authority
by using the refresh token present in cache.
|
CompletableFuture<IAuthenticationResult> |
acquireTokenSilently(SilentParameters parameters)
Returns tokens from cache if present and not expired or acquires new tokens from the authority
by using the refresh token present in cache.
|
String |
applicationName() |
String |
applicationVersion() |
String |
authority() |
String |
authority() |
boolean |
autoDetectRegion() |
String |
azureRegion() |
static ConfidentialClientApplication.Builder |
builder(String clientId,
IClientCredential clientCredential)
Creates instance of Builder of ConfidentialClientApplication
|
protected com.nimbusds.oauth2.sdk.auth.ClientAuthentication |
clientAuthentication() |
String |
clientCapabilities() |
String |
clientId() |
String |
clientId() |
Integer |
connectTimeoutForDefaultHttpClient() |
String |
correlationId() |
String |
correlationId() |
protected static String |
enforceTrailingSlash(String authority) |
CompletableFuture<Set<IAccount>> |
getAccounts()
Returns accounts in the cache
|
CompletableFuture<Set<IAccount>> |
getAccounts()
Returns accounts in the cache
|
URL |
getAuthorizationRequestUrl(AuthorizationRequestUrlParameters parameters)
Computes the URL of the authorization request letting the user sign-in and consent to the
application.
|
URL |
getAuthorizationRequestUrl(AuthorizationRequestUrlParameters parameters)
Computes the URL of the authorization request letting the user sign-in and consent to the
application.
|
boolean |
logPii() |
boolean |
logPii() |
Proxy |
proxy() |
Proxy |
proxy() |
Integer |
readTimeoutForDefaultHttpClient() |
CompletableFuture |
removeAccount(IAccount account)
Removes IAccount from the cache
|
CompletableFuture<Void> |
removeAccount(IAccount account)
Removes IAccount from the cache
|
boolean |
sendX5c() |
SSLSocketFactory |
sslSocketFactory() |
SSLSocketFactory |
sslSocketFactory() |
ITokenCache |
tokenCache() |
TokenCache |
tokenCache() |
boolean |
validateAuthority() |
boolean |
validateAuthority() |
public static final String DEFAULT_AUTHORITY
protected org.slf4j.Logger log
protected com.microsoft.aad.msal4j.Authority authenticationAuthority
protected TokenCache tokenCache
public CompletableFuture<IAuthenticationResult> acquireToken(ClientCredentialParameters parameters)
IConfidentialClientApplication
acquireToken
in interface IConfidentialClientApplication
parameters
- instance of ClientCredentialParameters
CompletableFuture
containing an IAuthenticationResult
public CompletableFuture<IAuthenticationResult> acquireToken(OnBehalfOfParameters parameters)
IConfidentialClientApplication
UserAssertion
field of OnBehalfOfParameters
.
When serializing/deserializing the in-memory token cache to permanent storage, there should be
a token cache per incoming access token, where the hash of the incoming access token can be used
as the token cache key. Access tokens are usually only valid for a 1 hour period of time,
and a new access token in the UserAssertion
means there will be a new token cache and
new token cache key. To avoid your permanent storage from being filled with expired
token caches, an eviction policy should be set. For example, a token cache that
is more than a couple of hours old can be deemed expired and therefore evicted from the
serialized token cache.acquireToken
in interface IConfidentialClientApplication
parameters
- instance of OnBehalfOfParameters
CompletableFuture
containing an IAuthenticationResult
protected com.nimbusds.oauth2.sdk.auth.ClientAuthentication clientAuthentication()
public static ConfidentialClientApplication.Builder builder(String clientId, IClientCredential clientCredential)
clientId
- Client ID (Application ID) of the application as registered
in the application registration portal (portal.azure.com)clientCredential
- The client credential to use for token acquisition.public boolean sendX5c()
sendX5c
in interface IConfidentialClientApplication
public String clientId()
public String authority()
IClientApplicationBase.DEFAULT_AUTHORITY
public boolean validateAuthority()
public String correlationId()
public boolean logPii()
public Proxy proxy()
public SSLSocketFactory sslSocketFactory()
public ITokenCache tokenCache()
IClientApplicationBase.acquireTokenSilently(SilentParameters)
public URL getAuthorizationRequestUrl(AuthorizationRequestUrlParameters parameters)
AbstractClientApplicationBase.acquireToken(AuthorizationCodeParameters)
to be exchanged for a tokenparameters
- AuthorizationRequestUrlParameters
public CompletableFuture<IAuthenticationResult> acquireToken(AuthorizationCodeParameters parameters)
parameters
- AuthorizationCodeParameters
CompletableFuture
object representing the IAuthenticationResult
of the call.public CompletableFuture<IAuthenticationResult> acquireToken(RefreshTokenParameters parameters)
parameters
- RefreshTokenParameters
CompletableFuture
object representing the IAuthenticationResult
of the call.public CompletableFuture<IAuthenticationResult> acquireTokenSilently(SilentParameters parameters) throws MalformedURLException
parameters
- instance of SilentParametersCompletableFuture
object representing the IAuthenticationResult
of the call.MalformedURLException
- if authorityUrl from parameters is malformed URLpublic CompletableFuture<Set<IAccount>> getAccounts()
public CompletableFuture removeAccount(IAccount account)
account
- instance of Account to be removed from cacheCompletableFuture
object representing account removal task.public CompletableFuture<IAuthenticationResult> acquireToken(AuthorizationCodeParameters parameters)
parameters
- AuthorizationCodeParameters
CompletableFuture
object representing the IAuthenticationResult
of the call.public CompletableFuture<IAuthenticationResult> acquireToken(RefreshTokenParameters parameters)
parameters
- RefreshTokenParameters
CompletableFuture
object representing the IAuthenticationResult
of the call.public CompletableFuture<IAuthenticationResult> acquireTokenSilently(SilentParameters parameters) throws MalformedURLException
parameters
- instance of SilentParametersCompletableFuture
object representing the IAuthenticationResult
of the call.MalformedURLException
- if authorityUrl from parameters is malformed URLpublic CompletableFuture<Set<IAccount>> getAccounts()
public CompletableFuture<Void> removeAccount(IAccount account)
account
- instance of Account to be removed from cacheCompletableFuture
object representing account removal task.public URL getAuthorizationRequestUrl(AuthorizationRequestUrlParameters parameters)
AbstractClientApplicationBase.acquireToken(AuthorizationCodeParameters)
to be exchanged for a tokenparameters
- AuthorizationRequestUrlParameters
public String clientId()
public String authority()
IClientApplicationBase.DEFAULT_AUTHORITY
public boolean validateAuthority()
public String correlationId()
public boolean logPii()
public Proxy proxy()
public SSLSocketFactory sslSocketFactory()
public Integer connectTimeoutForDefaultHttpClient()
public Integer readTimeoutForDefaultHttpClient()
public TokenCache tokenCache()
IClientApplicationBase.acquireTokenSilently(SilentParameters)
public String applicationName()
public String applicationVersion()
public com.microsoft.aad.msal4j.AadInstanceDiscoveryResponse aadAadInstanceDiscoveryResponse()
public String clientCapabilities()
public boolean autoDetectRegion()
public String azureRegion()
Copyright © 2013–2021. All rights reserved.