use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.
the class LogSectionSystemInfo method getCensoredAci.
private static String getCensoredAci(@NonNull Context context) {
ACI aci = SignalStore.account().getAci();
if (aci != null) {
String aciString = aci.toString();
String lastTwo = aciString.substring(aciString.length() - 2);
return "********-****-****-****-**********" + lastTwo;
} else {
return "N/A";
}
}
use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.
the class SignalServiceAccountManager method getRegisteredUsersWithCdsh.
public Map<String, ACI> getRegisteredUsersWithCdsh(Set<String> e164numbers, String hexPublicKey, String hexCodeHash) throws IOException {
CdshAuthResponse auth = pushServiceSocket.getCdshAuth();
CdshService service = new CdshService(configuration, hexPublicKey, hexCodeHash);
Single<ServiceResponse<Map<String, ACI>>> result = service.getRegisteredUsers(auth.getUsername(), auth.getPassword(), e164numbers);
ServiceResponse<Map<String, ACI>> response;
try {
response = result.blockingGet();
} catch (Exception e) {
throw new RuntimeException("Unexpected exception when retrieving registered users!", e);
}
if (response.getResult().isPresent()) {
return response.getResult().get();
} else if (response.getApplicationError().isPresent()) {
throw new IOException(response.getApplicationError().get());
} else if (response.getExecutionError().isPresent()) {
throw new IOException(response.getExecutionError().get());
} else {
throw new IOException("Missing result!");
}
}
use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.
the class RotateSignedPreKeyJob method onRun.
@Override
public void onRun() throws Exception {
if (!SignalStore.account().isRegistered() || SignalStore.account().getAci() == null || SignalStore.account().getPni() == null) {
Log.w(TAG, "Not registered. Skipping.");
return;
}
Log.i(TAG, "Rotating signed prekey...");
ACI aci = SignalStore.account().getAci();
PNI pni = SignalStore.account().getPni();
if (aci == null) {
Log.w(TAG, "ACI is unset!");
return;
}
if (pni == null) {
Log.w(TAG, "PNI is unset!");
return;
}
rotate(ServiceIdType.ACI, ApplicationDependencies.getProtocolStore().aci(), SignalStore.account().aciPreKeys());
rotate(ServiceIdType.PNI, ApplicationDependencies.getProtocolStore().pni(), SignalStore.account().pniPreKeys());
}
use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.
the class ContactDiscoveryV3 method getDirectoryResult.
@WorkerThread
static DirectoryResult getDirectoryResult(@NonNull Set<String> databaseNumbers, @NonNull Set<String> systemNumbers) throws IOException {
Set<String> allNumbers = SetUtil.union(databaseNumbers, systemNumbers);
FuzzyPhoneNumberHelper.InputResult inputResult = FuzzyPhoneNumberHelper.generateInput(allNumbers, databaseNumbers);
Set<String> sanitizedNumbers = sanitizeNumbers(inputResult.getNumbers());
Set<String> ignoredNumbers = new HashSet<>();
if (sanitizedNumbers.size() > MAX_NUMBERS) {
Set<String> randomlySelected = randomlySelect(sanitizedNumbers, MAX_NUMBERS);
ignoredNumbers = SetUtil.difference(sanitizedNumbers, randomlySelected);
sanitizedNumbers = randomlySelected;
}
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
try {
Map<String, ACI> results = accountManager.getRegisteredUsersWithCdsh(sanitizedNumbers, BuildConfig.CDSH_PUBLIC_KEY, BuildConfig.CDSH_CODE_HASH);
FuzzyPhoneNumberHelper.OutputResult outputResult = FuzzyPhoneNumberHelper.generateOutput(results, inputResult);
return new DirectoryResult(outputResult.getNumbers(), outputResult.getRewrites(), ignoredNumbers);
} catch (IOException e) {
Log.w(TAG, "Attestation error.", e);
throw new IOException(e);
}
}
use of org.whispersystems.signalservice.api.push.ACI in project Signal-Android by WhisperSystems.
the class ApplicationDependencyProvider method provideProtocolStore.
@Override
@NonNull
public SignalServiceDataStoreImpl provideProtocolStore() {
ACI localAci = SignalStore.account().getAci();
PNI localPni = SignalStore.account().getPni();
if (localAci == null) {
throw new IllegalStateException("No ACI set!");
}
if (localPni == null) {
throw new IllegalStateException("No PNI set!");
}
if (!SignalStore.account().hasPniIdentityKey()) {
SignalStore.account().generatePniIdentityKeyIfNecessary();
CreateSignedPreKeyJob.enqueueIfNeeded();
}
SignalBaseIdentityKeyStore baseIdentityStore = new SignalBaseIdentityKeyStore(context);
SignalServiceAccountDataStoreImpl aciStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localAci), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getAciIdentityKey()), new TextSecureSessionStore(localAci), new SignalSenderKeyStore(context));
SignalServiceAccountDataStoreImpl pniStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localPni), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getPniIdentityKey()), new TextSecureSessionStore(localPni), new SignalSenderKeyStore(context));
return new SignalServiceDataStoreImpl(context, aciStore, pniStore);
}
Aggregations