本文整理汇总了Java中org.whispersystems.libsignal.InvalidMessageException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidMessageException类的具体用法?Java InvalidMessageException怎么用?Java InvalidMessageException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidMessageException类属于org.whispersystems.libsignal包,在下文中一共展示了InvalidMessageException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDecryptedBody
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private @Nullable String getDecryptedBody(@NonNull MasterSecret masterSecret,
@Nullable String body, long outboxType)
{
try {
if (!TextUtils.isEmpty(body) && Types.isSymmetricEncryption(outboxType)) {
MasterCipher masterCipher = new MasterCipher(masterSecret);
return masterCipher.decryptBody(body);
} else {
return body;
}
} catch (InvalidMessageException e) {
Log.w(TAG, e);
}
return null;
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:MmsDatabase.java
示例2: getBody
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private DisplayRecord.Body getBody(Cursor cursor) {
try {
String body = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.BODY));
long box = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX));
if (!TextUtils.isEmpty(body) && masterCipher != null && Types.isSymmetricEncryption(box)) {
return new DisplayRecord.Body(masterCipher.decryptBody(body), true);
} else if (!TextUtils.isEmpty(body) && masterCipher == null && Types.isSymmetricEncryption(box)) {
return new DisplayRecord.Body(body, false);
} else if (!TextUtils.isEmpty(body) && Types.isAsymmetricEncryption(box)) {
return new DisplayRecord.Body(body, false);
} else {
return new DisplayRecord.Body(body == null ? "" : body, true);
}
} catch (InvalidMessageException e) {
Log.w("MmsDatabase", e);
return new DisplayRecord.Body(context.getString(R.string.MmsDatabase_error_decrypting_message), true);
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:MmsDatabase.java
示例3: getDrafts
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
public List<Draft> getDrafts(MasterCipher masterCipher, long threadId) {
SQLiteDatabase db = databaseHelper.getReadableDatabase();
List<Draft> results = new LinkedList<Draft>();
Cursor cursor = null;
try {
cursor = db.query(TABLE_NAME, null, THREAD_ID + " = ?", new String[] {threadId+""}, null, null, null);
while (cursor != null && cursor.moveToNext()) {
try {
String encryptedType = cursor.getString(cursor.getColumnIndexOrThrow(DRAFT_TYPE));
String encryptedValue = cursor.getString(cursor.getColumnIndexOrThrow(DRAFT_VALUE));
results.add(new Draft(masterCipher.decryptBody(encryptedType),
masterCipher.decryptBody(encryptedValue)));
} catch (InvalidMessageException ime) {
Log.w("DraftDatabase", ime);
}
}
return results;
} finally {
if (cursor != null)
cursor.close();
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:DraftDatabase.java
示例4: getPlaintextBody
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private DisplayRecord.Body getPlaintextBody(Cursor cursor) {
try {
long type = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET_TYPE));
String body = cursor.getString(cursor.getColumnIndexOrThrow(SNIPPET));
if (!TextUtils.isEmpty(body) && masterCipher != null && MmsSmsColumns.Types.isSymmetricEncryption(type)) {
return new DisplayRecord.Body(masterCipher.decryptBody(body), true);
} else if (!TextUtils.isEmpty(body) && masterCipher == null && MmsSmsColumns.Types.isSymmetricEncryption(type)) {
return new DisplayRecord.Body(body, false);
} else {
return new DisplayRecord.Body(body, true);
}
} catch (InvalidMessageException e) {
Log.w("ThreadDatabase", e);
return new DisplayRecord.Body(context.getString(R.string.ThreadDatabase_error_decrypting_message), true);
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:ThreadDatabase.java
示例5: verifyMacBody
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private byte[] verifyMacBody(@NonNull Mac hmac, @NonNull byte[] encryptedAndMac) throws InvalidMessageException {
if (encryptedAndMac.length < hmac.getMacLength()) {
throw new InvalidMessageException("length(encrypted body + MAC) < length(MAC)");
}
byte[] encrypted = new byte[encryptedAndMac.length - hmac.getMacLength()];
System.arraycopy(encryptedAndMac, 0, encrypted, 0, encrypted.length);
byte[] remoteMac = new byte[hmac.getMacLength()];
System.arraycopy(encryptedAndMac, encryptedAndMac.length - remoteMac.length, remoteMac, 0, remoteMac.length);
byte[] localMac = hmac.doFinal(encrypted);
if (!Arrays.equals(remoteMac, localMac))
throw new InvalidMessageException("MAC doesen't match.");
return encrypted;
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:19,代码来源:MasterCipher.java
示例6: loadSignedPreKeys
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
@Override
public List<SignedPreKeyRecord> loadSignedPreKeys() {
synchronized (FILE_LOCK) {
File directory = getSignedPreKeyDirectory();
List<SignedPreKeyRecord> results = new LinkedList<>();
for (File signedPreKeyFile : directory.listFiles()) {
try {
if (!"index.dat".equals(signedPreKeyFile.getName())) {
results.add(new SignedPreKeyRecord(loadSerializedRecord(signedPreKeyFile)));
}
} catch (IOException | InvalidMessageException e) {
Log.w(TAG, e);
}
}
return results;
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:TextSecurePreKeyStore.java
示例7: loadSerializedRecord
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private byte[] loadSerializedRecord(File recordFile)
throws IOException, InvalidMessageException
{
FileInputStream fin = new FileInputStream(recordFile);
int recordVersion = readInteger(fin);
if (recordVersion > CURRENT_VERSION_MARKER) {
throw new AssertionError("Invalid version: " + recordVersion);
}
byte[] serializedRecord = readBlob(fin);
if (recordVersion < PLAINTEXT_VERSION && masterSecret != null) {
MasterCipher masterCipher = new MasterCipher(masterSecret);
serializedRecord = masterCipher.decryptBytes(serializedRecord);
} else if (recordVersion < PLAINTEXT_VERSION) {
throw new AssertionError("Migration didn't happen!");
}
fin.close();
return serializedRecord;
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:23,代码来源:TextSecurePreKeyStore.java
示例8: deserialize
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
@Override
public Job deserialize(EncryptionKeys keys, boolean encrypted, String serialized) throws IOException {
try {
String plaintext;
if (encrypted) {
MasterSecret masterSecret = ParcelUtil.deserialize(keys.getEncoded(), MasterSecret.CREATOR);
MasterCipher masterCipher = new MasterCipher(masterSecret);
plaintext = masterCipher.decryptBody(serialized);
} else {
plaintext = serialized;
}
return delegate.deserialize(keys, encrypted, plaintext);
} catch (InvalidMessageException e) {
throw new IOException(e);
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:19,代码来源:EncryptingJobSerializer.java
示例9: decrypt
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private byte[] decrypt(SignalServiceEnvelope envelope, byte[] ciphertext)
throws InvalidVersionException, InvalidMessageException, InvalidKeyException,
DuplicateMessageException, InvalidKeyIdException, UntrustedIdentityException,
LegacyMessageException, NoSessionException
{
SignalProtocolAddress sourceAddress = new SignalProtocolAddress(envelope.getSource(), envelope.getSourceDevice());
SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, sourceAddress);
byte[] paddedMessage;
if (envelope.isPreKeySignalMessage()) {
paddedMessage = sessionCipher.decrypt(new PreKeySignalMessage(ciphertext));
} else if (envelope.isSignalMessage()) {
paddedMessage = sessionCipher.decrypt(new SignalMessage(ciphertext));
} else {
throw new InvalidMessageException("Unknown type: " + envelope.getType());
}
PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
return transportDetails.getStrippedPaddingMessageBody(paddedMessage);
}
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:22,代码来源:SignalServiceCipher.java
示例10: tryFetchLatestMessage
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
@WorkerThread
private IncomingMessage tryFetchLatestMessage() throws TimeoutException {
if (this.messagePipe == null) {
this.messagePipe = messageReceiver.createMessagePipe();
}
try {
final SignalServiceEnvelope envelope = messagePipe.read(INCOMING_MESSAGE_TIMEOUT, TimeUnit.SECONDS);
return decryptIncomingSignalServiceEnvelope(envelope);
} catch (final TimeoutException ex) {
throw new TimeoutException(ex.getMessage());
} catch (final IllegalStateException | InvalidKeyException | InvalidKeyIdException | DuplicateMessageException | InvalidVersionException | LegacyMessageException | InvalidMessageException | NoSessionException | org.whispersystems.libsignal.UntrustedIdentityException | IOException e) {
LogUtil.exception(getClass(), "Error while fetching latest message", e);
}
return null;
}
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:17,代码来源:SofaMessageReceiver.java
示例11: handleIncomingSofaMessage
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private IncomingMessage handleIncomingSofaMessage(final SignalServiceEnvelope envelope) throws InvalidVersionException, InvalidMessageException, InvalidKeyException, DuplicateMessageException, InvalidKeyIdException, org.whispersystems.libsignal.UntrustedIdentityException, LegacyMessageException, NoSessionException {
final SignalServiceAddress localAddress = new SignalServiceAddress(this.wallet.getOwnerAddress());
final SignalServiceCipher cipher = new SignalServiceCipher(localAddress, this.protocolStore);
final SignalServiceContent content = cipher.decrypt(envelope);
final String messageSource = envelope.getSource();
if (isUserBlocked(messageSource)) {
LogUtil.i(getClass(), "A blocked user is trying to send a message");
return null;
}
if (content.getDataMessage().isPresent()) {
final SignalServiceDataMessage dataMessage = content.getDataMessage().get();
if (dataMessage.isGroupUpdate()) return taskGroupUpdate.run(messageSource, dataMessage);
else return taskHandleMessage.run(messageSource, dataMessage);
}
return null;
}
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:19,代码来源:SofaMessageReceiver.java
示例12: loadSignedPreKeys
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
@Override
public List<SignedPreKeyRecord> loadSignedPreKeys() {
synchronized (FILE_LOCK) {
File directory = getSignedPreKeyDirectory();
List<SignedPreKeyRecord> results = new LinkedList<>();
for (File signedPreKeyFile : directory.listFiles()) {
try {
results.add(new SignedPreKeyRecord(loadSerializedRecord(signedPreKeyFile)));
} catch (IOException | InvalidMessageException e) {
LogUtil.w(getClass(), e.getMessage());
}
}
return results;
}
}
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:18,代码来源:SignalPreKeyStore.java
示例13: loadSerializedRecord
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private byte[] loadSerializedRecord(File recordFile) throws IOException, InvalidMessageException {
FileInputStream fin = new FileInputStream(recordFile);
int recordVersion = readInteger(fin);
if (recordVersion > CURRENT_VERSION_MARKER) {
throw new AssertionError("Invalid version: " + recordVersion);
}
byte[] serializedRecord = readBlob(fin);
if (recordVersion < PLAINTEXT_VERSION) {
throw new AssertionError("Migration didn't happen!");
}
fin.close();
return serializedRecord;
}
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:18,代码来源:SignalPreKeyStore.java
示例14: writeAttachmentToFileFromMessageReceiver
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private @Nullable static File writeAttachmentToFileFromMessageReceiver(
final SignalServiceAttachmentPointer attachment,
final SignalServiceMessageReceiver messageReceiver,
final String fileId) {
File file = null;
try {
final String tempName = String.format("%d", attachment.getId());
file = new File(BaseApplication.get().getCacheDir(), tempName);
final int maxFileSize = 20 * 1024 * 1024;
final InputStream inputStream = messageReceiver.retrieveAttachment(attachment, file, maxFileSize);
final File destFile = constructAttachmentFile(attachment.getContentType(), fileId);
return writeToFileFromInputStream(destFile, inputStream);
} catch (IOException | InvalidMessageException e) {
LogUtil.exception(FileUtil.class, "Error during writing attachment to file", e);
return null;
} finally {
if (file != null) {
file.delete();
}
}
}
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:23,代码来源:FileUtil.java
示例15: getBody
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private DisplayRecord.Body getBody(Cursor cursor) {
try {
String body = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.BODY));
long box = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX));
if (!TextUtils.isEmpty(body) && masterCipher != null && Types.isSymmetricEncryption(box)) {
return new DisplayRecord.Body(masterCipher.decryptBody(body), true);
} else if (!TextUtils.isEmpty(body) && masterCipher == null && Types.isSymmetricEncryption(box)) {
return new DisplayRecord.Body(body, false);
} else {
return new DisplayRecord.Body(body == null ? "" : body, true);
}
} catch (InvalidMessageException e) {
Log.w("MmsDatabase", e);
return new DisplayRecord.Body(context.getString(R.string.MmsDatabase_error_decrypting_message), true);
}
}
开发者ID:SilenceIM,项目名称:Silence,代码行数:18,代码来源:MmsDatabase.java
示例16: getPlaintextBody
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
private DisplayRecord.Body getPlaintextBody(Cursor cursor) {
try {
long type = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET_TYPE));
String body = cursor.getString(cursor.getColumnIndexOrThrow(SNIPPET));
if (!TextUtils.isEmpty(body) && masterCipher != null && MmsSmsColumns.Types.isSymmetricEncryption(type)) {
return new DisplayRecord.Body(masterCipher.decryptBody(body), true);
} else if (!TextUtils.isEmpty(body) && masterCipher == null && MmsSmsColumns.Types.isSymmetricEncryption(type)) {
return new DisplayRecord.Body(body, false);
} else {
return new DisplayRecord.Body(body, true);
}
} catch (InvalidMessageException e) {
Log.w("ThreadDatabase", e);
return new DisplayRecord.Body(context.getString(R.string.EncryptingSmsDatabase_error_decrypting_message), true);
}
}
开发者ID:SilenceIM,项目名称:Silence,代码行数:18,代码来源:ThreadDatabase.java
示例17: decrypt
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
public IncomingTextMessage decrypt(Context context, IncomingTextMessage message)
throws LegacyMessageException, InvalidMessageException,
DuplicateMessageException, NoSessionException
{
try {
byte[] decoded = transportDetails.getDecodedMessage(message.getMessageBody().getBytes());
SignalMessage signalMessage = new SignalMessage(decoded);
SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, new SignalProtocolAddress(message.getSender(), 1));
byte[] padded = sessionCipher.decrypt(signalMessage);
byte[] plaintext = transportDetails.getStrippedPaddingMessageBody(padded);
if (message.isEndSession() && "TERMINATE".equals(new String(plaintext))) {
signalProtocolStore.deleteSession(new SignalProtocolAddress(message.getSender(), 1));
}
return message.withMessageBody(new String(plaintext));
} catch (IOException | IllegalArgumentException | NullPointerException e) {
throw new InvalidMessageException(e);
}
}
开发者ID:SilenceIM,项目名称:Silence,代码行数:21,代码来源:SmsCipher.java
示例18: process
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
public OutgoingKeyExchangeMessage process(Context context, IncomingKeyExchangeMessage message)
throws UntrustedIdentityException, StaleKeyExchangeException,
InvalidVersionException, LegacyMessageException, InvalidMessageException
{
try {
Recipients recipients = RecipientFactory.getRecipientsFromString(context, message.getSender(), false);
SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(message.getSender(), 1);
KeyExchangeMessage exchangeMessage = new KeyExchangeMessage(transportDetails.getDecodedMessage(message.getMessageBody().getBytes()));
SessionBuilder sessionBuilder = new SessionBuilder(signalProtocolStore, signalProtocolAddress);
KeyExchangeMessage response = sessionBuilder.process(exchangeMessage);
if (response != null) {
byte[] serializedResponse = transportDetails.getEncodedMessage(response.serialize());
return new OutgoingKeyExchangeMessage(recipients, new String(serializedResponse), message.getSubscriptionId());
} else {
return null;
}
} catch (IOException | InvalidKeyException e) {
throw new InvalidMessageException(e);
}
}
开发者ID:SilenceIM,项目名称:Silence,代码行数:23,代码来源:SmsCipher.java
示例19: decryptBody
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
public String decryptBody(String body) throws IOException, InvalidMessageException {
try {
byte[] combined = Base64.decode(body);
byte[][] parts = Util.split(combined, PublicKey.KEY_SIZE, combined.length - PublicKey.KEY_SIZE);
PublicKey theirPublicKey = new PublicKey(parts[0], 0);
ECPrivateKey ourPrivateKey = asymmetricMasterSecret.getPrivateKey();
byte[] secret = Curve.calculateAgreement(theirPublicKey.getKey(), ourPrivateKey);
MasterCipher masterCipher = getMasterCipherForSecret(secret);
byte[] decryptedBody = masterCipher.decryptBytes(parts[1]);
return new String(decryptedBody);
} catch (InvalidKeyException | InvalidMessageException ike) {
throw new InvalidMessageException(ike);
}
}
开发者ID:SilenceIM,项目名称:Silence,代码行数:17,代码来源:AsymmetricMasterCipher.java
示例20: loadSignedPreKeys
import org.whispersystems.libsignal.InvalidMessageException; //导入依赖的package包/类
@Override
public List<SignedPreKeyRecord> loadSignedPreKeys() {
synchronized (FILE_LOCK) {
File directory = getSignedPreKeyDirectory();
List<SignedPreKeyRecord> results = new LinkedList<>();
for (File signedPreKeyFile : directory.listFiles()) {
try {
results.add(new SignedPreKeyRecord(loadSerializedRecord(signedPreKeyFile)));
} catch (IOException | InvalidMessageException e) {
Log.w(TAG, e);
}
}
return results;
}
}
开发者ID:SilenceIM,项目名称:Silence,代码行数:18,代码来源:SilencePreKeyStore.java
注:本文中的org.whispersystems.libsignal.InvalidMessageException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论