Class RegistrationService
-
- All Implemented Interfaces:
-
org.signal.libsignal.internal.NativeHandleGuard.Owner
public class RegistrationService extends NativeHandleGuard.SimpleOwner
A client for the the registration service.
An instance of this class is tied to a single session ID that will be used for all requests. To obtain a {@RegistrationService}, use createSession or resumeSession to begin a new, or continue with an old session respectively.
CompletableFutures returned by methods on this class can complete exceptionally with any of the following exception types, in addition to any listed in the per-method documentation:
- RegistrationSessionNotFoundException if the server rejects the session ID,
- ChatServiceException if a request times out after being sent to the server,
- RetryLaterException if the server responds with an HTTP 429,
- RegistrationSessionIdInvalidException if the session ID is invalid,
- RegistrationException for other unexpected error responses
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classRegistrationService.CreateSessionValues passed to the server by createSession.
public enumRegistrationService.VerificationTransportpublic enumRegistrationService.Svr2CredentialsResultpublic classRegistrationService.AccountAttributesAccount attributes sent as part of a registerAccount request.
-
Method Summary
Modifier and Type Method Description static CompletableFuture<RegistrationService>createSession(Network network, RegistrationService.CreateSession createSession)Start a new registration session. static CompletableFuture<RegistrationService>resumeSession(Network network, String sessionId, String number)Resume an existing registration session. CompletableFuture<Void>requestPushChallenge(String fcmPushToken)Request a push challenge sent to the provided FCM token. CompletableFuture<Void>submitPushChallenge(String pushChallenge)Submit the result of a push challenge. CompletableFuture<Void>requestVerificationCode(RegistrationService.VerificationTransport transport, String client, Locale locale)Request that a verification code be sent via the given transport method. CompletableFuture<Void>submitVerificationCode(String code)Submit a received verification code. CompletableFuture<Void>submitCaptcha(String captchaValue)Submit the result of a completed captcha challenge. CompletableFuture<Map<String, RegistrationService.Svr2CredentialsResult>>checkSvr2Credentials(Array<String> svrTokens)Check that the given list of SVR credentials is valid. StringgetSessionId()Get the ID for this registration validation session. RegistrationSessionStategetSessionState()Get the session state received from the server with the last completed validation request. CompletableFuture<RegisterAccountResponse>registerAccount(String accountPassword, boolean skipDeviceTransfer, RegistrationService.AccountAttributes accountAttributes, String gcmPushToken, ECPublicKey aciPublicKey, ECPublicKey pniPublicKey, SignedPublicPreKey<ECPublicKey> aciSignedPreKey, SignedPublicPreKey<ECPublicKey> pniSignedPreKey, SignedPublicPreKey<KEMPublicKey> aciPqLastResortPreKey, SignedPublicPreKey<KEMPublicKey> pniPqLastResortPreKey)Send a register account request. static CompletableFuture<RegisterAccountResponse>reregisterAccount(Network network, String number, String accountPassword, boolean skipDeviceTransfer, RegistrationService.AccountAttributes accountAttributes, String gcmPushToken, ECPublicKey aciPublicKey, ECPublicKey pniPublicKey, SignedPublicPreKey<ECPublicKey> aciSignedPreKey, SignedPublicPreKey<ECPublicKey> pniSignedPreKey, SignedPublicPreKey<KEMPublicKey> aciPqLastResortPreKey, SignedPublicPreKey<KEMPublicKey> pniPqLastResortPreKey)Send a request to re-register an account. -
Methods inherited from class org.signal.libsignal.internal.NativeHandleGuard.SimpleOwner
unsafeNativeHandleWithoutGuard -
Methods inherited from class org.signal.libsignal.internal.NativeHandleGuard.Owner
guard, guardedMap, guardedMapChecked, guardedRun, guardedRunChecked -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
createSession
static CompletableFuture<RegistrationService> createSession(Network network, RegistrationService.CreateSession createSession)
Start a new registration session.
Returns a
CompletableFuturethat, on success, completes with an instance of this class bound to the created session.On failure, the future completes exceptionally.
With the websocket transport, this makes a POST request to
/v1/verification/session.
-
resumeSession
static CompletableFuture<RegistrationService> resumeSession(Network network, String sessionId, String number)
Resume an existing registration session.
Returns a
CompletableFuturethat, on success, completes with an instance of this class bound to the resumed session.On failure, the future completes exceptionally.
With the websocket transport, this makes a GET request to
/v1/verification/session/{sessionId}.
-
requestPushChallenge
CompletableFuture<Void> requestPushChallenge(String fcmPushToken)
Request a push challenge sent to the provided FCM token.
The returned future resolves with
nullif the request is successful.On failure, the future completes exceptionally.
With the websocket transport, this makes a PATCH request to
/v1/verification/session/{sessionId}.
-
submitPushChallenge
CompletableFuture<Void> submitPushChallenge(String pushChallenge)
Submit the result of a push challenge.
The returned future resolves with
nullif the request is successful.On failure, the future completes exceptionally.
With the websocket transport, this makes a PATCH request to
/v1/verification/session/{sessionId}.
-
requestVerificationCode
CompletableFuture<Void> requestVerificationCode(RegistrationService.VerificationTransport transport, String client, Locale locale)
Request that a verification code be sent via the given transport method.
The returned future resolves with
nullif the request is successful.On failure, the future completes exceptionally with
- RegistrationSessionNotReadyException
- RegistrationSessionSendCodeException
- RegistrationCodeNotDeliverableException
With the websocket transport, this makes a POST request to
/v1/verification/session/{sessionId}/code.
-
submitVerificationCode
CompletableFuture<Void> submitVerificationCode(String code)
Submit a received verification code.
The returned future resolves with
nullif the request is successful.On failure, the future completes exceptionally with
in addition to the list of common exception types.With the websocket transport, this makes a PUT request to
/v1/verification/session/{sessionId}/code.
-
submitCaptcha
CompletableFuture<Void> submitCaptcha(String captchaValue)
Submit the result of a completed captcha challenge.
The returned future resolves with
nullif the request is successful.On failure, the future completes exceptionally.
With the websocket transport, this makes a PATCH request to
/v1/verification/session/{sessionId}.
-
checkSvr2Credentials
CompletableFuture<Map<String, RegistrationService.Svr2CredentialsResult>> checkSvr2Credentials(Array<String> svrTokens)
Check that the given list of SVR credentials is valid.
If the request succeeds, the returned future resolves with a map of submitted credential to check result.
On failure, the future completes exceptionally.
With the websocket transport, this makes a POST request to
/v2/backup/auth/check.
-
getSessionId
String getSessionId()
Get the ID for this registration validation session.
-
getSessionState
RegistrationSessionState getSessionState()
Get the session state received from the server with the last completed validation request.
-
registerAccount
CompletableFuture<RegisterAccountResponse> registerAccount(String accountPassword, boolean skipDeviceTransfer, RegistrationService.AccountAttributes accountAttributes, String gcmPushToken, ECPublicKey aciPublicKey, ECPublicKey pniPublicKey, SignedPublicPreKey<ECPublicKey> aciSignedPreKey, SignedPublicPreKey<ECPublicKey> pniSignedPreKey, SignedPublicPreKey<KEMPublicKey> aciPqLastResortPreKey, SignedPublicPreKey<KEMPublicKey> pniPqLastResortPreKey)
Send a register account request.
The returned future resolves to a RegisterAccountResponse if the request is successful. If not, the future resolves with
in addition to the list of common exception types.With the websocket transport, this makes a POST request to
/v1/registration.
-
reregisterAccount
static CompletableFuture<RegisterAccountResponse> reregisterAccount(Network network, String number, String accountPassword, boolean skipDeviceTransfer, RegistrationService.AccountAttributes accountAttributes, String gcmPushToken, ECPublicKey aciPublicKey, ECPublicKey pniPublicKey, SignedPublicPreKey<ECPublicKey> aciSignedPreKey, SignedPublicPreKey<ECPublicKey> pniSignedPreKey, SignedPublicPreKey<KEMPublicKey> aciPqLastResortPreKey, SignedPublicPreKey<KEMPublicKey> pniPqLastResortPreKey)
Send a request to re-register an account.
This is a static method since it uses the recovery password to authenticate instead of a verification session. The returned future resolves to a RegisterAccountResponse if the request is successful. If not, the future resolves with
in addition to the list of common exception types.With the websocket transport, this makes a POST request to
/v1/registration.
-
-
-
-