Java Code Examples for org.whispersystems.signalservice.api.SignalServiceAccountManager#NewDeviceRegistrationReturn
The following examples show how to use
org.whispersystems.signalservice.api.SignalServiceAccountManager#NewDeviceRegistrationReturn .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Manager.java From signald with GNU General Public License v3.0 | 6 votes |
public void finishDeviceLink(String deviceName) throws IOException, InvalidKeyException, TimeoutException, UserAlreadyExists { accountData.signalingKey = Util.getSecret(52); SignalServiceAccountManager.NewDeviceRegistrationReturn ret = accountManager.finishNewDeviceRegistration(accountData.axolotlStore.identityKeyStore.getIdentityKeyPair(), accountData.signalingKey, false, true, accountData.axolotlStore.identityKeyStore.getLocalRegistrationId(), deviceName); accountData.deviceId = ret.getDeviceId(); accountData.username = ret.getNumber(); // TODO do this check before actually registering if (userExists()) { throw new UserAlreadyExists(accountData.username, getFileName()); } accountData.axolotlStore = new SignalProtocolStore(ret.getIdentity(), accountData.axolotlStore.identityKeyStore.getLocalRegistrationId()); accountData.registered = true; refreshPreKeys(); accountData.init(); requestSyncGroups(); requestSyncContacts(); accountData.save(); managers.put(accountData.username, this); logger.info("Successfully finished linked to " + Util.redact(accountData.username) + " as device #" + accountData.deviceId); }
Example 2
Source File: ProvisioningManager.java From signal-cli with GNU General Public License v3.0 | 4 votes |
public String finishDeviceLink(String deviceName) throws IOException, InvalidKeyException, TimeoutException, UserAlreadyExists { String signalingKey = KeyUtils.createSignalingKey(); SignalServiceAccountManager.NewDeviceRegistrationReturn ret = accountManager.finishNewDeviceRegistration(identityKey, signalingKey, false, true, registrationId, deviceName); String username = ret.getNumber(); // TODO do this check before actually registering if (SignalAccount.userExists(pathConfig.getDataPath(), username)) { throw new UserAlreadyExists(username, SignalAccount.getFileName(pathConfig.getDataPath(), username)); } // Create new account with the synced identity byte[] profileKeyBytes = ret.getProfileKey(); ProfileKey profileKey; if (profileKeyBytes == null) { profileKey = KeyUtils.createProfileKey(); } else { try { profileKey = new ProfileKey(profileKeyBytes); } catch (InvalidInputException e) { throw new IOException("Received invalid profileKey", e); } } try (SignalAccount account = SignalAccount.createLinkedAccount(pathConfig.getDataPath(), username, ret.getUuid(), password, ret.getDeviceId(), ret.getIdentity(), registrationId, signalingKey, profileKey)) { account.save(); try (Manager m = new Manager(account, pathConfig, serviceConfiguration, userAgent)) { m.refreshPreKeys(); m.requestSyncGroups(); m.requestSyncContacts(); m.requestSyncBlocked(); m.requestSyncConfiguration(); m.saveAccount(); } } return username; }