AuthenticationService

class AuthenticationService : WebcomAbstractService

The Webcom service that makes it possible to authenticate users and manage identities (or authentication means) of users on a Webcom application.

Instances of AuthenticationService must be built using the WebcomApplication.authenticationService property.

The first step consists in choosing an AuthenticationMethod using one of the available getXXXMethod methods. Each subclass of AuthenticationMethod provides at least an authenticate method, and possibly additional methods to prepare the authentication call-flow (e.g. sending a One-Time Password to the user) or manage user identities (e.g. adding and validating a new email address).

Only one user may be authenticated at a time. If two authentication call-flows are run simultaneously, one of them will be rejected.

When a user is authenticated, it overwrites the already authenticated user if any.

In order to perform a multi-factor authentication, a user must already be authenticated and Context.Current must be passed to the authenticate method of the AuthenticationMethod associated with the additional factor. The resulting authentication factors may then be retrieved using the AuthenticationDetails.previousFactors property.

Types

Context
Link copied to clipboard
enum Context : Enum<AuthenticationService.Context>

Represents an authentication context.

Functions

cancelAllSubscriptions
Link copied to clipboard
fun cancelAllSubscriptions()

Cancels all subscriptions previously set using the subscribe method.

destroyAccount
Link copied to clipboard
fun destroyAccount(callback: WebcomDoneCallback? = null)

Removes the account of the currently authenticated user from the Webcom Authentication service. This operation is asynchronous and calls the given callback once performed.

detachIdentity
Link copied to clipboard
fun detachIdentity(callback: WebcomDoneCallback? = null)

Removes the last identity (or authentication means) of the currently authenticated user from the Webcom Authentication service. This operation is asynchronous and calls the given callback once performed.

getCustomMethod
Link copied to clipboard
fun getCustomMethod(provider: String): CustomMethod

Creates an instance of CustomMethod to authenticate users based on a given external ad-hoc (custom) identity provider.

getGuestMethod
Link copied to clipboard
fun getGuestMethod(): GuestMethod

Creates an instance of GuestMethod to manage guest users.

getOAuth2Method
Link copied to clipboard
fun getOAuth2Method(provider: OAuth2Method.Provider, context: Context, options: OAuth2Method.Options = OAuth2Method.Options()): OAuth2Method

Creates an instance of OAuth2Method to perform an OAuth2 authentication with a given provider from a given Android context (typically the Activity from which the authentication call-flow is to be started), using given options.

getOneTimePasswordMethod
Link copied to clipboard

Creates an instance of OneTimePasswordMethod to manage users with a given identity provider that authenticates users based on a given user identifier (email or MSISDN) and a generated one-time password sent to the user.

getOrangeMobileNetworkMethod
Link copied to clipboard
fun getOrangeMobileNetworkMethod(mcc: String? = null): OrangeMobileNetworkMethod

Creates an instance of OrangeMobileNetworkMethod to authenticate users based on their Orange mobile data network (works only for Orange customers).

getPersonalPasswordMethod
Link copied to clipboard

Creates an instance of PersonalPasswordMethod to manage users with a given identity provider that authenticates users based on a given identifier (email or MSISDN) and a personal password.

subscribe
Link copied to clipboard
fun subscribe(callback: AuthenticationCallback): Subscription

Subscribes to the authentication state maintained by this AuthenticationService instance and notifies the given callback function each time it changes or an authentication operation fails.

unauthenticate
Link copied to clipboard
fun unauthenticate(callback: WebcomDoneCallback? = null)

Unauthenticates the currently authenticated user. This operation is asynchronous and calls the given callback once performed.

Properties

currentAuthentication
Link copied to clipboard
var currentAuthentication: AuthenticationState

Gives the AuthenticationDetails of the currently authenticated user or null if no user is currently authenticated.