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 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 setTokenCacheAccessAspect(ITokenCacheAccessAspect val)

Sets ITokenCacheAccessAspect to be used for cache_data persistence.

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

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

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

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