Class: CredentialProvider

Constructor

new CredentialProvider(username, password, domain)

Class used to provide credentials for Basic Authentication.

Parameters:
Name Type Argument Description
username string <optional>

Username to be used for authentication.

password string <optional>

Password to be used used for authentication.

domain string <optional>

Domain for this credential object.

Members

displayName :string

Guest display name

Type:
  • string

domain :string

Domain for this credential object.

Type:
  • string

isGuest :boolean

Flag to indicate whether this is a guest user.

Type:
  • boolean

password :string

Password to be used used for authentication.

Type:
  • string

username :string

Username to be used for authentication.

Type:
  • string

Methods

onAuthenticationChallenge(challenge, callback) → {void}

Function called after credentials were required.

Parameters:
Name Type Description
challenge Object

It is not used right now.

callback function

Function to be called after credentials are retrieved.

Inherited From:
Returns:
{ void }

Callbacks

addOnInvalidCredentialsCallback(callback) → {void}

Adds callback on invalidCredentialsProvided.

Parameters:
Name Type Description
callback AvayaClientServices.Config.CredentialProvider#onInvalidCredentialsProvided
Inherited From:
Returns:
{ void }

removeOnInvalidCredentialsCallback(callback) → {void}

Removes callback from invalidCredentialsProvided.

Parameters:
Name Type Description
callback AvayaClientServices.Config.AbstractCredentialProvider#onInvalidCredentialsProvided
Inherited From:
Returns:
{ void }

Type Definitions

onInvalidCredentialsProvided(invalidCredentialsEvent) → {void}

Interface for callback function to be invoked when provided credentials are invalid.

Examples

Using callback to retry authentication using existing credentials provider:

credentialProvider.addOnInvalidCredentialsCallback(function (event) {
    // When consumer application keeps a reference to the credential
    // provider used to configure services, update corresponding field
    // e. g. username, password or domain:
    handle.credentialProvider.password = 'secure';

    // Signal to try to re-establish the connection:
    event.retry(handle.credentialProvider); // Optional argument could
                                            // be omitted only when using
                                            // the same reference as in
                                            // the user configuration.
});

Using callback to retry authentication using new credential provider:

credentialProvider.addOnInvalidCredentialsCallback(function (event) {
    // When there is no reference to existing credentials provider,
    // create a new one first. It is allowed to switch to different
    // kind of the provider.
    const credentialProvider = new AvayaClientServices.Config.CredentialProvider(
        'janedoe',
        'secret',
        'company.com',
    );
    credentialProvider.isGuest = false;
    credentialProvider.displayName = 'Jane Doe';

    // It is advised to set up a similar callback when using a new instance:
    credentialProvider.onInvalidCredentialsProvided(function (event) {
        console.error(event.getFailureCount());
    });

    // Signal to save new credentials and try to re-establish the connection:
    event.retry(credentialProvider);
});

Using callback to cancel authentication:

credentialProvider.addOnInvalidCredentialsCallback(function (event) {
    event.cancel();
});
Parameters:
Name Type Description
invalidCredentialsEvent AvayaClientServices.Config.InvalidCredentialsEvent

Event containing retry and cancel methods, and failure count.

Returns:
{ void }
©2016 Avaya Inc. All Rights Reserved.