import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.SignalServiceMessagePipe;
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
-import org.whispersystems.signalservice.api.crypto.InvalidCiphertextException;
-import org.whispersystems.signalservice.api.crypto.ProfileCipher;
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
import org.whispersystems.signalservice.internal.util.concurrent.CascadingFuture;
import org.whispersystems.signalservice.internal.util.concurrent.ListenableFuture;
-import org.whispersystems.util.Base64;
import java.io.IOException;
import java.util.Arrays;
}
public ProfileAndCredential retrieveProfileSync(
- SignalServiceAddress recipient,
- SignalServiceProfile.RequestType requestType
+ SignalServiceAddress recipient, SignalServiceProfile.RequestType requestType
) throws IOException {
try {
return retrieveProfile(recipient, requestType).get(10, TimeUnit.SECONDS);
}
public ListenableFuture<ProfileAndCredential> retrieveProfile(
- SignalServiceAddress address,
- SignalServiceProfile.RequestType requestType
+ SignalServiceAddress address, SignalServiceProfile.RequestType requestType
) {
Optional<UnidentifiedAccess> unidentifiedAccess = getUnidentifiedAccess(address);
Optional<ProfileKey> profileKey = Optional.fromNullable(profileKeyProvider.getProfileKey(address));
if (unidentifiedAccess.isPresent()) {
- return new CascadingFuture<>(Arrays.asList(() -> getPipeRetrievalFuture(address, profileKey, unidentifiedAccess, requestType),
+ return new CascadingFuture<>(Arrays.asList(() -> getPipeRetrievalFuture(address,
+ profileKey,
+ unidentifiedAccess,
+ requestType),
() -> getSocketRetrievalFuture(address, profileKey, unidentifiedAccess, requestType),
() -> getPipeRetrievalFuture(address, profileKey, Optional.absent(), requestType),
() -> getSocketRetrievalFuture(address, profileKey, Optional.absent(), requestType)),
e -> !(e instanceof NotFoundException));
} else {
- return new CascadingFuture<>(Arrays.asList(() -> getPipeRetrievalFuture(address, profileKey, Optional.absent(), requestType),
- () -> getSocketRetrievalFuture(address, profileKey, Optional.absent(), requestType)),
+ return new CascadingFuture<>(Arrays.asList(() -> getPipeRetrievalFuture(address,
+ profileKey,
+ Optional.absent(),
+ requestType), () -> getSocketRetrievalFuture(address, profileKey, Optional.absent(), requestType)),
e -> !(e instanceof NotFoundException));
}
}
- public String decryptName(
- ProfileKey profileKey,
- String encryptedName
- ) throws InvalidCiphertextException, IOException {
- if (encryptedName == null) {
- return null;
- }
-
- ProfileCipher profileCipher = new ProfileCipher(profileKey);
- return new String(profileCipher.decryptName(Base64.decode(encryptedName)));
- }
-
private ListenableFuture<ProfileAndCredential> getPipeRetrievalFuture(
SignalServiceAddress address,
Optional<ProfileKey> profileKey,
? unidentifiedPipe
: messagePipeProvider.getMessagePipe(false);
if (pipe != null) {
- return pipe.getProfile(address, profileKey, unidentifiedAccess, requestType);
+ try {
+ return pipe.getProfile(address, profileKey, unidentifiedAccess, requestType);
+ } catch (NoClassDefFoundError e) {
+ // Native zkgroup lib not available for ProfileKey
+ if (!address.getNumber().isPresent()) {
+ throw new NotFoundException("Can't request profile without number");
+ }
+ SignalServiceAddress addressWithoutUuid = new SignalServiceAddress(Optional.absent(),
+ address.getNumber());
+ return pipe.getProfile(addressWithoutUuid, profileKey, unidentifiedAccess, requestType);
+ }
}
throw new IOException("No pipe available!");
Optional<ProfileKey> profileKey,
Optional<UnidentifiedAccess> unidentifiedAccess,
SignalServiceProfile.RequestType requestType
- ) {
+ ) throws NotFoundException {
SignalServiceMessageReceiver receiver = messageReceiverProvider.getMessageReceiver();
- return receiver.retrieveProfile(address, profileKey, unidentifiedAccess, requestType);
+ try {
+ return receiver.retrieveProfile(address, profileKey, unidentifiedAccess, requestType);
+ } catch (NoClassDefFoundError e) {
+ // Native zkgroup lib not available for ProfileKey
+ if (!address.getNumber().isPresent()) {
+ throw new NotFoundException("Can't request profile without number");
+ }
+ SignalServiceAddress addressWithoutUuid = new SignalServiceAddress(Optional.absent(), address.getNumber());
+ return receiver.retrieveProfile(addressWithoutUuid, profileKey, unidentifiedAccess, requestType);
+ }
}
private Optional<UnidentifiedAccess> getUnidentifiedAccess(SignalServiceAddress recipient) {