Skip to main content

Java

Installation

Gradle users

Add this dependency to your project's build file:

implementation 'com.authsignal:authsignal-java:0.1.3'

Maven users

Add this dependency to your project's POM:

<dependency>
<groupId>com.authsignal</groupId>
<artifactId>authsignal-java</artifactId>
<version>0.1.4</version>
</dependency>

Initialization

import com.authsignal.AuthsignalClient;
...

AuthsignalClient authsignalClient = new AuthsignalClient(secret, baseURL);

You can find your secret key in the Authsignal Portal.

You must specify the correct base URL for your tenant's region.

RegionBase URL
US (Oregon)https://api.authsignal.com/v1
AU (Sydney)https://au.api.authsignal.com/v1
EU (Dublin)https://eu.api.authsignal.com/v1

track

track lets you track actions performed by users and obtain a URL to perform challenges via the pre-built UI.

TrackRequest request = new TrackRequest();
request.userId = userId;
request.action = action;

CompletableFuture<TrackResponse> response = authsignalClient.track(request);

Arguments

Refer to the Server API's Track action request object.

Returns

Refer to the Server API's Track action response object.

validateChallenge

validateChallenge lets you validate the result of a challenge using the token which is obtained after a redirect (if using the pre-built UI) or returned by a client SDK (if using an embedded flow).

ValidateChallengeRequest request = new ValidateChallengeRequest();
request.token = token;

CompletableFuture<ValidateChallengeResponse> response = authsignalClient.validateChallenge(request);
caution

When performing MFA for a user who has already been authenticated by a primary factor (e.g. username & password), it's important to check the token belongs to that user. The validateChallenge method will do this check if you pass both the token and the userId.

Arguments

NameTypeDescription
tokenStringThe token obtained after a redirect (if using the pre-built UI) or returned by a client SDK (if using an embedded flow).
userIdString(Optional) The ID of the user. Only pass this if doing step-up auth on an existing user session (i.e. not for login).

Returns

NameTypeDescription
successBooleanTrue if the challenge was completed successfully.
stateUserActionStateThe state of the action associated with the challenge. Possible enum values are CHALLENGE_REQUIRED, CHALLENGE_SUCCEEDED, CHALLENGE_FAILED, ALLOW, or BLOCK.
userIdStringThe ID of the user.

getUser

getUser retrieves a user and their enrollment status.

UserRequest request = new UserRequest();
request.userId = userId;

CompletableFuture<UserResponse> response = authsignalClient.getUser(request);

Arguments

Refer to the Server API's Retrieve user request object.

Returns

Refer to the Server API's Retrieve user response object.

getAction

getAction lets you determine the result of a challenge after the user has been redirected back from the Authsignal pre-built UI (or after the popup has been closed, if showing the page in a modal).

ActionRequest request = new ActionRequest();
request.userId = userId;
request.action = action;
request.idempotencyKey = idempotencyKey;

CompletableFuture<ActionResponse> response = authsignalClient.getAction(request);

Arguments

Refer to the Server API's Get action status request object.

Returns

Refer to the Server API's Get action status response object.

enrollVerifiedAuthenticator

enrollVerifiedAuthenticator can be used to enroll an authenticator on behalf of a user if it has already been verified.

EnrollVerifiedAuthenticatorRequest request = new EnrollVerifiedAuthenticatorRequest();
request.userId = userId;
request.phoneNumber = phoneNumber;
request.oobChannel = OobChannel.SMS;

CompletableFuture<EnrollVerifiedAuthenticatorResponse> response = authsignalClient.enrollVerifiedAuthenticator(request);

Arguments

Refer to the Server API's Enroll verified authenticator request object.

Returns

Refer to the Server API's Enroll verified authenticator response object.