Remove dead code and fix inspection issues

This commit is contained in:
AsamK 2021-12-05 10:25:46 +01:00
parent 6ffeb7c431
commit e83f43065e
13 changed files with 10 additions and 82 deletions

View file

@ -55,10 +55,6 @@ public class ServiceConfig {
} }
} }
public static AccountAttributes.Capabilities getCapabilities() {
return capabilities;
}
public static KeyStore getIasKeyStore() { public static KeyStore getIasKeyStore() {
return iasKeyStore; return iasKeyStore;
} }

View file

@ -26,10 +26,6 @@ public final class GroupInviteLinkUrl {
GroupLinkPassword.fromBytes(group.getInviteLinkPassword().toByteArray())); GroupLinkPassword.fromBytes(group.getInviteLinkPassword().toByteArray()));
} }
public static boolean isGroupLink(String urlString) {
return getGroupUrl(urlString) != null;
}
/** /**
* @return null iff not a group url. * @return null iff not a group url.
* @throws InvalidGroupLinkException If group url, but cannot be parsed. * @throws InvalidGroupLinkException If group url, but cannot be parsed.
@ -95,7 +91,7 @@ public final class GroupInviteLinkUrl {
this.url = createUrl(groupMasterKey, password); this.url = createUrl(groupMasterKey, password);
} }
protected static String createUrl(GroupMasterKey groupMasterKey, GroupLinkPassword password) { private static String createUrl(GroupMasterKey groupMasterKey, GroupLinkPassword password) {
var groupInviteLink = GroupInviteLink.newBuilder() var groupInviteLink = GroupInviteLink.newBuilder()
.setV1Contents(GroupInviteLink.GroupInviteLinkContentsV1.newBuilder() .setV1Contents(GroupInviteLink.GroupInviteLinkContentsV1.newBuilder()
.setGroupMasterKey(ByteString.copyFrom(groupMasterKey.serialize())) .setGroupMasterKey(ByteString.copyFrom(groupMasterKey.serialize()))

View file

@ -6,7 +6,7 @@ import org.asamk.signal.manager.storage.groups.GroupInfoV2;
import org.signal.zkgroup.InvalidInputException; import org.signal.zkgroup.InvalidInputException;
import org.signal.zkgroup.groups.GroupMasterKey; import org.signal.zkgroup.groups.GroupMasterKey;
import org.signal.zkgroup.groups.GroupSecretParams; import org.signal.zkgroup.groups.GroupSecretParams;
import org.whispersystems.libsignal.kdf.HKDFv3; import org.whispersystems.libsignal.kdf.HKDF;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage; import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceGroup; import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext; import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext;
@ -57,7 +57,7 @@ public class GroupUtils {
private static GroupMasterKey deriveV2MigrationMasterKey(GroupIdV1 groupIdV1) { private static GroupMasterKey deriveV2MigrationMasterKey(GroupIdV1 groupIdV1) {
try { try {
return new GroupMasterKey(new HKDFv3().deriveSecrets(groupIdV1.serialize(), return new GroupMasterKey(HKDF.deriveSecrets(groupIdV1.serialize(),
"GV2 Migration".getBytes(), "GV2 Migration".getBytes(),
GroupMasterKey.SIZE)); GroupMasterKey.SIZE));
} catch (InvalidInputException e) { } catch (InvalidInputException e) {

View file

@ -890,10 +890,6 @@ public class SignalAccount implements Closeable {
save(); save();
} }
public String getRegistrationLockPin() {
return registrationLockPin;
}
public void setRegistrationLockPin(final String registrationLockPin, final MasterKey pinMasterKey) { public void setRegistrationLockPin(final String registrationLockPin, final MasterKey pinMasterKey) {
this.registrationLockPin = registrationLockPin; this.registrationLockPin = registrationLockPin;
this.pinMasterKey = pinMasterKey; this.pinMasterKey = pinMasterKey;

View file

@ -41,8 +41,4 @@ public class IdentityInfo {
public Date getDateAdded() { public Date getDateAdded() {
return this.added; return this.added;
} }
public byte[] getFingerprint() {
return identityKey.getPublicKey().serialize();
}
} }

View file

@ -68,10 +68,6 @@ public class KeyUtils {
return new SignedPreKeyRecord(signedPreKeyId, System.currentTimeMillis(), keyPair, signature); return new SignedPreKeyRecord(signedPreKeyId, System.currentTimeMillis(), keyPair, signature);
} }
public static String createSignalingKey() {
return getSecret(52);
}
public static ProfileKey createProfileKey() { public static ProfileKey createProfileKey() {
try { try {
return new ProfileKey(getSecretBytes(32)); return new ProfileKey(getSecretBytes(32));

View file

@ -131,7 +131,7 @@ public class DbusManagerImpl implements Manager {
emptyIfNull(about), emptyIfNull(about),
emptyIfNull(aboutEmoji), emptyIfNull(aboutEmoji),
avatar == null ? "" : avatar.map(File::getPath).orElse(""), avatar == null ? "" : avatar.map(File::getPath).orElse(""),
avatar != null && !avatar.isPresent()); avatar != null && avatar.isEmpty());
} }
@Override @Override
@ -786,9 +786,8 @@ public class DbusManagerImpl implements Manager {
private void notifyMessageHandlers(final MessageEnvelope envelope) { private void notifyMessageHandlers(final MessageEnvelope envelope) {
synchronized (messageHandlers) { synchronized (messageHandlers) {
Stream.concat(messageHandlers.stream(), weakHandlers.stream()).forEach(h -> { Stream.concat(messageHandlers.stream(), weakHandlers.stream())
h.handleMessage(envelope, null); .forEach(h -> h.handleMessage(envelope, null));
});
} }
} }

View file

@ -18,12 +18,10 @@ import java.util.stream.Collectors;
public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler { public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler {
private final Manager m;
private final DBusConnection conn; private final DBusConnection conn;
private final String objectPath; private final String objectPath;
public DbusReceiveMessageHandler(Manager m, DBusConnection conn, final String objectPath) { public DbusReceiveMessageHandler(DBusConnection conn, final String objectPath) {
this.m = m;
this.conn = conn; this.conn = conn;
this.objectPath = objectPath; this.objectPath = objectPath;
} }
@ -127,7 +125,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
var attachments = message.attachments() var attachments = message.attachments()
.stream() .stream()
.filter(a -> a.id().isPresent()) .filter(a -> a.id().isPresent())
.map(a -> getAttachmentMap(m, a)) .map(this::getAttachmentMap)
.collect(Collectors.toList()); .collect(Collectors.toList());
extras.put("attachments", new Variant<>(attachments, "aa{sv}")); extras.put("attachments", new Variant<>(attachments, "aa{sv}"));
} }
@ -180,7 +178,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
} }
private Map<String, Variant<?>> getAttachmentMap( private Map<String, Variant<?>> getAttachmentMap(
final Manager m, final MessageEnvelope.Data.Attachment a final MessageEnvelope.Data.Attachment a
) { ) {
final var map = new HashMap<String, Variant<?>>(); final var map = new HashMap<String, Variant<?>>();
if (a.id().isPresent()) { if (a.id().isPresent()) {

View file

@ -111,7 +111,7 @@ public class DbusSignalImpl implements Signal {
@Override @Override
public void subscribeReceive() { public void subscribeReceive() {
if (dbusMessageHandler == null) { if (dbusMessageHandler == null) {
dbusMessageHandler = new DbusReceiveMessageHandler(m, connection, objectPath); dbusMessageHandler = new DbusReceiveMessageHandler(connection, objectPath);
m.addReceiveHandler(dbusMessageHandler); m.addReceiveHandler(dbusMessageHandler);
} }
subscriberCount++; subscriberCount++;

View file

@ -10,8 +10,4 @@ record JsonAttachment(String contentType, String filename, String id, Long size)
final var size = attachment.size().orElse(null); final var size = attachment.size().orElse(null);
return new JsonAttachment(attachment.contentType(), filename, id, size); return new JsonAttachment(attachment.contentType(), filename, id, size);
} }
static JsonAttachment from(String filename) {
return new JsonAttachment(filename, null, null, null);
}
} }

View file

@ -2,7 +2,6 @@ package org.asamk.signal.json;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import org.asamk.Signal;
import org.asamk.signal.manager.api.MessageEnvelope; import org.asamk.signal.manager.api.MessageEnvelope;
import java.util.List; import java.util.List;
@ -65,38 +64,4 @@ record JsonDataMessage(
contacts, contacts,
groupInfo); groupInfo);
} }
static JsonDataMessage from(Signal.MessageReceived messageReceived) {
return new JsonDataMessage(messageReceived.getTimestamp(),
messageReceived.getMessage(),
// TODO Replace these with the proper commands
null,
null,
null,
null,
null,
null,
messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
null,
null,
null,
messageReceived.getGroupId().length > 0 ? JsonGroupInfo.from(messageReceived.getGroupId()) : null);
}
static JsonDataMessage from(Signal.SyncMessageReceived messageReceived) {
return new JsonDataMessage(messageReceived.getTimestamp(),
messageReceived.getMessage(),
// TODO Replace these with the proper commands
null,
null,
null,
null,
null,
null,
messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
null,
null,
null,
messageReceived.getGroupId().length > 0 ? JsonGroupInfo.from(messageReceived.getGroupId()) : null);
}
} }

View file

@ -2,16 +2,10 @@ package org.asamk.signal.json;
import org.asamk.signal.manager.api.MessageEnvelope; import org.asamk.signal.manager.api.MessageEnvelope;
import java.util.Base64;
record JsonGroupInfo(String groupId, String type) { record JsonGroupInfo(String groupId, String type) {
static JsonGroupInfo from(MessageEnvelope.Data.GroupContext groupContext) { static JsonGroupInfo from(MessageEnvelope.Data.GroupContext groupContext) {
return new JsonGroupInfo(groupContext.groupId().toBase64(), return new JsonGroupInfo(groupContext.groupId().toBase64(),
groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER"); groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER");
} }
static JsonGroupInfo from(byte[] groupId) {
return new JsonGroupInfo(Base64.getEncoder().encodeToString(groupId), "DELIVER");
}
} }

View file

@ -5,8 +5,6 @@ import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.manager.api.ProofRequiredException; import org.asamk.signal.manager.api.ProofRequiredException;
import org.asamk.signal.manager.api.RecipientIdentifier; import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.SendMessageResult; import org.asamk.signal.manager.api.SendMessageResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -16,8 +14,6 @@ import java.util.stream.Collectors;
public class ErrorUtils { public class ErrorUtils {
private final static Logger logger = LoggerFactory.getLogger(ErrorUtils.class);
private ErrorUtils() { private ErrorUtils() {
} }