本文整理汇总了Java中org.whispersystems.signalservice.api.crypto.UntrustedIdentityException类的典型用法代码示例。如果您正苦于以下问题:Java UntrustedIdentityException类的具体用法?Java UntrustedIdentityException怎么用?Java UntrustedIdentityException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UntrustedIdentityException类属于org.whispersystems.signalservice.api.crypto包,在下文中一共展示了UntrustedIdentityException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onRun
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret)
throws IOException, UntrustedIdentityException
{
RecipientPreferenceDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
SignalServiceMessageSender messageSender = messageSenderFactory.create();
BlockedReader reader = database.readerForBlocked(database.getBlocked());
List<String> blocked = new LinkedList<>();
Recipients recipients;
while ((recipients = reader.getNext()) != null) {
if (recipients.isSingleRecipient()) {
try {
blocked.add(Util.canonicalizeNumber(context, recipients.getPrimaryRecipient().getNumber()));
} catch (InvalidNumberException e) {
Log.w(TAG, e);
}
}
}
messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blocked)));
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:MultiDeviceBlockedUpdateJob.java
示例2: generateSingleContactUpdate
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void generateSingleContactUpdate(long recipientId)
throws IOException, UntrustedIdentityException, NetworkException
{
SignalServiceMessageSender messageSender = messageSenderFactory.create();
File contactDataFile = createTempFile("multidevice-contact-update");
try {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile));
Recipient recipient = RecipientFactory.getRecipientForId(context, recipientId, false);
out.write(new DeviceContact(recipient.getNumber(),
Optional.fromNullable(recipient.getName()),
getAvatar(recipient.getContactUri()),
Optional.fromNullable(recipient.getColor().serialize())));
out.close();
sendUpdate(messageSender, contactDataFile);
} finally {
if (contactDataFile != null) contactDataFile.delete();
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:23,代码来源:MultiDeviceContactUpdateJob.java
示例3: generateFullContactUpdate
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void generateFullContactUpdate()
throws IOException, UntrustedIdentityException, NetworkException
{
SignalServiceMessageSender messageSender = messageSenderFactory.create();
File contactDataFile = createTempFile("multidevice-contact-update");
try {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile));
Collection<ContactData> contacts = ContactAccessor.getInstance().getContactsWithPush(context);
for (ContactData contactData : contacts) {
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id));
String number = contactData.numbers.get(0).number;
Optional<String> name = Optional.fromNullable(contactData.name);
Optional<String> color = getColor(number);
out.write(new DeviceContact(number, name, getAvatar(contactUri), color));
}
out.close();
sendUpdate(messageSender, contactDataFile);
} finally {
if (contactDataFile != null) contactDataFile.delete();
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:MultiDeviceContactUpdateJob.java
示例4: sendUpdate
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile)
throws IOException, UntrustedIdentityException, NetworkException
{
if (contactsFile.length() > 0) {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
try {
messageSender.sendMessage(SignalServiceSyncMessage.forContacts(attachmentStream));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:19,代码来源:MultiDeviceContactUpdateJob.java
示例5: onRun
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.w(TAG, "Not multi device...");
return;
}
List<ReadMessage> readMessages = new LinkedList<>();
for (SerializableSyncMessageId messageId : messageIds) {
readMessages.add(new ReadMessage(messageId.sender, messageId.timestamp));
}
SignalServiceMessageSender messageSender = messageSenderFactory.create();
messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages));
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:MultiDeviceReadUpdateJob.java
示例6: sendMessage
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
/**
* Send a message to a single recipient.
*
* @param recipient The message's destination.
* @param message The message.
* @throws UntrustedIdentityException
* @throws IOException
*/
public void sendMessage(SignalServiceAddress recipient, SignalServiceDataMessage message)
throws UntrustedIdentityException, IOException
{
byte[] content = createMessageContent(message);
long timestamp = message.getTimestamp();
boolean silent = message.getGroupInfo().isPresent() && message.getGroupInfo().get().getType() == SignalServiceGroup.Type.REQUEST_INFO;
SendMessageResponse response = sendMessage(recipient, timestamp, content, true, silent);
if (response != null && response.getNeedsSync()) {
byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.of(recipient), timestamp);
sendMessage(localAddress, timestamp, syncMessage, false, false);
}
if (message.isEndSession()) {
store.deleteAllSessions(recipient.getNumber());
if (eventListener.isPresent()) {
eventListener.get().onSecurityEvent(recipient);
}
}
}
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:30,代码来源:SignalServiceMessageSender.java
示例7: getEncryptedMessages
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private OutgoingPushMessageList getEncryptedMessages(PushServiceSocket socket,
SignalServiceAddress recipient,
long timestamp,
byte[] plaintext,
boolean legacy,
boolean silent)
throws IOException, UntrustedIdentityException
{
List<OutgoingPushMessage> messages = new LinkedList<>();
if (!recipient.equals(localAddress)) {
messages.add(getEncryptedMessage(socket, recipient, SignalServiceAddress.DEFAULT_DEVICE_ID, plaintext, legacy, silent));
}
for (int deviceId : store.getSubDeviceSessions(recipient.getNumber())) {
messages.add(getEncryptedMessage(socket, recipient, deviceId, plaintext, legacy, silent));
}
return new OutgoingPushMessageList(recipient.getNumber(), timestamp, recipient.getRelay().orNull(), messages);
}
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:21,代码来源:SignalServiceMessageSender.java
示例8: onRun
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
try {
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.w(TAG, "Not multi device...");
return;
}
if (destination == null) {
Log.w(TAG, "No destination...");
return;
}
String canonicalDestination = Util.canonicalizeNumber(context, destination);
VerifiedMessage.VerifiedState verifiedState = getVerifiedState(verifiedStatus);
SignalServiceMessageSender messageSender = messageSenderFactory.create();
VerifiedMessage verifiedMessage = new VerifiedMessage(canonicalDestination, new IdentityKey(identityKey, 0), verifiedState, timestamp);
messageSender.sendMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
} catch (InvalidNumberException | InvalidKeyException e) {
throw new IOException(e);
}
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:24,代码来源:MultiDeviceVerifiedUpdateJob.java
示例9: sendUpdate
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile, boolean complete)
throws IOException, UntrustedIdentityException, NetworkException
{
if (contactsFile.length() > 0) {
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
try {
messageSender.sendMessage(SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, complete)));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:19,代码来源:MultiDeviceContactUpdateJob.java
示例10: trustIdentityVerified
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
/**
* Trust this the identity with this fingerprint
*
* @param name username of the identity
* @param fingerprint Fingerprint
*/
public boolean trustIdentityVerified(String name, byte[] fingerprint) {
List<JsonIdentityKeyStore.Identity> ids = signalProtocolStore.getIdentities(name);
if (ids == null) {
return false;
}
for (JsonIdentityKeyStore.Identity id : ids) {
if (!Arrays.equals(id.getIdentityKey().serialize(), fingerprint)) {
continue;
}
signalProtocolStore.saveIdentity(name, id.getIdentityKey(), TrustLevel.TRUSTED_VERIFIED);
try {
sendVerifiedMessage(name, id.getIdentityKey(), TrustLevel.TRUSTED_VERIFIED);
} catch (IOException | UntrustedIdentityException e) {
e.printStackTrace();
}
save();
return true;
}
return false;
}
开发者ID:AsamK,项目名称:signal-cli,代码行数:28,代码来源:Manager.java
示例11: trustIdentityVerifiedSafetyNumber
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
/**
* Trust this the identity with this safety number
*
* @param name username of the identity
* @param safetyNumber Safety number
*/
public boolean trustIdentityVerifiedSafetyNumber(String name, String safetyNumber) {
List<JsonIdentityKeyStore.Identity> ids = signalProtocolStore.getIdentities(name);
if (ids == null) {
return false;
}
for (JsonIdentityKeyStore.Identity id : ids) {
if (!safetyNumber.equals(computeSafetyNumber(name, id.getIdentityKey()))) {
continue;
}
signalProtocolStore.saveIdentity(name, id.getIdentityKey(), TrustLevel.TRUSTED_VERIFIED);
try {
sendVerifiedMessage(name, id.getIdentityKey(), TrustLevel.TRUSTED_VERIFIED);
} catch (IOException | UntrustedIdentityException e) {
e.printStackTrace();
}
save();
return true;
}
return false;
}
开发者ID:AsamK,项目名称:signal-cli,代码行数:28,代码来源:Manager.java
示例12: trustIdentityAllKeys
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
/**
* Trust all keys of this identity without verification
*
* @param name username of the identity
*/
public boolean trustIdentityAllKeys(String name) {
List<JsonIdentityKeyStore.Identity> ids = signalProtocolStore.getIdentities(name);
if (ids == null) {
return false;
}
for (JsonIdentityKeyStore.Identity id : ids) {
if (id.getTrustLevel() == TrustLevel.UNTRUSTED) {
signalProtocolStore.saveIdentity(name, id.getIdentityKey(), TrustLevel.TRUSTED_UNVERIFIED);
try {
sendVerifiedMessage(name, id.getIdentityKey(), TrustLevel.TRUSTED_UNVERIFIED);
} catch (IOException | UntrustedIdentityException e) {
e.printStackTrace();
}
}
}
save();
return true;
}
开发者ID:AsamK,项目名称:signal-cli,代码行数:24,代码来源:Manager.java
示例13: requestSyncGroups
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void requestSyncGroups() throws IOException {
SignalServiceProtos.SyncMessage.Request r = SignalServiceProtos.SyncMessage.Request.newBuilder().setType(SignalServiceProtos.SyncMessage.Request.Type.GROUPS).build();
SignalServiceSyncMessage message = SignalServiceSyncMessage.forRequest(new RequestMessage(r));
try {
sendSyncMessage(message);
} catch (UntrustedIdentityException e) {
e.printStackTrace();
}
}
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:10,代码来源:Manager.java
示例14: requestSyncContacts
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void requestSyncContacts() throws IOException {
SignalServiceProtos.SyncMessage.Request r = SignalServiceProtos.SyncMessage.Request.newBuilder().setType(SignalServiceProtos.SyncMessage.Request.Type.CONTACTS).build();
SignalServiceSyncMessage message = SignalServiceSyncMessage.forRequest(new RequestMessage(r));
try {
sendSyncMessage(message);
} catch (UntrustedIdentityException e) {
// TODO: save that this is untrusted?
e.printStackTrace();
}
}
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:11,代码来源:Manager.java
示例15: sendSyncMessage
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void sendSyncMessage(SignalServiceSyncMessage message)
throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceUrls, localIdentity.getToshiId(), localIdentity.getPassword(), signalProtocolStore, USER_AGENT, Optional.<SignalServiceMessagePipe>absent(), Optional.<SignalServiceMessageSender.EventListener>absent());
try {
messageSender.sendMessage(message);
} catch (UntrustedIdentityException e) {
// TODO: save that this is untrusted?
throw e;
}
}
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:11,代码来源:Manager.java
示例16: decryptMessage
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) throws NoSessionException, LegacyMessageException, InvalidVersionException, InvalidMessageException, DuplicateMessageException, InvalidKeyException, InvalidKeyIdException, org.whispersystems.libsignal.UntrustedIdentityException {
SignalServiceCipher cipher = new SignalServiceCipher(new SignalServiceAddress(wallet.getOwnerAddress()), signalProtocolStore);
try {
return cipher.decrypt(envelope);
} catch (org.whispersystems.libsignal.UntrustedIdentityException e) {
signalProtocolStore.saveIdentity(new SignalProtocolAddress(e.getName(), 1), e.getUntrustedIdentity());
return cipher.decrypt(envelope);
}
}
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:10,代码来源:Manager.java
示例17: sendGroups
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void sendGroups() throws IOException, UntrustedIdentityException {
File groupsFile = Util.createTempFile();
try {
try (OutputStream fos = new FileOutputStream(groupsFile)) {
DeviceGroupsOutputStream out = new DeviceGroupsOutputStream(fos);
for (GroupInfo record : groupStore.getGroups()) {
out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name),
new ArrayList<>(record.members), createGroupAvatarAttachment(record.groupId),
record.active));
}
}
if (groupsFile.exists() && groupsFile.length() > 0) {
try (FileInputStream groupsFileStream = new FileInputStream(groupsFile)) {
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
.withStream(groupsFileStream)
.withContentType("application/octet-stream")
.withLength(groupsFile.length())
.build();
sendSyncMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
}
}
} finally {
try {
Files.delete(groupsFile.toPath());
} catch (IOException e) {
System.out.println("Failed to delete temp file “" + groupsFile + "”: " + e.getMessage());
}
}
}
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:33,代码来源:Manager.java
示例18: sendContacts
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void sendContacts() throws IOException, UntrustedIdentityException {
File contactsFile = Util.createTempFile();
try {
try (OutputStream fos = new FileOutputStream(contactsFile)) {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(fos);
for (ContactInfo record : contactStore.getContacts()) {
out.write(new DeviceContact(record.number, Optional.fromNullable(record.name),
createContactAvatarAttachment(record.number), Optional.fromNullable(record.color),
Optional.absent()));
}
}
if (contactsFile.exists() && contactsFile.length() > 0) {
try (FileInputStream contactsFileStream = new FileInputStream(contactsFile)) {
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
// TODO: no idea if "false" is right here
sendSyncMessage(SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, false)));
}
}
} finally {
try {
Files.delete(contactsFile.toPath());
} catch (IOException e) {
System.out.println("Failed to delete temp file “" + contactsFile + "”: " + e.getMessage());
}
}
}
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:34,代码来源:Manager.java
示例19: sendUpdate
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile)
throws IOException, UntrustedIdentityException
{
FileInputStream contactsFileStream = new FileInputStream(contactsFile);
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
.withStream(contactsFileStream)
.withContentType("application/octet-stream")
.withLength(contactsFile.length())
.build();
messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:13,代码来源:MultiDeviceGroupUpdateJob.java
示例20: onRun
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; //导入依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupRecord record = groupDatabase.getGroup(groupId);
SignalServiceAttachment avatar = null;
if (record == null) {
Log.w(TAG, "No information for group record info request: " + new String(groupId));
return;
}
if (record.getAvatar() != null) {
avatar = SignalServiceAttachmentStream.newStreamBuilder()
.withContentType("image/jpeg")
.withStream(new ByteArrayInputStream(record.getAvatar()))
.withLength(record.getAvatar().length)
.build();
}
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE)
.withAvatar(avatar)
.withId(groupId)
.withMembers(record.getMembers())
.withName(record.getTitle())
.withOwner(record.getOwner())
.withAdmins(record.getAdmins())
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(groupContext)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:38,代码来源:PushGroupUpdateJob.java
注:本文中的org.whispersystems.signalservice.api.crypto.UntrustedIdentityException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论