本文整理汇总了Java中org.whispersystems.signalservice.api.SignalServiceAccountManager类的典型用法代码示例。如果您正苦于以下问题:Java SignalServiceAccountManager类的具体用法?Java SignalServiceAccountManager怎么用?Java SignalServiceAccountManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SignalServiceAccountManager类属于org.whispersystems.signalservice.api包,在下文中一共展示了SignalServiceAccountManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createManager
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public static SignalServiceAccountManager createManager(final Context context, String number, String password) {
if (new SignalServiceNetworkAccess(context).isCensored(number)) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
ProviderInstaller.installIfNeeded(context);
} catch (Throwable t) {
Log.w(TAG, t);
}
return null;
}
}.execute();
}
return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(number),
number, password, BuildConfig.USER_AGENT);
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:19,代码来源:AccountManagerFactory.java
示例2: handleVoiceRegistrationIntent
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
private void handleVoiceRegistrationIntent(Intent intent) {
markAsVerifying(true);
String number = intent.getStringExtra(NUMBER_EXTRA);
String password = intent.getStringExtra(PASSWORD_EXTRA);
String signalingKey = intent.getStringExtra(SIGNALING_KEY_EXTRA);
boolean supportsGcm = intent.getBooleanExtra(GCM_SUPPORTED_EXTRA, true);
try {
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(this, number, password);
handleCommonRegistration(accountManager, number, password, signalingKey, supportsGcm);
markAsVerified(number, password, signalingKey);
setState(new RegistrationState(RegistrationState.STATE_COMPLETE, number));
broadcastComplete(true);
} catch (UnsupportedOperationException uoe) {
Log.w("RegistrationService", uoe);
setState(new RegistrationState(RegistrationState.STATE_GCM_UNSUPPORTED, number));
broadcastComplete(false);
} catch (IOException e) {
Log.w("RegistrationService", e);
setState(new RegistrationState(RegistrationState.STATE_NETWORK_ERROR, number));
broadcastComplete(false);
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:RegistrationService.java
示例3: isPushDestination
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
private static boolean isPushDestination(Context context, String destination) {
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
try {
return directory.isSecureTextSupported(destination);
} catch (NotInDirectoryException e) {
try {
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(context);
Optional<ContactTokenDetails> registeredUser = accountManager.getContact(destination);
if (!registeredUser.isPresent()) {
registeredUser = Optional.of(new ContactTokenDetails());
registeredUser.get().setNumber(destination);
directory.setNumber(registeredUser.get(), false);
return false;
} else {
registeredUser.get().setNumber(destination);
directory.setNumber(registeredUser.get(), true);
return true;
}
} catch (IOException e1) {
Log.w(TAG, e1);
return false;
}
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:MessageSender.java
示例4: doInBackground
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
@Override
protected Integer doInBackground(Void... params) {
try {
Context context = getActivity();
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(context);
try {
accountManager.setGcmId(Optional.<String>absent());
} catch (AuthorizationFailedException e) {
Log.w(TAG, e);
}
if (!TextSecurePreferences.isGcmDisabled(context)) {
GoogleCloudMessaging.getInstance(context).unregister();
}
return SUCCESS;
} catch (IOException ioe) {
Log.w(TAG, ioe);
return NETWORK_ERROR;
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:23,代码来源:AdvancedPreferenceFragment.java
示例5: refreshDirectory
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public static @NonNull RefreshResult refreshDirectory(@NonNull Context context,
@NonNull SignalServiceAccountManager accountManager,
@NonNull String localNumber)
throws IOException
{
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
Set<String> eligibleContactNumbers = directory.getPushEligibleContactNumbers(localNumber);
List<ContactTokenDetails> activeTokens = accountManager.getContacts(eligibleContactNumbers);
if (activeTokens != null) {
for (ContactTokenDetails activeToken : activeTokens) {
eligibleContactNumbers.remove(activeToken.getNumber());
activeToken.setNumber(activeToken.getNumber());
}
directory.setNumbers(activeTokens, eligibleContactNumbers);
return updateContactsDatabase(context, localNumber, activeTokens, true);
}
return new RefreshResult(new LinkedList<String>(), false);
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:22,代码来源:DirectoryHelper.java
示例6: createManager
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public static SignalServiceAccountManager createManager(final Context context, String number, String password) {
if (new SignalServiceNetworkAccess(context).isCensored(number)) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
//NOGMS ProviderInstaller.installIfNeeded(context);
} catch (Throwable t) {
Log.w(TAG, t);
}
return null;
}
}.execute();
}
return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(number),
number, password, BuildConfig.USER_AGENT);
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:19,代码来源:AccountManagerFactory.java
示例7: handleCommonRegistration
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
private void handleCommonRegistration(SignalServiceAccountManager accountManager, String number, String password, String signalingKey, boolean supportsGcm)
throws IOException
{
setState(new RegistrationState(RegistrationState.STATE_GENERATING_KEYS, number));
Recipient self = RecipientFactory.getRecipientsFromString(this, number, false).getPrimaryRecipient();
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(this);
List<PreKeyRecord> records = PreKeyUtil.generatePreKeys(this);
SignedPreKeyRecord signedPreKey = PreKeyUtil.generateSignedPreKey(this, identityKey, true);
accountManager.setPreKeys(identityKey.getPublicKey(), signedPreKey, records);
setState(new RegistrationState(RegistrationState.STATE_GCM_REGISTERING, number));
TextSecurePreferences.setWebsocketRegistered(this, true);
DatabaseFactory.getIdentityDatabase(this).saveIdentity(self.getRecipientId(), identityKey.getPublicKey(), IdentityDatabase.VerifiedStatus.VERIFIED, true, System.currentTimeMillis(), true);
DirectoryHelper.refreshDirectory(this, accountManager, number);
DirectoryRefreshListener.schedule(this);
RotateSignedPreKeyListener.schedule(this);
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:21,代码来源:RegistrationService.java
示例8: doInBackground
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
@Override
protected Integer doInBackground(Void... params) {
try {
Context context = getActivity();
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(context);
try {
accountManager.setGcmId(Optional.<String>absent());
} catch (AuthorizationFailedException e) {
Log.w(TAG, e);
}
return SUCCESS;
} catch (IOException ioe) {
Log.w(TAG, ioe);
return NETWORK_ERROR;
}
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:19,代码来源:AdvancedPreferenceFragment.java
示例9: getQrCode
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public void getQrCode(Consumer<String> callback) {
executor.submit(new Runnable() {
@Override
public void run() {
try {
logger.debug("Creating QR code for provisioning");
temporaryPassword = SecretUtil.getSecret(18);
temporaryIdentity = KeyHelper.generateIdentityKeyPair();
accountManager = new SignalServiceAccountManager(SignalConstants.URL, new ResourceTrustStore(),
null, temporaryPassword, SignalConstants.USER_AGENT);
String uuid = accountManager.getNewDeviceUuid();
String publicKey = Base64.encodeBytesWithoutPadding(temporaryIdentity.getPublicKey().serialize());
String qrString = "tsdevice:/?uuid=" + URLEncoder.encode(uuid, "UTF-8") + "&pub_key="
+ URLEncoder.encode(publicKey, "UTF-8");
logger.debug("Content of qr code: {}", qrString);
String qrCode = QRCode.from(qrString).file().getAbsolutePath();
callback.accept(qrCode);
} catch (IOException | TimeoutException e) {
throw new RuntimeException("Networking error while creating provisioning QR code!", e);
}
}
});
}
开发者ID:Turakar,项目名称:Signal-JDesktop,代码行数:26,代码来源:SignalAccountHelper.java
示例10: finishDeviceLink
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public void finishDeviceLink(String deviceName) throws IOException, InvalidKeyException, TimeoutException, UserAlreadyExists {
signalingKey = Util.getSecret(52);
SignalServiceAccountManager.NewDeviceRegistrationReturn ret = accountManager.finishNewDeviceRegistration(signalProtocolStore.getIdentityKeyPair(), signalingKey, false, true, signalProtocolStore.getLocalRegistrationId(), deviceName);
deviceId = ret.getDeviceId();
username = ret.getNumber();
// TODO do this check before actually registering
if (userExists()) {
throw new UserAlreadyExists(username, getFileName());
}
signalProtocolStore = new JsonSignalProtocolStore(ret.getIdentity(), signalProtocolStore.getLocalRegistrationId());
registered = true;
refreshPreKeys();
requestSyncGroups();
requestSyncContacts();
save();
}
开发者ID:AsamK,项目名称:signal-cli,代码行数:20,代码来源:Manager.java
示例11: init
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public void init() throws IOException {
this.storage.migrateLegacyConfigs();
boolean refreshKeys = false;
// load the identity
this.localIdentity = this.storage.getLocalIdentityStore().loadLocalIdentity(wallet.getOwnerAddress());
if (this.localIdentity == null) {
// if none was loaded, create a new identity
createNewIdentity();
refreshKeys = true;
}
// set up stores
groupStore = this.storage.getGroupStore();
threadStore = this.storage.getThreadStore();
contactStore = this.storage.getContactStore();
signalProtocolStore = this.storage.getSignalProtocolStore(this.localIdentity.getIdentityKeyPair(),
this.localIdentity.getRegistrationId());
accountManager = new SignalServiceAccountManager(serviceUrls, localIdentity.getToshiId(),
this.localIdentity.getPassword(),
USER_AGENT);
// do key refresh
try {
if (localIdentity.isRegistered()) {
if (refreshKeys || accountManager.getPreKeysCount() < PREKEY_MINIMUM_COUNT) {
refreshPreKeys();
}
}
} catch (AuthorizationFailedException e) {
System.err.println("Authorization failed, was the number registered elsewhere?");
}
}
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:35,代码来源:Manager.java
示例12: handleCommonRegistration
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
private void handleCommonRegistration(SignalServiceAccountManager accountManager, String number, String password, String signalingKey, boolean supportsGcm)
throws IOException
{
setState(new RegistrationState(RegistrationState.STATE_GENERATING_KEYS, number));
Recipient self = RecipientFactory.getRecipientsFromString(this, number, false).getPrimaryRecipient();
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(this);
List<PreKeyRecord> records = PreKeyUtil.generatePreKeys(this);
PreKeyRecord lastResort = PreKeyUtil.generateLastResortKey(this);
SignedPreKeyRecord signedPreKey = PreKeyUtil.generateSignedPreKey(this, identityKey, true);
accountManager.setPreKeys(identityKey.getPublicKey(),lastResort, signedPreKey, records);
setState(new RegistrationState(RegistrationState.STATE_GCM_REGISTERING, number));
if (supportsGcm) {
String gcmRegistrationId = GoogleCloudMessaging.getInstance(this).register(GcmRefreshJob.REGISTRATION_ID);
accountManager.setGcmId(Optional.of(gcmRegistrationId));
TextSecurePreferences.setGcmRegistrationId(this, gcmRegistrationId);
TextSecurePreferences.setGcmDisabled(this, false);
} else {
TextSecurePreferences.setGcmDisabled(this, true);
}
TextSecurePreferences.setWebsocketRegistered(this, true);
DatabaseFactory.getIdentityDatabase(this).saveIdentity(self.getRecipientId(), identityKey.getPublicKey());
DirectoryHelper.refreshDirectory(this, accountManager, number);
DirectoryRefreshListener.schedule(this);
RotateSignedPreKeyListener.schedule(this);
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:32,代码来源:RegistrationService.java
示例13: refreshDirectoryFor
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public static UserCapabilities refreshDirectoryFor(@NonNull Context context,
@Nullable MasterSecret masterSecret,
@NonNull Recipients recipients,
@NonNull String localNumber)
throws IOException
{
try {
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(context);
String number = Util.canonicalizeNumber(context, recipients.getPrimaryRecipient().getNumber());
Optional<ContactTokenDetails> details = accountManager.getContact(number);
if (details.isPresent()) {
directory.setNumber(details.get(), true);
RefreshResult result = updateContactsDatabase(context, localNumber, details.get());
if (!result.getNewUsers().isEmpty() && TextSecurePreferences.isMultiDevice(context)) {
ApplicationContext.getInstance(context).getJobManager().add(new MultiDeviceContactUpdateJob(context));
}
if (!result.isFresh()) {
notifyNewUsers(context, masterSecret, result.getNewUsers());
}
return new UserCapabilities(Capability.SUPPORTED,
details.get().isVoice() ? Capability.SUPPORTED : Capability.UNSUPPORTED,
details.get().isVideo() ? Capability.SUPPORTED : Capability.UNSUPPORTED);
} else {
ContactTokenDetails absent = new ContactTokenDetails();
absent.setNumber(number);
directory.setNumber(absent, false);
return UserCapabilities.UNSUPPORTED;
}
} catch (InvalidNumberException e) {
Log.w(TAG, e);
return UserCapabilities.UNSUPPORTED;
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:40,代码来源:DirectoryHelper.java
示例14: handleVoiceRegistrationIntent
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
private void handleVoiceRegistrationIntent(Intent intent) {
markAsVerifying(true);
String number = intent.getStringExtra(NUMBER_EXTRA);
String password = intent.getStringExtra(PASSWORD_EXTRA);
String signalingKey = intent.getStringExtra(SIGNALING_KEY_EXTRA);
boolean supportsGcm = false;
try {
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(this, number, password);
handleCommonRegistration(accountManager, number, password, signalingKey, supportsGcm);
markAsVerified(number, password, signalingKey);
setState(new RegistrationState(RegistrationState.STATE_COMPLETE, number));
broadcastComplete(true);
} catch (UnsupportedOperationException uoe) {
Log.w("RegistrationService", uoe);
setState(new RegistrationState(RegistrationState.STATE_GCM_UNSUPPORTED, number));
broadcastComplete(false);
} catch (IOException e) {
Log.w("RegistrationService", e);
setState(new RegistrationState(RegistrationState.STATE_NETWORK_ERROR, number));
broadcastComplete(false);
}
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:28,代码来源:RegistrationService.java
示例15: SignalService
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
/**
* Create a new instance. Will automatically load a store file if existent.
* @throws IOException can be thrown while loading the store
*/
public SignalService() throws IOException {
// Add bouncycastle
Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 1);
File storeFile = new File(STORE_PATH);
if(storeFile.isFile()) {
store = JsonSignalStore.load(storeFile);
accountManager = new SignalServiceAccountManager(store.getUrl(), trustStore, store.getPhoneNumber(),
store.getPassword(), store.getDeviceId(), store.getUserAgent());
} else {
store = new JsonSignalStore();
}
}
开发者ID:Turakar,项目名称:signal4j,代码行数:18,代码来源:SignalService.java
示例16: init
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public void init() throws IOException {
load();
migrateLegacyConfigs();
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, deviceId, USER_AGENT);
try {
if (registered && accountManager.getPreKeysCount() < PREKEY_MINIMUM_COUNT) {
refreshPreKeys();
save();
}
} catch (AuthorizationFailedException e) {
System.err.println("Authorization failed, was the number registered elsewhere?");
}
}
开发者ID:AsamK,项目名称:signal-cli,代码行数:16,代码来源:Manager.java
示例17: register
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public void register(boolean voiceVerification) throws IOException {
password = Util.getSecret(18);
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT);
if (voiceVerification)
accountManager.requestVoiceVerificationCode();
else
accountManager.requestSmsVerificationCode();
registered = false;
save();
}
开发者ID:AsamK,项目名称:signal-cli,代码行数:14,代码来源:Manager.java
示例18: getDeviceLinkUri
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public URI getDeviceLinkUri() throws TimeoutException, IOException {
password = Util.getSecret(18);
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT);
String uuid = accountManager.getNewDeviceUuid();
registered = false;
try {
return new URI("tsdevice:/?uuid=" + URLEncoder.encode(uuid, "utf-8") + "&pub_key=" + URLEncoder.encode(Base64.encodeBytesWithoutPadding(signalProtocolStore.getIdentityKeyPair().getPublicKey().serialize()), "utf-8"));
} catch (URISyntaxException e) {
// Shouldn't happen
return null;
}
}
开发者ID:AsamK,项目名称:signal-cli,代码行数:15,代码来源:Manager.java
示例19: DeviceListLoader
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
public DeviceListLoader(Context context, SignalServiceAccountManager accountManager) {
super(context);
this.accountManager = accountManager;
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:5,代码来源:DeviceListLoader.java
示例20: handleSmsRegistrationIntent
import org.whispersystems.signalservice.api.SignalServiceAccountManager; //导入依赖的package包/类
private void handleSmsRegistrationIntent(Intent intent) {
markAsVerifying(true);
String number = intent.getStringExtra(NUMBER_EXTRA);
boolean supportsGcm = intent.getBooleanExtra(GCM_SUPPORTED_EXTRA, true);
int registrationId = TextSecurePreferences.getLocalRegistrationId(this);
boolean supportsVideo = TextSecurePreferences.isWebrtcCallingEnabled(this) || !supportsGcm;
if (registrationId == 0) {
registrationId = KeyHelper.generateRegistrationId(false);
TextSecurePreferences.setLocalRegistrationId(this, registrationId);
}
String password = Util.getSecret(18);
String signalingKey = Util.getSecret(52);
try {
initializeChallengeListener();
setState(new RegistrationState(RegistrationState.STATE_CONNECTING, number));
SignalServiceAccountManager accountManager = AccountManagerFactory.createManager(this, number, password);
accountManager.requestSmsVerificationCode();
setState(new RegistrationState(RegistrationState.STATE_VERIFYING, number));
String challenge = waitForChallenge();
accountManager.verifyAccountWithCode(challenge, signalingKey, registrationId, true, supportsVideo, !supportsGcm);
handleCommonRegistration(accountManager, number, password, signalingKey, supportsGcm);
markAsVerified(number, password, signalingKey);
setState(new RegistrationState(RegistrationState.STATE_COMPLETE, number));
broadcastComplete(true);
} catch (ExpectationFailedException efe) {
Log.w("RegistrationService", efe);
setState(new RegistrationState(RegistrationState.STATE_MULTI_REGISTERED, number));
broadcastComplete(false);
} catch (UnsupportedOperationException uoe) {
Log.w("RegistrationService", uoe);
setState(new RegistrationState(RegistrationState.STATE_GCM_UNSUPPORTED, number));
broadcastComplete(false);
} catch (AccountVerificationTimeoutException avte) {
Log.w("RegistrationService", avte);
setState(new RegistrationState(RegistrationState.STATE_TIMEOUT, number, password));
broadcastComplete(false);
} catch (IOException e) {
Log.w("RegistrationService", e);
setState(new RegistrationState(RegistrationState.STATE_NETWORK_ERROR, number));
broadcastComplete(false);
} finally {
shutdownChallengeListener();
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:53,代码来源:RegistrationService.java
注:本文中的org.whispersystems.signalservice.api.SignalServiceAccountManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论