Delen via


CredentialBuilderBase<T> Class

  • java.lang.Object
    • com.azure.identity.CredentialBuilderBase<T>

Type Parameters

T

the type of the credential builder

Implements

public abstract class CredentialBuilderBase
implements HttpTrait<T>

The base class for all the credential builders.

Method Summary

Modifier and Type Method and Description
T addPolicy(HttpPipelinePolicy policy)

Adds a HttpPipelinePolicy to apply on each request sent.

T clientOptions(ClientOptions clientOptions)

Allows for setting common properties such as application ID, headers, proxy configuration, etc.

T configuration(Configuration configuration)

Sets the configuration store that is used during construction of the credential.

T enableAccountIdentifierLogging()

Enables account identifiers to be logged on client side for debugging/monitoring purposes.

T httpClient(HttpClient client)

Sets the HTTP client to use for sending and receiving requests to and from the service.

T httpLogOptions(HttpLogOptions logOptions)

Sets the HttpLogOptions to use when sending and receiving requests to and from the service.

T httpPipeline(HttpPipeline httpPipeline)

Deprecated

This method is deprecated. Use pipeline(HttpPipeline pipeline) instead

Specifies the HttpPipeline to send all requests.

T maxRetry(int maxRetry)

Specifies the max number of retries when an authentication request fails.

T pipeline(HttpPipeline pipeline)

Sets the HttpPipeline to use for the service client.

T proxyOptions(ProxyOptions proxyOptions)

Deprecated

Configure the proxy options on the HttpClient instead and then set that client on the credential using httpClient(HttpClient client).

Specifies the options for proxy configuration.

T retryOptions(RetryOptions retryOptions)

Sets the RetryOptions for all the requests made through the client.

T retryPolicy(RetryPolicy retryPolicy)

Sets the RetryPolicy that is used when each request is sent.

T retryTimeout(Function<Duration,Duration> retryTimeout)

Specifies a Function to calculate seconds of timeout on every retried request.

Methods inherited from java.lang.Object

Method Details

addPolicy

public T addPolicy(HttpPipelinePolicy policy)

Adds a HttpPipelinePolicy to apply on each request sent.

Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

Parameters:

policy - A HttpPipelinePolicy.

Returns:

An updated instance of this builder with the policy configured.

clientOptions

public T clientOptions(ClientOptions clientOptions)

Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is recommended that this method be called with an instance of the HttpClientOptions class (a subclass of the ClientOptions base class). The HttpClientOptions subclass provides more configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait interface.

Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

Parameters:

clientOptions - A configured instance of HttpClientOptions.

Returns:

An updated instance of this builder with the client options configured.

configuration

public T configuration(Configuration configuration)

Sets the configuration store that is used during construction of the credential. The default configuration store is a clone of the global configuration store.

Parameters:

configuration - The configuration store used to load Env variables and/or properties from.

Returns:

An updated instance of this builder with the configuration store set as specified.

enableAccountIdentifierLogging

public T enableAccountIdentifierLogging()

Enables account identifiers to be logged on client side for debugging/monitoring purposes. By default, it is disabled.

The Account Identifier logs can contain sensitive information and should be enabled on protected machines only. Enabling this logs Application ID, Object ID, Tenant ID and User Principal Name at INFO level when an access token is successfully retrieved. Ensure that INFO level logs are enabled to see the account identifier logs.

Returns:

An updated instance of this builder.

httpClient

public T httpClient(HttpClient client)

Sets the HTTP client to use for sending and receiving requests to and from the service.

Parameters:

client - The HTTP client to use for requests.

Returns:

An updated instance of this builder with the http client set as specified.

httpLogOptions

public T httpLogOptions(HttpLogOptions logOptions)

Sets the HttpLogOptions to use when sending and receiving requests to and from the service. If a logLevel is not provided, default value of HttpLogDetailLevel#NONE is set.

Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

Parameters:

logOptions - The HttpLogOptions to use when sending and receiving requests to and from the service.

Returns:

An updated instance of this builder with the Http log options configured.

httpPipeline

@Deprecated
public T httpPipeline(HttpPipeline httpPipeline)

Deprecated

This method is deprecated. Use pipeline(HttpPipeline pipeline) instead

Specifies the HttpPipeline to send all requests. This setting overrides the others.

Parameters:

httpPipeline - the HttpPipeline to send all requests

Returns:

An updated instance of this builder with the http pipeline set as specified.

maxRetry

public T maxRetry(int maxRetry)

Specifies the max number of retries when an authentication request fails.

Parameters:

maxRetry - the number of retries

Returns:

An updated instance of this builder with the max retry set as specified.

pipeline

public T pipeline(HttpPipeline pipeline)

Sets the HttpPipeline to use for the service client.

Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

Parameters:

pipeline - HttpPipeline to use for sending service requests and receiving responses.

Returns:

An updated instance of this builder with the http pipeline set as specified.

proxyOptions

@Deprecated
public T proxyOptions(ProxyOptions proxyOptions)

Deprecated

Configure the proxy options on the HttpClient instead and then set that client on the credential using httpClient(HttpClient client).

Specifies the options for proxy configuration.

Parameters:

proxyOptions - the options for proxy configuration

Returns:

An updated instance of this builder with the proxy options set as specified.

retryOptions

public T retryOptions(RetryOptions retryOptions)

Sets the RetryOptions for all the requests made through the client.

Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

Setting this is mutually exclusive with using retryPolicy(RetryPolicy retryPolicy).

Parameters:

retryOptions - The RetryOptions to use for all the requests made through the client.

Returns:

An updated instance of this builder with the retry options configured.

retryPolicy

public T retryPolicy(RetryPolicy retryPolicy)

Sets the RetryPolicy that is used when each request is sent. Setting this is mutually exclusive with using retryOptions(RetryOptions retryOptions). The default retry policy will be used in the pipeline, if not provided.

Parameters:

retryPolicy - user's retry policy applied to each request.

Returns:

An updated instance of this builder with the retry policy configured.

retryTimeout

public T retryTimeout(Function retryTimeout)

Specifies a Function to calculate seconds of timeout on every retried request.

Parameters:

retryTimeout - the Function that returns a timeout in seconds given the number of retry

Returns:

An updated instance of this builder with the retry timeout set as specified.

Applies to