Partager via


AbstractClientApplicationBase.Builder<T> Class

Type Parameters

T

public abstract static class AbstractClientApplicationBase.Builder
extends Builder<T>

Field Summary

Modifier and Type Field and Description
protected boolean isInstanceDiscoveryEnabled

Constructor Summary

Constructor Description
Builder(String clientId)

Constructor to create instance of Builder of client application

Method Summary

Modifier and Type Method and Description
T aadInstanceDiscoveryResponse(String val)

Sets instance discovery response data which will be used for determining tenant discovery endpoint and authority aliases.

T applicationName(String val)

Sets application name for telemetry purposes

T applicationVersion(String val)

Sets application version for telemetry purposes

T authority(String val)

Set URL of the authenticating authority or security token service (STS) from which MSAL will acquire security tokens.

T autoDetectRegion(boolean val)

Indicates that the library should attempt to discover the Azure region the application is running in when fetching the instance discovery metadata.

T azureRegion(String val)

Set the region that the library will use to format authorities in token requests.

T b2cAuthority(String val)

Set URL of the authenticating B2C authority from which MSAL will acquire tokens Valid B2C authorities should look like: https://<something.b2clogin.com// MSAL Java also supports a legacy B2C authority format, which looks like: https:///tfp// However, MSAL Java will eventually stop supporting the legacy format.

T clientCapabilities(Set<String> capabilities)
T connectTimeoutForDefaultHttpClient(Integer val)

Sets the connect timeout value used in HttpsURLConnection connections made by DefaultHttpClient, and is not needed if using a custom HTTP client

T correlationId(String val)

Set optional correlation id to be used by the API.

T executorService(ExecutorService val)

Sets ExecutorService to be used to execute the requests.

T httpClient(IHttpClient val)

Sets HTTP client to be used by the client application for all HTTP requests.

T instanceDiscovery(boolean val)

Historically, MSAL would connect to a central endpoint located at ``https://login.microsoftonline.com`` to acquire some metadata, especially when using an unfamiliar authority.

T logPii(boolean val)

Set logPii - boolean value, which determines whether Pii (personally identifiable information) will be logged in.

T oidcAuthority(String val)

Set a known authority corresponding to a generic OpenIdConnect Identity Provider.

T proxy(Proxy val)

Sets Proxy configuration to be used by the client application (MSAL4J by default uses javax.net.ssl.HttpsURLConnection) for all network communication.

T readTimeoutForDefaultHttpClient(Integer val)

Sets the read timeout value used in HttpsURLConnection connections made by DefaultHttpClient, and is not needed if using a custom HTTP client

T setTokenCacheAccessAspect(ITokenCacheAccessAspect val)

Sets ITokenCacheAccessAspect to be used for cache_data persistence.

T sslSocketFactory(SSLSocketFactory val)

Sets SSLSocketFactory to be used by the client application for all network communication.

T validateAuthority(boolean val)

Set a boolean value telling the application if the authority needs to be verified against a list of known authorities.

Methods inherited from Builder

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

isInstanceDiscoveryEnabled

protected boolean isInstanceDiscoveryEnabled

Constructor Details

Builder

public Builder(String clientId)

Constructor to create instance of Builder of client application

Parameters:

clientId - Client ID (Application ID) of the application as registered
             in the application registration portal (portal.azure.com)

Method Details

aadInstanceDiscoveryResponse

public T aadInstanceDiscoveryResponse(String val)

Sets instance discovery response data which will be used for determining tenant discovery endpoint and authority aliases.

Note that authority validation is not done even if AbstractClientApplicationBase#validateAuthority is set to true.

For more information, see https://aka.ms/msal4j-instance-discovery

Parameters:

val - JSON formatted value of response from AAD instance discovery endpoint

Returns:

instance of the Builder on which method was called

applicationName

public T applicationName(String val)

Sets application name for telemetry purposes

Parameters:

val - application name

Returns:

instance of the Builder on which method was called

applicationVersion

public T applicationVersion(String val)

Sets application version for telemetry purposes

Parameters:

val - application version

Returns:

instance of the Builder on which method was called

authority

public T authority(String val)

Set URL of the authenticating authority or security token service (STS) from which MSAL will acquire security tokens. The default value is AbstractClientApplicationBase#DEFAULT_AUTHORITY

Parameters:

val - a string value of authority

Returns:

instance of the Builder on which method was called

Throws:

java.net.MalformedURLException - if val is malformed URL

autoDetectRegion

public T autoDetectRegion(boolean val)

Indicates that the library should attempt to discover the Azure region the application is running in when fetching the instance discovery metadata. Regions can only be detected when running in an Azure environment, such as an Azure VM or other service, or if the environment has environment variable named REGION_NAME configured. Although you can enable both autodetection here and a specific region with AbstractClientApplicationBase#azureRegion at the same time, the region set with AbstractClientApplicationBase#azureRegion will take priority if there is a mismatch. See here for more information about supported scenarios: https://aka.ms/msal4j-azure-regions

Parameters:

val - boolean (default is false)

Returns:

instance of the Builder on which method was called

azureRegion

public T azureRegion(String val)

Set the region that the library will use to format authorities in token requests. If given a valid Azure region, the library will attempt to make token requests at a regional ESTS-R endpoint rather than the global ESTS endpoint. Regions must be valid Azure regions and their short names should be used, such as 'westus' for the West US Azure region, 'centralus' for the Central US Azure region, etc. Although you can set a specific region here and enable autodetection with AbstractClientApplicationBase#autoDetectRegion at the same time the specific region set here will take priority over the autodetected region if there is a mismatch. See here for more information about supported scenarios: https://aka.ms/msal4j-azure-regions

Parameters:

val - String region name

Returns:

instance of the Builder on which method was called

b2cAuthority

public T b2cAuthority(String val)

Set URL of the authenticating B2C authority from which MSAL will acquire tokens Valid B2C authorities should look like: https://<something.b2clogin.com// MSAL Java also supports a legacy B2C authority format, which looks like: https:///tfp// However, MSAL Java will eventually stop supporting the legacy format. See here for information on how to migrate to the new format: https://aka.ms/msal4j-b2c

Parameters:

val - a boolean value for validateAuthority

Returns:

instance of the Builder on which method was called

Throws:

java.net.MalformedURLException

clientCapabilities

public T clientCapabilities(Set capabilities)

Parameters:

capabilities

connectTimeoutForDefaultHttpClient

public T connectTimeoutForDefaultHttpClient(Integer val)

Sets the connect timeout value used in HttpsURLConnection connections made by DefaultHttpClient, and is not needed if using a custom HTTP client

Overrides:

AbstractClientApplicationBase.Builder<T>.connectTimeoutForDefaultHttpClient(Integer val)

Parameters:

val - timeout value in milliseconds

Returns:

instance of the Builder on which method was called

correlationId

public T correlationId(String val)

Set optional correlation id to be used by the API. If not provided, the API generates a random UUID.

Overrides:

AbstractClientApplicationBase.Builder<T>.correlationId(String val)

Parameters:

val - a string value of correlation id

Returns:

instance of the Builder on which method was called

executorService

public T executorService(ExecutorService val)

Sets ExecutorService to be used to execute the requests. Developer is responsible for maintaining the lifecycle of the ExecutorService.

Overrides:

AbstractClientApplicationBase.Builder<T>.executorService(ExecutorService val)

Parameters:

val - an instance of ExecutorService

Returns:

instance of the Builder on which method was called

httpClient

public T httpClient(IHttpClient val)

Sets HTTP client to be used by the client application for all HTTP requests. Allows for fine grained configuration of HTTP client.

Overrides:

AbstractClientApplicationBase.Builder<T>.httpClient(IHttpClient val)

Parameters:

val - Implementation of IHttpClient

Returns:

instance of the Builder on which method was called

instanceDiscovery

public T instanceDiscovery(boolean val)

Historically, MSAL would connect to a central endpoint located at ``https://login.microsoftonline.com`` to acquire some metadata, especially when using an unfamiliar authority. This behavior is known as Instance Discovery. This parameter defaults to true, which enables the Instance Discovery. If you do not know some authorities beforehand, yet still want MSAL to accept any authority that you will provide, you can use a ``False`` to unconditionally disable Instance Discovery.

Parameters:

val

logPii

public T logPii(boolean val)

Set logPii - boolean value, which determines whether Pii (personally identifiable information) will be logged in. The default value is false.

Overrides:

AbstractClientApplicationBase.Builder<T>.logPii(boolean val)

Parameters:

val - a boolean value for logPii

Returns:

instance of the Builder on which method was called

oidcAuthority

public T oidcAuthority(String val)

Set a known authority corresponding to a generic OpenIdConnect Identity Provider. MSAL will append ".well-known/openid-configuration" to the authority to retrieve the OIDC metadata and determine the endpoints.

Parameters:

val - a string value of authority

Returns:

instance of the Builder on which method was called

Throws:

java.net.MalformedURLException

proxy

public T proxy(Proxy val)

Sets Proxy configuration to be used by the client application (MSAL4J by default uses javax.net.ssl.HttpsURLConnection) for all network communication. If no proxy value is passed in, system defined properties are used. If HTTP client is set on the client application (via ClientApplication.builder().httpClient()), proxy configuration should be done on the HTTP client object being passed in, and not through this method.

Overrides:

AbstractClientApplicationBase.Builder<T>.proxy(Proxy val)

Parameters:

val - an instance of Proxy

Returns:

instance of the Builder on which method was called

readTimeoutForDefaultHttpClient

public T readTimeoutForDefaultHttpClient(Integer val)

Sets the read timeout value used in HttpsURLConnection connections made by DefaultHttpClient, and is not needed if using a custom HTTP client

Overrides:

AbstractClientApplicationBase.Builder<T>.readTimeoutForDefaultHttpClient(Integer val)

Parameters:

val - timeout value in milliseconds

Returns:

instance of the Builder on which method was called

setTokenCacheAccessAspect

public T setTokenCacheAccessAspect(ITokenCacheAccessAspect val)

Sets ITokenCacheAccessAspect to be used for cache_data persistence.

Parameters:

val - an instance of ITokenCacheAccessAspect

Returns:

instance of the Builder on which method was called

sslSocketFactory

public T sslSocketFactory(SSLSocketFactory val)

Sets SSLSocketFactory to be used by the client application for all network communication. If HTTP client is set on the client application (via ClientApplication.builder().httpClient()), any configuration of SSL should be done on the HTTP client and not through this method.

Overrides:

AbstractClientApplicationBase.Builder<T>.sslSocketFactory(SSLSocketFactory val)

Parameters:

val - an instance of SSLSocketFactory

Returns:

instance of the Builder on which method was called

validateAuthority

public T validateAuthority(boolean val)

Set a boolean value telling the application if the authority needs to be verified against a list of known authorities. Authority is only validated when: 1 - It is an Azure Active Directory authority (not B2C or ADFS) 2 - Instance discovery metadata is not set via AbstractClientApplicationBase#aadAadInstanceDiscoveryResponse

The default value is true.

Parameters:

val - a boolean value for validateAuthority

Returns:

instance of the Builder on which method was called

Applies to