mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Move credentials provider to SignalAccount
This commit is contained in:
parent
0476895c3d
commit
292ef0f2da
3 changed files with 29 additions and 11 deletions
|
@ -70,7 +70,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
||||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||||
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||||
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
|
||||||
import org.whispersystems.signalservice.internal.util.Hex;
|
import org.whispersystems.signalservice.internal.util.Hex;
|
||||||
import org.whispersystems.signalservice.internal.util.Util;
|
import org.whispersystems.signalservice.internal.util.Util;
|
||||||
|
|
||||||
|
@ -100,7 +99,6 @@ class ManagerImpl implements Manager {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
|
private final static Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
|
||||||
|
|
||||||
private SignalAccount account;
|
private SignalAccount account;
|
||||||
private final AccountFileUpdater accountFileUpdater;
|
|
||||||
private final SignalDependencies dependencies;
|
private final SignalDependencies dependencies;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
|
@ -121,12 +119,7 @@ class ManagerImpl implements Manager {
|
||||||
String userAgent
|
String userAgent
|
||||||
) {
|
) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.accountFileUpdater = accountFileUpdater;
|
|
||||||
|
|
||||||
final var credentialsProvider = new DynamicCredentialsProvider(account.getAci(),
|
|
||||||
account.getNumber(),
|
|
||||||
account.getPassword(),
|
|
||||||
account.getDeviceId());
|
|
||||||
final var sessionLock = new SignalSessionLock() {
|
final var sessionLock = new SignalSessionLock() {
|
||||||
private final ReentrantLock LEGACY_LOCK = new ReentrantLock();
|
private final ReentrantLock LEGACY_LOCK = new ReentrantLock();
|
||||||
|
|
||||||
|
@ -138,7 +131,7 @@ class ManagerImpl implements Manager {
|
||||||
};
|
};
|
||||||
this.dependencies = new SignalDependencies(serviceEnvironmentConfig,
|
this.dependencies = new SignalDependencies(serviceEnvironmentConfig,
|
||||||
userAgent,
|
userAgent,
|
||||||
credentialsProvider,
|
account.getCredentialsProvider(),
|
||||||
account.getSignalProtocolStore(),
|
account.getSignalProtocolStore(),
|
||||||
executor,
|
executor,
|
||||||
sessionLock);
|
sessionLock);
|
||||||
|
|
|
@ -18,9 +18,9 @@ import org.whispersystems.signalservice.api.groupsv2.GroupsV2Api;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.services.ProfileService;
|
import org.whispersystems.signalservice.api.services.ProfileService;
|
||||||
|
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||||
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
|
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
|
||||||
import org.whispersystems.signalservice.api.websocket.WebSocketFactory;
|
import org.whispersystems.signalservice.api.websocket.WebSocketFactory;
|
||||||
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
|
|
||||||
import org.whispersystems.signalservice.internal.websocket.WebSocketConnection;
|
import org.whispersystems.signalservice.internal.websocket.WebSocketConnection;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -34,7 +34,7 @@ public class SignalDependencies {
|
||||||
|
|
||||||
private final ServiceEnvironmentConfig serviceEnvironmentConfig;
|
private final ServiceEnvironmentConfig serviceEnvironmentConfig;
|
||||||
private final String userAgent;
|
private final String userAgent;
|
||||||
private final DynamicCredentialsProvider credentialsProvider;
|
private final CredentialsProvider credentialsProvider;
|
||||||
private final SignalServiceDataStore dataStore;
|
private final SignalServiceDataStore dataStore;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
private final SignalSessionLock sessionLock;
|
private final SignalSessionLock sessionLock;
|
||||||
|
@ -55,7 +55,7 @@ public class SignalDependencies {
|
||||||
SignalDependencies(
|
SignalDependencies(
|
||||||
final ServiceEnvironmentConfig serviceEnvironmentConfig,
|
final ServiceEnvironmentConfig serviceEnvironmentConfig,
|
||||||
final String userAgent,
|
final String userAgent,
|
||||||
final DynamicCredentialsProvider credentialsProvider,
|
final CredentialsProvider credentialsProvider,
|
||||||
final SignalServiceDataStore dataStore,
|
final SignalServiceDataStore dataStore,
|
||||||
final ExecutorService executor,
|
final ExecutorService executor,
|
||||||
final SignalSessionLock sessionLock
|
final SignalSessionLock sessionLock
|
||||||
|
|
|
@ -50,6 +50,7 @@ import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.DistributionId;
|
import org.whispersystems.signalservice.api.push.DistributionId;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.storage.StorageKey;
|
import org.whispersystems.signalservice.api.storage.StorageKey;
|
||||||
|
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -901,6 +902,30 @@ public class SignalAccount implements Closeable {
|
||||||
() -> messageSendLogStore = new MessageSendLogStore(getRecipientStore(), getAccountDatabase()));
|
() -> messageSendLogStore = new MessageSendLogStore(getRecipientStore(), getAccountDatabase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CredentialsProvider getCredentialsProvider() {
|
||||||
|
return new CredentialsProvider() {
|
||||||
|
@Override
|
||||||
|
public ACI getAci() {
|
||||||
|
return aci;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getE164() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public String getNumber() {
|
public String getNumber() {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue