use of net.java.otr4j.crypto.OtrCryptoException in project Zom-Android by zom.
the class OtrKeyManagerDefaultImpl method getLocalFingerprint.
public String getLocalFingerprint(SessionID sessionID) {
KeyPair keyPair = loadLocalKeyPair(sessionID);
if (keyPair == null)
return null;
PublicKey pubKey = keyPair.getPublic();
try {
return new OtrCryptoEngineImpl().getFingerprint(pubKey);
} catch (OtrCryptoException e) {
e.printStackTrace();
return null;
}
}
use of net.java.otr4j.crypto.OtrCryptoException in project Zom-Android by zom.
the class OtrAndroidKeyManagerImpl method getRemoteFingerprint.
public String getRemoteFingerprint(String fullUserId) {
String fingerprint = this.store.getProperty(fullUserId + ".fingerprint");
if (fingerprint != null) {
// If we have a fingerprint stashed, assume it is correct.
return fingerprint;
}
// if we can't find an exact match, let's show the first one that matches the id sans resource
for (Object fpKey : store.getKeySet().toArray()) {
String fpKeyString = (String) fpKey;
if (fpKeyString.startsWith(fullUserId) && fpKeyString.endsWith(".fingerprint")) {
fingerprint = store.getProperty(fpKeyString);
if (fingerprint != null)
return fingerprint;
}
}
PublicKey remotePublicKey = loadRemotePublicKeyFromStore(fullUserId);
if (remotePublicKey == null)
return null;
try {
// Store the fingerprint, for posterity.
String fingerprintString = new OtrCryptoEngineImpl().getFingerprint(remotePublicKey);
this.store.setProperty(fullUserId + ".fingerprint", fingerprintString);
return fingerprintString;
} catch (OtrCryptoException e) {
throw new RuntimeException("OtrCryptoException getting remote fingerprint", e);
}
}
use of net.java.otr4j.crypto.OtrCryptoException in project Pix-Art-Messenger by kriztan.
the class Account method getOtrFingerprint.
public String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {
if (this.mOtrService == null) {
return null;
}
final PublicKey publicKey = this.mOtrService.getPublicKey();
if (publicKey == null || !(publicKey instanceof DSAPublicKey)) {
return null;
}
this.otrFingerprint = new OtrCryptoEngineImpl().getFingerprint(publicKey).toLowerCase(Locale.US);
return this.otrFingerprint;
} catch (final OtrCryptoException ignored) {
return null;
}
} else {
return this.otrFingerprint;
}
}
use of net.java.otr4j.crypto.OtrCryptoException in project Pix-Art-Messenger by kriztan.
the class Conversation method getOtrFingerprint.
public synchronized String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {
if (getOtrSession() == null || getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
return null;
}
DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey();
this.otrFingerprint = getAccount().getOtrService().getFingerprint(remotePubKey).toLowerCase(Locale.US);
} catch (final OtrCryptoException | UnsupportedOperationException ignored) {
return null;
}
}
return this.otrFingerprint;
}
Aggregations