AppCredentials Class

  • java.lang.Object
    • com.microsoft.bot.connector.authentication.AppCredentials

Implements

public abstract class AppCredentials
implements ServiceClientCredentials

Base abstraction for AAD credentials for auth and caching.

Subclasses must provide the impl for #buildAuthenticator

Constructor Summary

Constructor Description
AppCredentials(String withChannelAuthTenant)

Initializes a new instance of the AppCredentials class.

AppCredentials(String withChannelAuthTenant, String withOAuthScope)

Initializes a new instance of the AppCredentials class.

Method Summary

Modifier and Type Method and Description
void applyCredentialsFilter(OkHttpClient.Builder clientBuilder)

Apply the credentials to the HTTP request.

protected abstract Authenticator buildAuthenticator()

Returns an appropriate Authenticator that is provided by a subclass.

java.lang.String getAppId()

Gets the App ID for this credential.

protected java.lang.String getAuthTenant()

Gets the channel auth token tenant for this credential.

java.lang.String getChannelAuthTenant()

Gets tenant to be used for channel authentication.

java.util.concurrent.CompletableFuture<java.lang.String> getToken()

Gets an OAuth access token.

java.lang.String oAuthEndpoint()

OAuth endpoint to use.

java.lang.String oAuthScope()

OAuth scope to use.

void setAppId(String withAppId)

Sets the Microsoft app ID for this credential.

protected void setAuthTenant(String withAuthTenant)

Sets the channel auth token tenant for this credential.

void setChannelAuthTenant(String withAuthTenant)

Sets tenant to be used for channel authentication.

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

Constructor Details

AppCredentials

public AppCredentials(String withChannelAuthTenant)

Initializes a new instance of the AppCredentials class.

Parameters:

withChannelAuthTenant - Optional. The oauth token tenant.

AppCredentials

public AppCredentials(String withChannelAuthTenant, String withOAuthScope)

Initializes a new instance of the AppCredentials class.

Parameters:

withChannelAuthTenant - Optional. The oauth token tenant.
withOAuthScope - The scope for the token.

Method Details

applyCredentialsFilter

public void applyCredentialsFilter(OkHttpClient.Builder clientBuilder)

Apply the credentials to the HTTP request.

Note: Provides the same functionality as dotnet ProcessHttpRequestAsync

Parameters:

clientBuilder - the builder for building up an OkHttpClient

buildAuthenticator

protected abstract Authenticator buildAuthenticator()

Returns an appropriate Authenticator that is provided by a subclass.

Returns:

An Authenticator object.

Throws:

java.net.MalformedURLException - If the endpoint isn't valid.

getAppId

public String getAppId()

Gets the App ID for this credential.

Returns:

The app id.

getAuthTenant

protected String getAuthTenant()

Gets the channel auth token tenant for this credential.

Returns:

The channel auth token tenant.

getChannelAuthTenant

public String getChannelAuthTenant()

Gets tenant to be used for channel authentication.

Returns:

Tenant to be used for channel authentication.

getToken

public CompletableFuture getToken()

Gets an OAuth access token.

Returns:

If the task is successful, the result contains the access token string.

oAuthEndpoint

public String oAuthEndpoint()

OAuth endpoint to use.

Returns:

The OAuth endpoint.

oAuthScope

public String oAuthScope()

OAuth scope to use.

Returns:

OAuth scope.

setAppId

public void setAppId(String withAppId)

Sets the Microsoft app ID for this credential.

Parameters:

withAppId - The app id.

setAuthTenant

protected void setAuthTenant(String withAuthTenant)

Sets the channel auth token tenant for this credential.

Parameters:

withAuthTenant - The auth token tenant.

setChannelAuthTenant

public void setChannelAuthTenant(String withAuthTenant)

Sets tenant to be used for channel authentication.

Parameters:

withAuthTenant - Tenant to be used for channel authentication.

Applies to