public class ConfidentialClientApplication extends AbstractClientApplicationBase implements IConfidentialClientApplication
IConfidentialClientApplication
Conditionally thread-safe
| Modifier and Type | Class and Description |
|---|---|
static class |
ConfidentialClientApplication.Builder |
| Modifier and Type | Field and Description |
|---|---|
Function<AppTokenProviderParameters,CompletableFuture<TokenProviderResult>> |
appTokenProvider
AppTokenProvider creates a Credential from a function that provides access tokens.
|
static String |
DEFAULT_AUTHORITY |
azureRegionauthenticationAuthority, log, tokenCache| Modifier and Type | Method and Description |
|---|---|
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> |
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 |
authority()
Gets the authority URL for this application.
|
static ConfidentialClientApplication.Builder |
builder(String clientId,
IClientCredential clientCredential)
Creates instance of Builder of ConfidentialClientApplication
|
String |
clientId()
Gets the client ID (application ID) for this application.
|
String |
correlationId()
Gets the correlation ID used for tracing requests through the authentication system.
|
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.
|
IHttpClient |
httpClient()
Gets the HTTP client used by the application for all HTTP requests.
|
boolean |
logPii()
Gets whether personally identifiable information (PII) is included in log messages.
|
Proxy |
proxy()
Gets the proxy configuration used by the application for network communication.
|
CompletableFuture |
removeAccount(IAccount account)
Removes IAccount from the cache
|
boolean |
sendX5c() |
SSLSocketFactory |
sslSocketFactory()
Gets the SSL socket factory used by the application for secure network communication.
|
boolean |
validateAuthority()
Gets whether the authority URL should be validated against a list of known authorities.
|
aadAadInstanceDiscoveryResponse, acquireToken, acquireToken, acquireTokenSilently, applicationName, applicationVersion, authority, autoDetectRegion, azureRegion, clientCapabilities, clientId, getAccounts, getAuthorizationRequestUrl, instanceDiscovery, removeAccount, tokenCache, validateAuthorityconnectTimeoutForDefaultHttpClient, correlationId, httpClient, logPii, proxy, readTimeoutForDefaultHttpClient, sslSocketFactorypublic Function<AppTokenProviderParameters,CompletableFuture<TokenProviderResult>> appTokenProvider
public static final String DEFAULT_AUTHORITY
public CompletableFuture<IAuthenticationResult> acquireToken(ClientCredentialParameters parameters)
IConfidentialClientApplicationacquireToken in interface IConfidentialClientApplicationparameters - instance of ClientCredentialParametersCompletableFuture containing an IAuthenticationResultpublic CompletableFuture<IAuthenticationResult> acquireToken(OnBehalfOfParameters parameters)
IConfidentialClientApplicationUserAssertion 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 IConfidentialClientApplicationparameters - instance of OnBehalfOfParametersCompletableFuture containing an IAuthenticationResultpublic 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 IConfidentialClientApplicationpublic String clientId()
public String authority()
IApplicationBase.DEFAULT_AUTHORITYpublic boolean validateAuthority()
public URL getAuthorizationRequestUrl(AuthorizationRequestUrlParameters parameters)
Once the user successfully authenticates, the response should contain an authorization code,
which can then be passed in to AbstractClientApplicationBase.acquireToken(AuthorizationCodeParameters)
to be exchanged for a token.
parameters - AuthorizationRequestUrlParameters containing the details needed to create the authorization URL,
such as scopes, response type, and redirect URIpublic CompletableFuture<IAuthenticationResult> acquireToken(AuthorizationCodeParameters parameters)
This is typically used as the second step in an authorization code flow, after the user has authenticated and provided consent at the authorization endpoint, resulting in an authorization code.
parameters - AuthorizationCodeParameters containing the authorization code and other information
required to exchange the code for tokensCompletableFuture object representing the IAuthenticationResult of the call,
which contains the requested tokens and account informationpublic CompletableFuture<IAuthenticationResult> acquireToken(RefreshTokenParameters parameters)
parameters - RefreshTokenParametersCompletableFuture 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 boolean logPii()
public String correlationId()
public IHttpClient httpClient()
public Proxy proxy()
public SSLSocketFactory sslSocketFactory()
Copyright © 2013–2025. All rights reserved.