Search in sources :

Example 1 with CdshAuthResponse

use of org.whispersystems.signalservice.internal.push.CdshAuthResponse in project Signal-Android by signalapp.

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!");
    }
}
Also used : CdshService(org.whispersystems.signalservice.api.services.CdshService) ServiceResponse(org.whispersystems.signalservice.internal.ServiceResponse) ACI(org.whispersystems.signalservice.api.push.ACI) CdshAuthResponse(org.whispersystems.signalservice.internal.push.CdshAuthResponse) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoContentException(org.whispersystems.signalservice.api.push.exceptions.NoContentException) InvalidKeyException(org.whispersystems.libsignal.InvalidKeyException) UnauthenticatedQuoteException(org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException) PushNetworkException(org.whispersystems.signalservice.api.push.exceptions.PushNetworkException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) NotFoundException(org.whispersystems.signalservice.api.push.exceptions.NotFoundException) NonSuccessfulResponseCodeException(org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException) InvalidCiphertextException(org.whispersystems.signalservice.api.crypto.InvalidCiphertextException) SignatureException(java.security.SignatureException) UnauthenticatedResponseException(org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)

Example 2 with CdshAuthResponse

use of org.whispersystems.signalservice.internal.push.CdshAuthResponse 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!");
    }
}
Also used : CdshService(org.whispersystems.signalservice.api.services.CdshService) ServiceResponse(org.whispersystems.signalservice.internal.ServiceResponse) ACI(org.whispersystems.signalservice.api.push.ACI) CdshAuthResponse(org.whispersystems.signalservice.internal.push.CdshAuthResponse) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoContentException(org.whispersystems.signalservice.api.push.exceptions.NoContentException) InvalidKeyException(org.whispersystems.libsignal.InvalidKeyException) UnauthenticatedQuoteException(org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException) PushNetworkException(org.whispersystems.signalservice.api.push.exceptions.PushNetworkException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) NotFoundException(org.whispersystems.signalservice.api.push.exceptions.NotFoundException) NonSuccessfulResponseCodeException(org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException) InvalidCiphertextException(org.whispersystems.signalservice.api.crypto.InvalidCiphertextException) SignatureException(java.security.SignatureException) UnauthenticatedResponseException(org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)

Aggregations

ByteString (com.google.protobuf.ByteString)2 IOException (java.io.IOException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SignatureException (java.security.SignatureException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)2 InvalidCiphertextException (org.whispersystems.signalservice.api.crypto.InvalidCiphertextException)2 ACI (org.whispersystems.signalservice.api.push.ACI)2 NoContentException (org.whispersystems.signalservice.api.push.exceptions.NoContentException)2 NonSuccessfulResponseCodeException (org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException)2 NotFoundException (org.whispersystems.signalservice.api.push.exceptions.NotFoundException)2 PushNetworkException (org.whispersystems.signalservice.api.push.exceptions.PushNetworkException)2 CdshService (org.whispersystems.signalservice.api.services.CdshService)2 ServiceResponse (org.whispersystems.signalservice.internal.ServiceResponse)2 UnauthenticatedQuoteException (org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException)2 UnauthenticatedResponseException (org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)2 CdshAuthResponse (org.whispersystems.signalservice.internal.push.CdshAuthResponse)2