import org.whispersystems.signalservice.api.messages.multidevice.ViewOnceOpenMessage;
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
-import org.whispersystems.util.Base64;
import java.io.File;
+import java.util.Base64;
import java.util.List;
public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
for (StickerPackOperationMessage m : stickerPackOperationMessages) {
System.out.println(" - " + m.getType().toString());
if (m.getPackId().isPresent()) {
- System.out.println(" packId: " + Base64.encodeBytes(m.getPackId().get()));
+ System.out.println(" packId: " + Base64.getEncoder()
+ .encodeToString(m.getPackId().get()));
}
if (m.getPackKey().isPresent()) {
- System.out.println(" packKey: " + Base64.encodeBytes(m.getPackKey().get()));
+ System.out.println(" packKey: " + Base64.getEncoder()
+ .encodeToString(m.getPackKey().get()));
}
}
}
System.out.println("Received message request response:");
System.out.println(" Type: " + requestResponseMessage.getType());
if (requestResponseMessage.getGroupId().isPresent()) {
- System.out.println(" Group id: " + Base64.encodeBytes(requestResponseMessage.getGroupId()
- .get()));
+ System.out.println(" Group id: " + Base64.getEncoder()
+ .encodeToString(requestResponseMessage.getGroupId().get()));
}
if (requestResponseMessage.getPerson().isPresent()) {
System.out.println(" Person: " + requestResponseMessage.getPerson()
if (message.getSticker().isPresent()) {
final SignalServiceDataMessage.Sticker sticker = message.getSticker().get();
System.out.println("Sticker:");
- System.out.println(" - Pack id: " + Base64.encodeBytes(sticker.getPackId()));
- System.out.println(" - Pack key: " + Base64.encodeBytes(sticker.getPackKey()));
+ System.out.println(" - Pack id: " + Base64.getEncoder().encodeToString(sticker.getPackId()));
+ System.out.println(" - Pack key: " + Base64.getEncoder().encodeToString(sticker.getPackKey()));
System.out.println(" - Sticker id: " + sticker.getStickerId());
// TODO also download sticker image ??
}
import org.freedesktop.dbus.exceptions.DBusException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.whispersystems.util.Base64;
import java.io.IOException;
+import java.util.Base64;
import java.util.concurrent.TimeUnit;
import static org.asamk.signal.util.ErrorUtils.handleAssertionError;
messageReceived.getMessage()));
if (messageReceived.getGroupId().length > 0) {
System.out.println("Group info:");
- System.out.println(" Id: " + Base64.encodeBytes(messageReceived.getGroupId()));
+ System.out.println(" Id: " + Base64.getEncoder().encodeToString(messageReceived.getGroupId()));
}
if (messageReceived.getAttachments().size() > 0) {
System.out.println("Attachments: ");
syncReceived.getMessage()));
if (syncReceived.getGroupId().length > 0) {
System.out.println("Group info:");
- System.out.println(" Id: " + Base64.encodeBytes(syncReceived.getGroupId()));
+ System.out.println(" Id: " + Base64.getEncoder().encodeToString(syncReceived.getGroupId()));
}
if (syncReceived.getAttachments().size() > 0) {
System.out.println("Attachments: ");
import org.asamk.signal.manager.groups.GroupIdFormatException;
import org.asamk.signal.util.Util;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
-import org.whispersystems.util.Base64;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.List;
import static org.asamk.signal.util.ErrorUtils.handleAssertionError;
try {
byte[] newGroupId = signal.updateGroup(groupId, groupName, groupMembers, groupAvatar);
if (groupId.length != newGroupId.length) {
- System.out.println("Creating new group \"" + Base64.encodeBytes(newGroupId) + "\" …");
+ System.out.println("Creating new group \"" + Base64.getEncoder().encodeToString(newGroupId) + "\" …");
}
return 0;
} catch (AssertionError e) {
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
-import org.whispersystems.util.Base64;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.List;
class JsonGroupInfo {
String type;
JsonGroupInfo(SignalServiceGroup groupInfo) {
- this.groupId = Base64.encodeBytes(groupInfo.getGroupId());
+ this.groupId = Base64.getEncoder().encodeToString(groupInfo.getGroupId());
if (groupInfo.getMembers().isPresent()) {
this.members = new ArrayList<>(groupInfo.getMembers().get().size());
for (SignalServiceAddress address : groupInfo.getMembers().get()) {
}
JsonGroupInfo(byte[] groupId) {
- this.groupId = Base64.encodeBytes(groupId);
+ this.groupId = Base64.getEncoder().encodeToString(groupId);
}
}
package org.asamk.signal.json;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
-import org.whispersystems.util.Base64;
+
+import java.util.Base64;
public class JsonSticker {
int stickerId;
public JsonSticker(SignalServiceDataMessage.Sticker sticker) {
- this.packId = Base64.encodeBytes(sticker.getPackId());
- this.packKey = Base64.encodeBytes(sticker.getPackKey());
+ this.packId = Base64.getEncoder().encodeToString(sticker.getPackId());
+ this.packKey = Base64.getEncoder().encodeToString(sticker.getPackKey());
this.stickerId = sticker.getStickerId();
// TODO also download sticker image ??
}
import org.whispersystems.libsignal.InvalidKeyException;
import org.whispersystems.libsignal.ecc.Curve;
import org.whispersystems.libsignal.ecc.ECPublicKey;
-import org.whispersystems.util.Base64;
-import java.io.IOException;
import java.net.URI;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
+import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
final String deviceIdentifier;
final ECPublicKey deviceKey;
- public static DeviceLinkInfo parseDeviceLinkUri(URI linkUri) throws IOException, InvalidKeyException {
+ public static DeviceLinkInfo parseDeviceLinkUri(URI linkUri) throws InvalidKeyException {
final String rawQuery = linkUri.getRawQuery();
if (isEmpty(rawQuery)) {
throw new RuntimeException("Invalid device link uri");
throw new RuntimeException("Invalid device link uri");
}
- ECPublicKey deviceKey = Curve.decodePoint(Base64.decode(publicKeyEncoded), 0);
+ final byte[] publicKeyBytes;
+ try {
+ publicKeyBytes = Base64.getDecoder().decode(publicKeyEncoded);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException("Invalid device link uri", e);
+ }
+ ECPublicKey deviceKey = Curve.decodePoint(publicKeyBytes, 0);
return new DeviceLinkInfo(deviceIdentifier, deviceKey);
}
}
public String createDeviceLinkUri() {
+ final String deviceKeyString = Base64.getEncoder().encodeToString(deviceKey.serialize()).replace("=", "");
return "tsdevice:/?uuid="
+ URLEncoder.encode(deviceIdentifier, StandardCharsets.UTF_8)
+ "&pub_key="
- + URLEncoder.encode(Base64.encodeBytesWithoutPadding(deviceKey.serialize()), StandardCharsets.UTF_8);
+ + URLEncoder.encode(deviceKeyString, StandardCharsets.UTF_8);
}
}
package org.asamk.signal.manager.groups;
-import org.whispersystems.util.Base64;
-
import java.util.Arrays;
+import java.util.Base64;
public abstract class GroupId {
}
public String toBase64() {
- return Base64.encodeBytes(id);
+ return Base64.getEncoder().encodeToString(id);
}
@Override
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
import org.whispersystems.signalservice.api.kbs.MasterKey;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
-import org.whispersystems.util.Base64;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
+import java.util.Base64;
import java.util.Collection;
import java.util.UUID;
import java.util.stream.Collectors;
}
final ProfileKey profileKey;
try {
- profileKey = new ProfileKey(Base64.decode(profileKeyString));
- } catch (InvalidInputException | IOException e) {
+ profileKey = new ProfileKey(Base64.getDecoder().decode(profileKeyString));
+ } catch (InvalidInputException ignored) {
continue;
}
contact.profileKey = null;
JsonNode pinMasterKeyNode = rootNode.get("pinMasterKey");
pinMasterKey = pinMasterKeyNode == null || pinMasterKeyNode.isNull()
? null
- : new MasterKey(Base64.decode(pinMasterKeyNode.asText()));
+ : new MasterKey(Base64.getDecoder().decode(pinMasterKeyNode.asText()));
if (rootNode.has("signalingKey")) {
signalingKey = Utils.getNotNullNode(rootNode, "signalingKey").asText();
}
}
if (rootNode.has("profileKey")) {
try {
- profileKey = new ProfileKey(Base64.decode(Utils.getNotNullNode(rootNode, "profileKey").asText()));
+ profileKey = new ProfileKey(Base64.getDecoder()
+ .decode(Utils.getNotNullNode(rootNode, "profileKey").asText()));
} catch (InvalidInputException e) {
throw new IOException(
"Config file contains an invalid profileKey, needs to be base64 encoded array of 32 bytes",
.put("isMultiDevice", isMultiDevice)
.put("password", password)
.put("registrationLockPin", registrationLockPin)
- .put("pinMasterKey", pinMasterKey == null ? null : Base64.encodeBytes(pinMasterKey.serialize()))
+ .put("pinMasterKey",
+ pinMasterKey == null ? null : Base64.getEncoder().encodeToString(pinMasterKey.serialize()))
.put("signalingKey", signalingKey)
.put("preKeyIdOffset", preKeyIdOffset)
.put("nextSignedPreKeyId", nextSignedPreKeyId)
- .put("profileKey", Base64.encodeBytes(profileKey.serialize()))
+ .put("profileKey", Base64.getEncoder().encodeToString(profileKey.serialize()))
.put("registered", registered)
.putPOJO("axolotlStore", signalProtocolStore)
.putPOJO("groupStore", groupStore)
import org.signal.zkgroup.groups.GroupMasterKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.whispersystems.util.Base64;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
final GroupInfoV2 groupV2 = (GroupInfoV2) group;
jgen.writeStartObject();
jgen.writeStringField("groupId", groupV2.getGroupId().toBase64());
- jgen.writeStringField("masterKey", Base64.encodeBytes(groupV2.getMasterKey().serialize()));
+ jgen.writeStringField("masterKey",
+ Base64.getEncoder().encodeToString(groupV2.getMasterKey().serialize()));
jgen.writeBooleanField("blocked", groupV2.isBlocked());
jgen.writeEndObject();
} else {
// a v2 group
GroupIdV2 groupId = GroupIdV2.fromBase64(n.get("groupId").asText());
try {
- GroupMasterKey masterKey = new GroupMasterKey(Base64.decode(n.get("masterKey").asText()));
+ GroupMasterKey masterKey = new GroupMasterKey(Base64.getDecoder()
+ .decode(n.get("masterKey").asText()));
g = new GroupInfoV2(groupId, masterKey);
- } catch (InvalidInputException e) {
+ } catch (InvalidInputException | IllegalArgumentException e) {
throw new AssertionError("Invalid master key for group " + groupId.toBase64());
}
g.setBlocked(n.get("blocked").asBoolean(false));
} else {
- GroupInfoV1 gv1 = jsonProcessor.treeToValue(n, GroupInfoV1.class);
- g = gv1;
+ g = jsonProcessor.treeToValue(n, GroupInfoV1.class);
}
groups.put(g.getGroupId(), g);
}
import org.signal.zkgroup.profiles.ProfileKeyCredential;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.UuidUtil;
-import org.whispersystems.util.Base64;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.List;
import java.util.UUID;
final SignalServiceAddress serviceAddress = new SignalServiceAddress(uuid, name);
ProfileKey profileKey = null;
try {
- profileKey = new ProfileKey(Base64.decode(entry.get("profileKey").asText()));
+ profileKey = new ProfileKey(Base64.getDecoder().decode(entry.get("profileKey").asText()));
} catch (InvalidInputException ignored) {
}
ProfileKeyCredential profileKeyCredential = null;
if (entry.hasNonNull("profileKeyCredential")) {
try {
- profileKeyCredential = new ProfileKeyCredential(Base64.decode(entry.get(
- "profileKeyCredential").asText()));
+ profileKeyCredential = new ProfileKeyCredential(Base64.getDecoder()
+ .decode(entry.get("profileKeyCredential").asText()));
} catch (Throwable ignored) {
}
}
if (address.getUuid().isPresent()) {
json.writeStringField("uuid", address.getUuid().get().toString());
}
- json.writeStringField("profileKey", Base64.encodeBytes(profileEntry.getProfileKey().serialize()));
+ json.writeStringField("profileKey",
+ Base64.getEncoder().encodeToString(profileEntry.getProfileKey().serialize()));
json.writeNumberField("lastUpdateTimestamp", profileEntry.getLastUpdateTimestamp());
json.writeObjectField("profile", profileEntry.getProfile());
if (profileEntry.getProfileKeyCredential() != null) {
json.writeStringField("profileKeyCredential",
- Base64.encodeBytes(profileEntry.getProfileKeyCredential().serialize()));
+ Base64.getEncoder().encodeToString(profileEntry.getProfileKeyCredential().serialize()));
}
json.writeEndObject();
}
import org.whispersystems.libsignal.state.IdentityKeyStore;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.UuidUtil;
-import org.whispersystems.util.Base64;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.UUID;
try {
int localRegistrationId = node.get("registrationId").asInt();
- IdentityKeyPair identityKeyPair = new IdentityKeyPair(Base64.decode(node.get("identityKey").asText()));
+ IdentityKeyPair identityKeyPair = new IdentityKeyPair(Base64.getDecoder()
+ .decode(node.get("identityKey").asText()));
JsonIdentityKeyStore keyStore = new JsonIdentityKeyStore(identityKeyPair, localRegistrationId);
? Utils.getSignalServiceAddressFromIdentifier(trustedKeyName)
: new SignalServiceAddress(uuid, trustedKeyName);
try {
- IdentityKey id = new IdentityKey(Base64.decode(trustedKey.get("identityKey").asText()), 0);
+ IdentityKey id = new IdentityKey(Base64.getDecoder()
+ .decode(trustedKey.get("identityKey").asText()), 0);
TrustLevel trustLevel = trustedKey.has("trustLevel") ? TrustLevel.fromInt(trustedKey.get(
"trustLevel").asInt()) : TrustLevel.TRUSTED_UNVERIFIED;
Date added = trustedKey.has("addedTimestamp") ? new Date(trustedKey.get("addedTimestamp")
.asLong()) : new Date();
keyStore.saveIdentity(serviceAddress, id, trustLevel, added);
- } catch (InvalidKeyException | IOException e) {
+ } catch (InvalidKeyException e) {
logger.warn("Error while decoding key for {}: {}", trustedKeyName, e.getMessage());
}
}
json.writeStartObject();
json.writeNumberField("registrationId", jsonIdentityKeyStore.getLocalRegistrationId());
json.writeStringField("identityKey",
- Base64.encodeBytes(jsonIdentityKeyStore.getIdentityKeyPair().serialize()));
+ Base64.getEncoder().encodeToString(jsonIdentityKeyStore.getIdentityKeyPair().serialize()));
+ json.writeStringField("identityPrivateKey",
+ Base64.getEncoder()
+ .encodeToString(jsonIdentityKeyStore.getIdentityKeyPair().getPrivateKey().serialize()));
+ json.writeStringField("identityPublicKey",
+ Base64.getEncoder()
+ .encodeToString(jsonIdentityKeyStore.getIdentityKeyPair().getPublicKey().serialize()));
json.writeArrayFieldStart("trustedKeys");
for (IdentityInfo trustedKey : jsonIdentityKeyStore.identities) {
json.writeStartObject();
if (trustedKey.getAddress().getUuid().isPresent()) {
json.writeStringField("uuid", trustedKey.getAddress().getUuid().get().toString());
}
- json.writeStringField("identityKey", Base64.encodeBytes(trustedKey.identityKey.serialize()));
+ json.writeStringField("identityKey",
+ Base64.getEncoder().encodeToString(trustedKey.identityKey.serialize()));
json.writeNumberField("trustLevel", trustedKey.trustLevel.ordinal());
json.writeNumberField("addedTimestamp", trustedKey.added.getTime());
json.writeEndObject();
json.writeEndObject();
}
}
-
}
import org.whispersystems.libsignal.InvalidKeyIdException;
import org.whispersystems.libsignal.state.PreKeyRecord;
import org.whispersystems.libsignal.state.PreKeyStore;
-import org.whispersystems.util.Base64;
import java.io.IOException;
+import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
Map<Integer, byte[]> preKeyMap = new HashMap<>();
if (node.isArray()) {
for (JsonNode preKey : node) {
- Integer preKeyId = preKey.get("id").asInt();
- try {
- preKeyMap.put(preKeyId, Base64.decode(preKey.get("record").asText()));
- } catch (IOException e) {
- logger.warn("Error while decoding prekey for {}: {}", preKeyId, e.getMessage());
- }
+ final int preKeyId = preKey.get("id").asInt();
+ final byte[] preKeyRecord = Base64.getDecoder().decode(preKey.get("record").asText());
+ preKeyMap.put(preKeyId, preKeyRecord);
}
}
keyStore.addPreKeys(preKeyMap);
return keyStore;
-
}
}
for (Map.Entry<Integer, byte[]> preKey : jsonPreKeyStore.store.entrySet()) {
json.writeStartObject();
json.writeNumberField("id", preKey.getKey());
- json.writeStringField("record", Base64.encodeBytes(preKey.getValue()));
+ json.writeStringField("record", Base64.getEncoder().encodeToString(preKey.getValue()));
json.writeEndObject();
}
json.writeEndArray();
import org.whispersystems.libsignal.state.SessionStore;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.UuidUtil;
-import org.whispersystems.util.Base64;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
? Utils.getSignalServiceAddressFromIdentifier(sessionName)
: new SignalServiceAddress(uuid, sessionName);
final int deviceId = session.get("deviceId").asInt();
- final String record = session.get("record").asText();
- try {
- SessionInfo sessionInfo = new SessionInfo(serviceAddress, deviceId, Base64.decode(record));
- sessionStore.sessions.add(sessionInfo);
- } catch (IOException e) {
- logger.warn("Error while decoding session for {}: {}", sessionName, e.getMessage());
- }
+ final byte[] record = Base64.getDecoder().decode(session.get("record").asText());
+ SessionInfo sessionInfo = new SessionInfo(serviceAddress, deviceId, record);
+ sessionStore.sessions.add(sessionInfo);
}
}
json.writeStringField("uuid", sessionInfo.address.getUuid().get().toString());
}
json.writeNumberField("deviceId", sessionInfo.deviceId);
- json.writeStringField("record", Base64.encodeBytes(sessionInfo.sessionRecord));
+ json.writeStringField("record", Base64.getEncoder().encodeToString(sessionInfo.sessionRecord));
json.writeEndObject();
}
json.writeEndArray();
import org.whispersystems.libsignal.InvalidKeyIdException;
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
import org.whispersystems.libsignal.state.SignedPreKeyStore;
-import org.whispersystems.util.Base64;
import java.io.IOException;
+import java.util.Base64;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
Map<Integer, byte[]> preKeyMap = new HashMap<>();
if (node.isArray()) {
for (JsonNode preKey : node) {
- Integer preKeyId = preKey.get("id").asInt();
- try {
- preKeyMap.put(preKeyId, Base64.decode(preKey.get("record").asText()));
- } catch (IOException e) {
- logger.warn("Error while decoding prekey for {}: {}", preKeyId, e.getMessage());
- }
+ final int preKeyId = preKey.get("id").asInt();
+ final byte[] preKeyRecord = Base64.getDecoder().decode(preKey.get("record").asText());
+ preKeyMap.put(preKeyId, preKeyRecord);
}
}
keyStore.addSignedPreKeys(preKeyMap);
return keyStore;
-
}
}
for (Map.Entry<Integer, byte[]> signedPreKey : jsonPreKeyStore.store.entrySet()) {
json.writeStartObject();
json.writeNumberField("id", signedPreKey.getKey());
- json.writeStringField("record", Base64.encodeBytes(signedPreKey.getValue()));
+ json.writeStringField("record", Base64.getEncoder().encodeToString(signedPreKey.getValue()));
json.writeEndObject();
}
json.writeEndArray();
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import org.whispersystems.util.Base64;
-
import java.io.IOException;
+import java.util.Base64;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class StickerStore {
- private static final ObjectMapper jsonProcessor = new ObjectMapper();
-
@JsonSerialize(using = StickersSerializer.class)
@JsonDeserialize(using = StickersDeserializer.class)
private final Map<byte[], Sticker> stickers = new HashMap<>();
jgen.writeStartArray(stickers.size());
for (Sticker sticker : stickers) {
jgen.writeStartObject();
- jgen.writeStringField("packId", Base64.encodeBytes(sticker.getPackId()));
- jgen.writeStringField("packKey", Base64.encodeBytes(sticker.getPackKey()));
+ jgen.writeStringField("packId", Base64.getEncoder().encodeToString(sticker.getPackId()));
+ jgen.writeStringField("packKey", Base64.getEncoder().encodeToString(sticker.getPackKey()));
jgen.writeBooleanField("installed", sticker.isInstalled());
jgen.writeEndObject();
}
Map<byte[], Sticker> stickers = new HashMap<>();
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
for (JsonNode n : node) {
- byte[] packId = Base64.decode(n.get("packId").asText());
- byte[] packKey = Base64.decode(n.get("packKey").asText());
+ byte[] packId = Base64.getDecoder().decode(n.get("packId").asText());
+ byte[] packKey = Base64.getDecoder().decode(n.get("packKey").asText());
boolean installed = n.get("installed").asBoolean(false);
stickers.put(packId, new Sticker(packId, packKey, installed));
}
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
import org.whispersystems.libsignal.util.Medium;
import org.whispersystems.signalservice.api.kbs.MasterKey;
-import org.whispersystems.util.Base64;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.List;
public class KeyUtils {
private static String getSecret(int size) {
byte[] secret = getSecretBytes(size);
- return Base64.encodeBytes(secret);
+ return Base64.getEncoder().encodeToString(secret);
}
public static byte[] getSecretBytes(int size) {
import org.whispersystems.signalservice.api.crypto.InvalidCiphertextException;
import org.whispersystems.signalservice.api.crypto.ProfileCipher;
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
-import org.whispersystems.util.Base64;
-import java.io.IOException;
+import java.util.Base64;
public class ProfileUtils {
try {
name = encryptedProfile.getName() == null
? null
- : new String(profileCipher.decryptName(Base64.decode(encryptedProfile.getName())));
- } catch (IOException e) {
+ : new String(profileCipher.decryptName(Base64.getDecoder().decode(encryptedProfile.getName())));
+ } catch (IllegalArgumentException e) {
name = null;
}
String unidentifiedAccess;
try {
unidentifiedAccess = encryptedProfile.getUnidentifiedAccess() == null
- || !profileCipher.verifyUnidentifiedAccess(Base64.decode(encryptedProfile.getUnidentifiedAccess()))
+ || !profileCipher.verifyUnidentifiedAccess(Base64.getDecoder()
+ .decode(encryptedProfile.getUnidentifiedAccess()))
? null
: encryptedProfile.getUnidentifiedAccess();
- } catch (IOException e) {
+ } catch (IllegalArgumentException e) {
unidentifiedAccess = null;
}
return new SignalProfile(encryptedProfile.getIdentityKey(),