Clean up logging
Add a fixed prefix to axolotl-related log messages, set log levels sensibly.
This commit is contained in:
parent
7049904c32
commit
3458f5bb91
|
@ -61,6 +61,8 @@ public class AxolotlService {
|
||||||
public static final String PEP_DEVICE_LIST = PEP_PREFIX + ".devicelist";
|
public static final String PEP_DEVICE_LIST = PEP_PREFIX + ".devicelist";
|
||||||
public static final String PEP_BUNDLES = PEP_PREFIX + ".bundles";
|
public static final String PEP_BUNDLES = PEP_PREFIX + ".bundles";
|
||||||
|
|
||||||
|
public static final String LOGPREFIX = "AxolotlService";
|
||||||
|
|
||||||
public static final int NUM_KEYS_TO_PUBLISH = 10;
|
public static final int NUM_KEYS_TO_PUBLISH = 10;
|
||||||
|
|
||||||
private final Account account;
|
private final Account account;
|
||||||
|
@ -100,7 +102,7 @@ public class AxolotlService {
|
||||||
|
|
||||||
|
|
||||||
private static IdentityKeyPair generateIdentityKeyPair() {
|
private static IdentityKeyPair generateIdentityKeyPair() {
|
||||||
Log.d(Config.LOGTAG, "Generating axolotl IdentityKeyPair...");
|
Log.i(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Generating axolotl IdentityKeyPair...");
|
||||||
ECKeyPair identityKeyPairKeys = Curve.generateKeyPair();
|
ECKeyPair identityKeyPairKeys = Curve.generateKeyPair();
|
||||||
IdentityKeyPair ownKey = new IdentityKeyPair(new IdentityKey(identityKeyPairKeys.getPublicKey()),
|
IdentityKeyPair ownKey = new IdentityKeyPair(new IdentityKey(identityKeyPairKeys.getPublicKey()),
|
||||||
identityKeyPairKeys.getPrivateKey());
|
identityKeyPairKeys.getPrivateKey());
|
||||||
|
@ -108,7 +110,7 @@ public class AxolotlService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int generateRegistrationId() {
|
private static int generateRegistrationId() {
|
||||||
Log.d(Config.LOGTAG, "Generating axolotl registration ID...");
|
Log.i(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Generating axolotl registration ID...");
|
||||||
int reg_id = KeyHelper.generateRegistrationId(false);
|
int reg_id = KeyHelper.generateRegistrationId(false);
|
||||||
return reg_id;
|
return reg_id;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +121,7 @@ public class AxolotlService {
|
||||||
this.localRegistrationId = loadRegistrationId();
|
this.localRegistrationId = loadRegistrationId();
|
||||||
this.currentPreKeyId = loadCurrentPreKeyId();
|
this.currentPreKeyId = loadCurrentPreKeyId();
|
||||||
for (SignedPreKeyRecord record : loadSignedPreKeys()) {
|
for (SignedPreKeyRecord record : loadSignedPreKeys()) {
|
||||||
Log.d(Config.LOGTAG, "Got Axolotl signed prekey record:" + record.getId());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Got Axolotl signed prekey record:" + record.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +141,7 @@ public class AxolotlService {
|
||||||
if (ownKey != null) {
|
if (ownKey != null) {
|
||||||
return ownKey;
|
return ownKey;
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "Could not retrieve axolotl key for account " + ownName);
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Could not retrieve axolotl key for account " + ownName);
|
||||||
ownKey = generateIdentityKeyPair();
|
ownKey = generateIdentityKeyPair();
|
||||||
mXmppConnectionService.databaseBackend.storeOwnIdentityKeyPair(account, ownName, ownKey);
|
mXmppConnectionService.databaseBackend.storeOwnIdentityKeyPair(account, ownName, ownKey);
|
||||||
}
|
}
|
||||||
|
@ -152,13 +154,13 @@ public class AxolotlService {
|
||||||
if (regIdString != null) {
|
if (regIdString != null) {
|
||||||
reg_id = Integer.valueOf(regIdString);
|
reg_id = Integer.valueOf(regIdString);
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "Could not retrieve axolotl registration id for account " + account.getJid());
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Could not retrieve axolotl registration id for account " + account.getJid());
|
||||||
reg_id = generateRegistrationId();
|
reg_id = generateRegistrationId();
|
||||||
boolean success = this.account.setKey(JSONKEY_REGISTRATION_ID, Integer.toString(reg_id));
|
boolean success = this.account.setKey(JSONKEY_REGISTRATION_ID, Integer.toString(reg_id));
|
||||||
if (success) {
|
if (success) {
|
||||||
mXmppConnectionService.databaseBackend.updateAccount(account);
|
mXmppConnectionService.databaseBackend.updateAccount(account);
|
||||||
} else {
|
} else {
|
||||||
Log.e(Config.LOGTAG, "Failed to write new key to the database!");
|
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Failed to write new key to the database!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reg_id;
|
return reg_id;
|
||||||
|
@ -170,7 +172,7 @@ public class AxolotlService {
|
||||||
if (regIdString != null) {
|
if (regIdString != null) {
|
||||||
reg_id = Integer.valueOf(regIdString);
|
reg_id = Integer.valueOf(regIdString);
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "Could not retrieve current prekey id for account " + account.getJid());
|
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Could not retrieve current prekey id for account " + account.getJid());
|
||||||
reg_id = 0;
|
reg_id = 0;
|
||||||
}
|
}
|
||||||
return reg_id;
|
return reg_id;
|
||||||
|
@ -366,7 +368,7 @@ public class AxolotlService {
|
||||||
if (success) {
|
if (success) {
|
||||||
mXmppConnectionService.databaseBackend.updateAccount(account);
|
mXmppConnectionService.databaseBackend.updateAccount(account);
|
||||||
} else {
|
} else {
|
||||||
Log.e(Config.LOGTAG, "Failed to write new prekey id to the database!");
|
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Failed to write new prekey id to the database!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,11 +458,13 @@ public class AxolotlService {
|
||||||
private Integer preKeyId = null;
|
private Integer preKeyId = null;
|
||||||
private SQLiteAxolotlStore sqLiteAxolotlStore;
|
private SQLiteAxolotlStore sqLiteAxolotlStore;
|
||||||
private AxolotlAddress remoteAddress;
|
private AxolotlAddress remoteAddress;
|
||||||
|
private final Account account;
|
||||||
|
|
||||||
public XmppAxolotlSession(SQLiteAxolotlStore store, AxolotlAddress remoteAddress) {
|
public XmppAxolotlSession(Account account, SQLiteAxolotlStore store, AxolotlAddress remoteAddress) {
|
||||||
this.cipher = new SessionCipher(store, remoteAddress);
|
this.cipher = new SessionCipher(store, remoteAddress);
|
||||||
this.remoteAddress = remoteAddress;
|
this.remoteAddress = remoteAddress;
|
||||||
this.sqLiteAxolotlStore = store;
|
this.sqLiteAxolotlStore = store;
|
||||||
|
this.account = account;
|
||||||
this.isTrusted = sqLiteAxolotlStore.isTrustedSession(remoteAddress);
|
this.isTrusted = sqLiteAxolotlStore.isTrustedSession(remoteAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,21 +490,20 @@ public class AxolotlService {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
PreKeyWhisperMessage message = new PreKeyWhisperMessage(incomingHeader.getContents());
|
PreKeyWhisperMessage message = new PreKeyWhisperMessage(incomingHeader.getContents());
|
||||||
Log.d(Config.LOGTAG, "PreKeyWhisperMessage ID:" + message.getSignedPreKeyId() + "/" + message.getPreKeyId());
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"PreKeyWhisperMessage received, new session ID:" + message.getSignedPreKeyId() + "/" + message.getPreKeyId());
|
||||||
plaintext = cipher.decrypt(message);
|
plaintext = cipher.decrypt(message);
|
||||||
if (message.getPreKeyId().isPresent()) {
|
if (message.getPreKeyId().isPresent()) {
|
||||||
preKeyId = message.getPreKeyId().get();
|
preKeyId = message.getPreKeyId().get();
|
||||||
}
|
}
|
||||||
} catch (InvalidMessageException | InvalidVersionException e) {
|
} catch (InvalidMessageException | InvalidVersionException e) {
|
||||||
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"WhisperMessage received");
|
||||||
WhisperMessage message = new WhisperMessage(incomingHeader.getContents());
|
WhisperMessage message = new WhisperMessage(incomingHeader.getContents());
|
||||||
plaintext = cipher.decrypt(message);
|
plaintext = cipher.decrypt(message);
|
||||||
} catch (InvalidKeyException | InvalidKeyIdException | UntrustedIdentityException e) {
|
} catch (InvalidKeyException | InvalidKeyIdException | UntrustedIdentityException e) {
|
||||||
Log.d(Config.LOGTAG, "Error decrypting axolotl header, "+e.getClass().getName()+": " + e.getMessage());
|
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Error decrypting axolotl header, "+e.getClass().getName()+": " + e.getMessage());
|
||||||
}
|
}
|
||||||
} catch (LegacyMessageException | InvalidMessageException e) {
|
} catch (LegacyMessageException | InvalidMessageException | DuplicateMessageException | NoSessionException e) {
|
||||||
Log.d(Config.LOGTAG, "Error decrypting axolotl header, "+e.getClass().getName()+": " + e.getMessage());
|
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Error decrypting axolotl header, "+e.getClass().getName()+": " + e.getMessage());
|
||||||
} catch (DuplicateMessageException | NoSessionException e) {
|
|
||||||
Log.d(Config.LOGTAG, "Error decrypting axolotl header, "+e.getClass().getName()+": " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
return plaintext;
|
return plaintext;
|
||||||
}
|
}
|
||||||
|
@ -580,7 +583,7 @@ public class AxolotlService {
|
||||||
List<Integer> deviceIDs = store.getSubDeviceSessions(address);
|
List<Integer> deviceIDs = store.getSubDeviceSessions(address);
|
||||||
for (Integer deviceId : deviceIDs) {
|
for (Integer deviceId : deviceIDs) {
|
||||||
AxolotlAddress axolotlAddress = new AxolotlAddress(address, deviceId);
|
AxolotlAddress axolotlAddress = new AxolotlAddress(address, deviceId);
|
||||||
this.put(axolotlAddress, new XmppAxolotlSession(store, axolotlAddress));
|
this.put(axolotlAddress, new XmppAxolotlSession(account, store, axolotlAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,6 +600,10 @@ public class AxolotlService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getLogprefix(Account account) {
|
||||||
|
return LOGPREFIX+" ("+account.getJid().toBareJid().toString()+"): ";
|
||||||
|
}
|
||||||
|
|
||||||
public AxolotlService(Account account, XmppConnectionService connectionService) {
|
public AxolotlService(Account account, XmppConnectionService connectionService) {
|
||||||
this.mXmppConnectionService = connectionService;
|
this.mXmppConnectionService = connectionService;
|
||||||
this.account = account;
|
this.account = account;
|
||||||
|
@ -661,11 +668,11 @@ public class AxolotlService {
|
||||||
|
|
||||||
public void registerDevices(final Jid jid, @NonNull final Set<Integer> deviceIds) {
|
public void registerDevices(final Jid jid, @NonNull final Set<Integer> deviceIds) {
|
||||||
if(deviceIds.contains(getOwnDeviceId())) {
|
if(deviceIds.contains(getOwnDeviceId())) {
|
||||||
Log.d(Config.LOGTAG, "Skipping own Device ID:"+ jid + ":"+getOwnDeviceId());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Skipping own Device ID:"+ jid + ":"+getOwnDeviceId());
|
||||||
deviceIds.remove(getOwnDeviceId());
|
deviceIds.remove(getOwnDeviceId());
|
||||||
}
|
}
|
||||||
for(Integer i:deviceIds) {
|
for(Integer i:deviceIds) {
|
||||||
Log.d(Config.LOGTAG, "Adding Device ID:"+ jid + ":"+i);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Adding Device ID:"+ jid + ":"+i);
|
||||||
}
|
}
|
||||||
this.deviceIds.put(jid, deviceIds);
|
this.deviceIds.put(jid, deviceIds);
|
||||||
publishOwnDeviceIdIfNeeded();
|
publishOwnDeviceIdIfNeeded();
|
||||||
|
@ -675,7 +682,7 @@ public class AxolotlService {
|
||||||
Set<Integer> deviceIds = new HashSet<>();
|
Set<Integer> deviceIds = new HashSet<>();
|
||||||
deviceIds.add(getOwnDeviceId());
|
deviceIds.add(getOwnDeviceId());
|
||||||
IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(deviceIds);
|
IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(deviceIds);
|
||||||
Log.d(Config.LOGTAG, "Wiping all other devices from Pep:" + publish);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Wiping all other devices from Pep:" + publish);
|
||||||
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
|
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
|
@ -697,7 +704,7 @@ public class AxolotlService {
|
||||||
if (!deviceIds.contains(getOwnDeviceId())) {
|
if (!deviceIds.contains(getOwnDeviceId())) {
|
||||||
deviceIds.add(getOwnDeviceId());
|
deviceIds.add(getOwnDeviceId());
|
||||||
IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(deviceIds);
|
IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(deviceIds);
|
||||||
Log.d(Config.LOGTAG, "Own device " + getOwnDeviceId() + " not in PEP devicelist. Publishing: " + publish);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Own device " + getOwnDeviceId() + " not in PEP devicelist. Publishing: " + publish);
|
||||||
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
|
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
|
@ -718,19 +725,19 @@ public class AxolotlService {
|
||||||
Map<Integer, ECPublicKey> keys = mXmppConnectionService.getIqParser().preKeyPublics(packet);
|
Map<Integer, ECPublicKey> keys = mXmppConnectionService.getIqParser().preKeyPublics(packet);
|
||||||
boolean flush = false;
|
boolean flush = false;
|
||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
Log.e(Config.LOGTAG, "Received invalid bundle:" + packet);
|
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Received invalid bundle:" + packet);
|
||||||
bundle = new PreKeyBundle(-1, -1, -1 , null, -1, null, null, null);
|
bundle = new PreKeyBundle(-1, -1, -1 , null, -1, null, null, null);
|
||||||
flush = true;
|
flush = true;
|
||||||
}
|
}
|
||||||
if (keys == null) {
|
if (keys == null) {
|
||||||
Log.e(Config.LOGTAG, "Received invalid prekeys:" + packet);
|
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Received invalid prekeys:" + packet);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
// Validate IdentityKey
|
// Validate IdentityKey
|
||||||
IdentityKeyPair identityKeyPair = axolotlStore.getIdentityKeyPair();
|
IdentityKeyPair identityKeyPair = axolotlStore.getIdentityKeyPair();
|
||||||
if (flush || !identityKeyPair.getPublicKey().equals(bundle.getIdentityKey())) {
|
if (flush || !identityKeyPair.getPublicKey().equals(bundle.getIdentityKey())) {
|
||||||
Log.d(Config.LOGTAG, "Adding own IdentityKey " + identityKeyPair.getPublicKey() + " to PEP.");
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Adding own IdentityKey " + identityKeyPair.getPublicKey() + " to PEP.");
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,13 +749,13 @@ public class AxolotlService {
|
||||||
if ( flush
|
if ( flush
|
||||||
||!bundle.getSignedPreKey().equals(signedPreKeyRecord.getKeyPair().getPublicKey())
|
||!bundle.getSignedPreKey().equals(signedPreKeyRecord.getKeyPair().getPublicKey())
|
||||||
|| !Arrays.equals(bundle.getSignedPreKeySignature(), signedPreKeyRecord.getSignature())) {
|
|| !Arrays.equals(bundle.getSignedPreKeySignature(), signedPreKeyRecord.getSignature())) {
|
||||||
Log.d(Config.LOGTAG, "Adding new signedPreKey with ID " + (numSignedPreKeys + 1) + " to PEP.");
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Adding new signedPreKey with ID " + (numSignedPreKeys + 1) + " to PEP.");
|
||||||
signedPreKeyRecord = KeyHelper.generateSignedPreKey(identityKeyPair, numSignedPreKeys + 1);
|
signedPreKeyRecord = KeyHelper.generateSignedPreKey(identityKeyPair, numSignedPreKeys + 1);
|
||||||
axolotlStore.storeSignedPreKey(signedPreKeyRecord.getId(), signedPreKeyRecord);
|
axolotlStore.storeSignedPreKey(signedPreKeyRecord.getId(), signedPreKeyRecord);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
} catch (InvalidKeyIdException e) {
|
} catch (InvalidKeyIdException e) {
|
||||||
Log.d(Config.LOGTAG, "Adding new signedPreKey with ID " + (numSignedPreKeys + 1) + " to PEP.");
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Adding new signedPreKey with ID " + (numSignedPreKeys + 1) + " to PEP.");
|
||||||
signedPreKeyRecord = KeyHelper.generateSignedPreKey(identityKeyPair, numSignedPreKeys + 1);
|
signedPreKeyRecord = KeyHelper.generateSignedPreKey(identityKeyPair, numSignedPreKeys + 1);
|
||||||
axolotlStore.storeSignedPreKey(signedPreKeyRecord.getId(), signedPreKeyRecord);
|
axolotlStore.storeSignedPreKey(signedPreKeyRecord.getId(), signedPreKeyRecord);
|
||||||
changed = true;
|
changed = true;
|
||||||
|
@ -776,7 +783,7 @@ public class AxolotlService {
|
||||||
axolotlStore.storePreKey(record.getId(), record);
|
axolotlStore.storePreKey(record.getId(), record);
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
Log.d(Config.LOGTAG, "Adding " + newKeys + " new preKeys to PEP.");
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Adding " + newKeys + " new preKeys to PEP.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -784,17 +791,17 @@ public class AxolotlService {
|
||||||
IqPacket publish = mXmppConnectionService.getIqGenerator().publishBundles(
|
IqPacket publish = mXmppConnectionService.getIqGenerator().publishBundles(
|
||||||
signedPreKeyRecord, axolotlStore.getIdentityKeyPair().getPublicKey(),
|
signedPreKeyRecord, axolotlStore.getIdentityKeyPair().getPublicKey(),
|
||||||
preKeyRecords, ownDeviceId);
|
preKeyRecords, ownDeviceId);
|
||||||
Log.d(Config.LOGTAG, "Bundle " + getOwnDeviceId() + " in PEP not current. Publishing: " + publish);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+ ": Bundle " + getOwnDeviceId() + " in PEP not current. Publishing: " + publish);
|
||||||
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
|
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
// TODO: implement this!
|
// TODO: implement this!
|
||||||
Log.d(Config.LOGTAG, "Published bundle, got: " + packet);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Published bundle, got: " + packet);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.e(Config.LOGTAG, "Failed to publish bundle " + getOwnDeviceId() + ", reason: " + e.getMessage());
|
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Failed to publish bundle " + getOwnDeviceId() + ", reason: " + e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -809,21 +816,21 @@ public class AxolotlService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildSessionFromPEP(final Conversation conversation, final AxolotlAddress address) {
|
private void buildSessionFromPEP(final Conversation conversation, final AxolotlAddress address) {
|
||||||
Log.d(Config.LOGTAG, "Building new sesstion for " + address.getDeviceId());
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Building new sesstion for " + address.getDeviceId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IqPacket bundlesPacket = mXmppConnectionService.getIqGenerator().retrieveBundlesForDevice(
|
IqPacket bundlesPacket = mXmppConnectionService.getIqGenerator().retrieveBundlesForDevice(
|
||||||
Jid.fromString(address.getName()), address.getDeviceId());
|
Jid.fromString(address.getName()), address.getDeviceId());
|
||||||
Log.d(Config.LOGTAG, "Retrieving bundle: " + bundlesPacket);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Retrieving bundle: " + bundlesPacket);
|
||||||
mXmppConnectionService.sendIqPacket(account, bundlesPacket, new OnIqPacketReceived() {
|
mXmppConnectionService.sendIqPacket(account, bundlesPacket, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
Log.d(Config.LOGTAG, "Received preKey IQ packet, processing...");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Received preKey IQ packet, processing...");
|
||||||
final IqParser parser = mXmppConnectionService.getIqParser();
|
final IqParser parser = mXmppConnectionService.getIqParser();
|
||||||
final List<PreKeyBundle> preKeyBundleList = parser.preKeys(packet);
|
final List<PreKeyBundle> preKeyBundleList = parser.preKeys(packet);
|
||||||
final PreKeyBundle bundle = parser.bundle(packet);
|
final PreKeyBundle bundle = parser.bundle(packet);
|
||||||
if (preKeyBundleList.isEmpty() || bundle == null) {
|
if (preKeyBundleList.isEmpty() || bundle == null) {
|
||||||
Log.d(Config.LOGTAG, "preKey IQ packet invalid: " + packet);
|
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account)+"preKey IQ packet invalid: " + packet);
|
||||||
fetchStatusMap.put(address, FetchStatus.ERROR);
|
fetchStatusMap.put(address, FetchStatus.ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -845,11 +852,11 @@ public class AxolotlService {
|
||||||
try {
|
try {
|
||||||
SessionBuilder builder = new SessionBuilder(axolotlStore, address);
|
SessionBuilder builder = new SessionBuilder(axolotlStore, address);
|
||||||
builder.process(preKeyBundle);
|
builder.process(preKeyBundle);
|
||||||
XmppAxolotlSession session = new XmppAxolotlSession(axolotlStore, address);
|
XmppAxolotlSession session = new XmppAxolotlSession(account, axolotlStore, address);
|
||||||
sessions.put(address, session);
|
sessions.put(address, session);
|
||||||
fetchStatusMap.put(address, FetchStatus.SUCCESS);
|
fetchStatusMap.put(address, FetchStatus.SUCCESS);
|
||||||
} catch (UntrustedIdentityException|InvalidKeyException e) {
|
} catch (UntrustedIdentityException|InvalidKeyException e) {
|
||||||
Log.d(Config.LOGTAG, "Error building session for " + address + ": "
|
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Error building session for " + address + ": "
|
||||||
+ e.getClass().getName() + ", " + e.getMessage());
|
+ e.getClass().getName() + ", " + e.getMessage());
|
||||||
fetchStatusMap.put(address, FetchStatus.ERROR);
|
fetchStatusMap.put(address, FetchStatus.ERROR);
|
||||||
}
|
}
|
||||||
|
@ -869,32 +876,32 @@ public class AxolotlService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (InvalidJidException e) {
|
} catch (InvalidJidException e) {
|
||||||
Log.e(Config.LOGTAG,"Got address with invalid jid: " + address.getName());
|
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Got address with invalid jid: " + address.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean createSessionsIfNeeded(Conversation conversation) {
|
private boolean createSessionsIfNeeded(Conversation conversation) {
|
||||||
boolean newSessions = false;
|
boolean newSessions = false;
|
||||||
Log.d(Config.LOGTAG, "Creating axolotl sessions if needed...");
|
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Creating axolotl sessions if needed...");
|
||||||
Jid contactJid = conversation.getContact().getJid().toBareJid();
|
Jid contactJid = conversation.getContact().getJid().toBareJid();
|
||||||
Set<AxolotlAddress> addresses = new HashSet<>();
|
Set<AxolotlAddress> addresses = new HashSet<>();
|
||||||
if(deviceIds.get(contactJid) != null) {
|
if(deviceIds.get(contactJid) != null) {
|
||||||
for(Integer foreignId:this.deviceIds.get(contactJid)) {
|
for(Integer foreignId:this.deviceIds.get(contactJid)) {
|
||||||
Log.d(Config.LOGTAG, "Found device "+account.getJid().toBareJid()+":"+foreignId);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Found device "+account.getJid().toBareJid()+":"+foreignId);
|
||||||
addresses.add(new AxolotlAddress(contactJid.toString(), foreignId));
|
addresses.add(new AxolotlAddress(contactJid.toString(), foreignId));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(Config.LOGTAG, "Have no target devices in PEP!");
|
Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Have no target devices in PEP!");
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "Checking own account "+account.getJid().toBareJid());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Checking own account "+account.getJid().toBareJid());
|
||||||
if(deviceIds.get(account.getJid().toBareJid()) != null) {
|
if(deviceIds.get(account.getJid().toBareJid()) != null) {
|
||||||
for(Integer ownId:this.deviceIds.get(account.getJid().toBareJid())) {
|
for(Integer ownId:this.deviceIds.get(account.getJid().toBareJid())) {
|
||||||
Log.d(Config.LOGTAG, "Found device "+account.getJid().toBareJid()+":"+ownId);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Found device "+account.getJid().toBareJid()+":"+ownId);
|
||||||
addresses.add(new AxolotlAddress(account.getJid().toBareJid().toString(), ownId));
|
addresses.add(new AxolotlAddress(account.getJid().toBareJid().toString(), ownId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (AxolotlAddress address : addresses) {
|
for (AxolotlAddress address : addresses) {
|
||||||
Log.d(Config.LOGTAG, "Processing device: " + address.toString());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Processing device: " + address.toString());
|
||||||
FetchStatus status = fetchStatusMap.get(address);
|
FetchStatus status = fetchStatusMap.get(address);
|
||||||
XmppAxolotlSession session = sessions.get(address);
|
XmppAxolotlSession session = sessions.get(address);
|
||||||
if ( session == null && ( status == null || status == FetchStatus.ERROR) ) {
|
if ( session == null && ( status == null || status == FetchStatus.ERROR) ) {
|
||||||
|
@ -902,7 +909,7 @@ public class AxolotlService {
|
||||||
this.buildSessionFromPEP(conversation, address);
|
this.buildSessionFromPEP(conversation, address);
|
||||||
newSessions = true;
|
newSessions = true;
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "Already have session for " + address.toString());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Already have session for " + address.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newSessions;
|
return newSessions;
|
||||||
|
@ -916,18 +923,18 @@ public class AxolotlService {
|
||||||
if(findSessionsforContact(message.getContact()).isEmpty()) {
|
if(findSessionsforContact(message.getContact()).isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "Building axolotl foreign headers...");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Building axolotl foreign headers...");
|
||||||
for (XmppAxolotlSession session : findSessionsforContact(message.getContact())) {
|
for (XmppAxolotlSession session : findSessionsforContact(message.getContact())) {
|
||||||
Log.d(Config.LOGTAG, session.remoteAddress.toString());
|
Log.v(Config.LOGTAG, AxolotlService.getLogprefix(account)+session.remoteAddress.toString());
|
||||||
//if(!session.isTrusted()) {
|
//if(!session.isTrusted()) {
|
||||||
// TODO: handle this properly
|
// TODO: handle this properly
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
axolotlMessage.addHeader(session.processSending(axolotlMessage.getInnerKey()));
|
axolotlMessage.addHeader(session.processSending(axolotlMessage.getInnerKey()));
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "Building axolotl own headers...");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Building axolotl own headers...");
|
||||||
for (XmppAxolotlSession session : findOwnSessions()) {
|
for (XmppAxolotlSession session : findOwnSessions()) {
|
||||||
Log.d(Config.LOGTAG, session.remoteAddress.toString());
|
Log.v(Config.LOGTAG, AxolotlService.getLogprefix(account)+session.remoteAddress.toString());
|
||||||
// if(!session.isTrusted()) {
|
// if(!session.isTrusted()) {
|
||||||
// TODO: handle this properly
|
// TODO: handle this properly
|
||||||
// continue;
|
// continue;
|
||||||
|
@ -948,7 +955,7 @@ public class AxolotlService {
|
||||||
mXmppConnectionService.markMessage(message, Message.STATUS_SEND_FAILED);
|
mXmppConnectionService.markMessage(message, Message.STATUS_SEND_FAILED);
|
||||||
//mXmppConnectionService.updateConversationUi();
|
//mXmppConnectionService.updateConversationUi();
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "Generated message, caching: " + message.getUuid());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Generated message, caching: " + message.getUuid());
|
||||||
messageCache.put(message.getUuid(), packet);
|
messageCache.put(message.getUuid(), packet);
|
||||||
mXmppConnectionService.resendMessage(message);
|
mXmppConnectionService.resendMessage(message);
|
||||||
}
|
}
|
||||||
|
@ -969,10 +976,10 @@ public class AxolotlService {
|
||||||
public MessagePacket fetchPacketFromCache(Message message) {
|
public MessagePacket fetchPacketFromCache(Message message) {
|
||||||
MessagePacket packet = messageCache.get(message.getUuid());
|
MessagePacket packet = messageCache.get(message.getUuid());
|
||||||
if (packet != null) {
|
if (packet != null) {
|
||||||
Log.d(Config.LOGTAG, "Cache hit: " + message.getUuid());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Cache hit: " + message.getUuid());
|
||||||
messageCache.remove(message.getUuid());
|
messageCache.remove(message.getUuid());
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, "Cache miss: " + message.getUuid());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Cache miss: " + message.getUuid());
|
||||||
}
|
}
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
@ -985,18 +992,18 @@ public class AxolotlService {
|
||||||
boolean newSession = false;
|
boolean newSession = false;
|
||||||
XmppAxolotlSession session = sessions.get(senderAddress);
|
XmppAxolotlSession session = sessions.get(senderAddress);
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
Log.d(Config.LOGTAG, "Account: "+account.getJid()+" No axolotl session found while parsing received message " + message);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Account: "+account.getJid()+" No axolotl session found while parsing received message " + message);
|
||||||
// TODO: handle this properly
|
// TODO: handle this properly
|
||||||
session = new XmppAxolotlSession(axolotlStore, senderAddress);
|
session = new XmppAxolotlSession(account, axolotlStore, senderAddress);
|
||||||
newSession = true;
|
newSession = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (XmppAxolotlMessage.XmppAxolotlMessageHeader header : message.getHeaders()) {
|
for (XmppAxolotlMessage.XmppAxolotlMessageHeader header : message.getHeaders()) {
|
||||||
if (header.getRecipientDeviceId() == ownDeviceId) {
|
if (header.getRecipientDeviceId() == ownDeviceId) {
|
||||||
Log.d(Config.LOGTAG, "Found axolotl header matching own device ID, processing...");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Found axolotl header matching own device ID, processing...");
|
||||||
byte[] payloadKey = session.processReceiving(header);
|
byte[] payloadKey = session.processReceiving(header);
|
||||||
if (payloadKey != null) {
|
if (payloadKey != null) {
|
||||||
Log.d(Config.LOGTAG, "Got payload key from axolotl header. Decrypting message...");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Got payload key from axolotl header. Decrypting message...");
|
||||||
plaintextMessage = message.decrypt(session, payloadKey);
|
plaintextMessage = message.decrypt(session, payloadKey);
|
||||||
}
|
}
|
||||||
Integer preKeyId = session.getPreKeyId();
|
Integer preKeyId = session.getPreKeyId();
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class MessageGenerator extends AbstractGenerator {
|
||||||
public MessagePacket generateAxolotlChat(Message message, boolean addDelay) {
|
public MessagePacket generateAxolotlChat(Message message, boolean addDelay) {
|
||||||
MessagePacket packet = preparePacket(message, addDelay);
|
MessagePacket packet = preparePacket(message, addDelay);
|
||||||
AxolotlService service = message.getConversation().getAccount().getAxolotlService();
|
AxolotlService service = message.getConversation().getAccount().getAxolotlService();
|
||||||
Log.d(Config.LOGTAG, "Submitting message to axolotl service for send processing...");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(message.getConversation().getAccount())+"Submitting message to axolotl service for send processing...");
|
||||||
XmppAxolotlMessage axolotlMessage = service.encrypt(message);
|
XmppAxolotlMessage axolotlMessage = service.encrypt(message);
|
||||||
if (axolotlMessage == null) {
|
if (axolotlMessage == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
|
@ -111,7 +112,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
Integer id = Integer.valueOf(device.getAttribute("id"));
|
Integer id = Integer.valueOf(device.getAttribute("id"));
|
||||||
deviceIds.add(id);
|
deviceIds.add(id);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(Config.LOGTAG, "Encountered nvalid <device> node in PEP:" + device.toString()
|
Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Encountered nvalid <device> node in PEP:" + device.toString()
|
||||||
+ ", skipping...");
|
+ ", skipping...");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +139,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
try {
|
try {
|
||||||
publicKey = Curve.decodePoint(Base64.decode(signedPreKeyPublic.getContent(),Base64.DEFAULT), 0);
|
publicKey = Curve.decodePoint(Base64.decode(signedPreKeyPublic.getContent(),Base64.DEFAULT), 0);
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.e(Config.LOGTAG, "Invalid signedPreKeyPublic in PEP: " + e.getMessage());
|
Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid signedPreKeyPublic in PEP: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return publicKey;
|
return publicKey;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +161,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
try {
|
try {
|
||||||
identityKey = new IdentityKey(Base64.decode(identityKeyElement.getContent(), Base64.DEFAULT), 0);
|
identityKey = new IdentityKey(Base64.decode(identityKeyElement.getContent(), Base64.DEFAULT), 0);
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.e(Config.LOGTAG,"Invalid identityKey in PEP: "+e.getMessage());
|
Log.e(Config.LOGTAG,AxolotlService.LOGPREFIX+" : "+"Invalid identityKey in PEP: "+e.getMessage());
|
||||||
}
|
}
|
||||||
return identityKey;
|
return identityKey;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +170,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
Map<Integer, ECPublicKey> preKeyRecords = new HashMap<>();
|
Map<Integer, ECPublicKey> preKeyRecords = new HashMap<>();
|
||||||
Element item = getItem(packet);
|
Element item = getItem(packet);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
Log.d(Config.LOGTAG, "Couldn't find <item> in bundle IQ packet: " + packet);
|
Log.d(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Couldn't find <item> in bundle IQ packet: " + packet);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Element bundleElement = item.findChild("bundle");
|
final Element bundleElement = item.findChild("bundle");
|
||||||
|
@ -178,12 +179,12 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
}
|
}
|
||||||
final Element prekeysElement = bundleElement.findChild("prekeys");
|
final Element prekeysElement = bundleElement.findChild("prekeys");
|
||||||
if(prekeysElement == null) {
|
if(prekeysElement == null) {
|
||||||
Log.d(Config.LOGTAG, "Couldn't find <prekeys> in bundle IQ packet: " + packet);
|
Log.d(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Couldn't find <prekeys> in bundle IQ packet: " + packet);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for(Element preKeyPublicElement : prekeysElement.getChildren()) {
|
for(Element preKeyPublicElement : prekeysElement.getChildren()) {
|
||||||
if(!preKeyPublicElement.getName().equals("preKeyPublic")){
|
if(!preKeyPublicElement.getName().equals("preKeyPublic")){
|
||||||
Log.d(Config.LOGTAG, "Encountered unexpected tag in prekeys list: " + preKeyPublicElement);
|
Log.d(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Encountered unexpected tag in prekeys list: " + preKeyPublicElement);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Integer preKeyId = Integer.valueOf(preKeyPublicElement.getAttribute("preKeyId"));
|
Integer preKeyId = Integer.valueOf(preKeyPublicElement.getAttribute("preKeyId"));
|
||||||
|
@ -191,7 +192,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
ECPublicKey preKeyPublic = Curve.decodePoint(Base64.decode(preKeyPublicElement.getContent(), Base64.DEFAULT), 0);
|
ECPublicKey preKeyPublic = Curve.decodePoint(Base64.decode(preKeyPublicElement.getContent(), Base64.DEFAULT), 0);
|
||||||
preKeyRecords.put(preKeyId, preKeyPublic);
|
preKeyRecords.put(preKeyId, preKeyPublic);
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.e(Config.LOGTAG, "Invalid preKeyPublic (ID="+preKeyId+") in PEP: "+ e.getMessage()+", skipping...");
|
Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid preKeyPublic (ID="+preKeyId+") in PEP: "+ e.getMessage()+", skipping...");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class MessageParser extends AbstractParser implements
|
||||||
mXmppConnectionService.updateAccountUi();
|
mXmppConnectionService.updateAccountUi();
|
||||||
}
|
}
|
||||||
} else if (AxolotlService.PEP_DEVICE_LIST.equals(node)) {
|
} else if (AxolotlService.PEP_DEVICE_LIST.equals(node)) {
|
||||||
Log.d(Config.LOGTAG, "Received PEP device list update from "+ from + ", processing...");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Received PEP device list update from "+ from + ", processing...");
|
||||||
Element item = items.findChild("item");
|
Element item = items.findChild("item");
|
||||||
Set<Integer> deviceIds = mXmppConnectionService.getIqParser().deviceIds(item);
|
Set<Integer> deviceIds = mXmppConnectionService.getIqParser().deviceIds(item);
|
||||||
AxolotlService axolotlService = account.getAxolotlService();
|
AxolotlService axolotlService = account.getAxolotlService();
|
||||||
|
|
|
@ -820,7 +820,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
try {
|
try {
|
||||||
identityKeyPair = new IdentityKeyPair(Base64.decode(cursor.getString(cursor.getColumnIndex(AxolotlService.SQLiteAxolotlStore.KEY)),Base64.DEFAULT));
|
identityKeyPair = new IdentityKeyPair(Base64.decode(cursor.getString(cursor.getColumnIndex(AxolotlService.SQLiteAxolotlStore.KEY)),Base64.DEFAULT));
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.d(Config.LOGTAG, "Encountered invalid IdentityKey in database for account" + account.getJid().toBareJid() + ", address: " + name);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Encountered invalid IdentityKey in database for account" + account.getJid().toBareJid() + ", address: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -836,7 +836,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
try {
|
try {
|
||||||
identityKeys.add(new IdentityKey(Base64.decode(cursor.getString(cursor.getColumnIndex(AxolotlService.SQLiteAxolotlStore.KEY)),Base64.DEFAULT),0));
|
identityKeys.add(new IdentityKey(Base64.decode(cursor.getString(cursor.getColumnIndex(AxolotlService.SQLiteAxolotlStore.KEY)),Base64.DEFAULT),0));
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.d(Config.LOGTAG, "Encountered invalid IdentityKey in database for account"+account.getJid().toBareJid()+", address: "+name);
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+"Encountered invalid IdentityKey in database for account"+account.getJid().toBareJid()+", address: "+name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -863,7 +863,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recreateAxolotlDb() {
|
public void recreateAxolotlDb() {
|
||||||
Log.d(Config.LOGTAG, ">>> (RE)CREATING AXOLOTL DATABASE <<<");
|
Log.d(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+">>> (RE)CREATING AXOLOTL DATABASE <<<");
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.SESSION_TABLENAME);
|
db.execSQL("DROP TABLE IF EXISTS " + AxolotlService.SQLiteAxolotlStore.SESSION_TABLENAME);
|
||||||
db.execSQL(CREATE_SESSIONS_STATEMENT);
|
db.execSQL(CREATE_SESSIONS_STATEMENT);
|
||||||
|
@ -877,7 +877,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public void wipeAxolotlDb(Account account) {
|
public void wipeAxolotlDb(Account account) {
|
||||||
String accountName = account.getUuid();
|
String accountName = account.getUuid();
|
||||||
Log.d(Config.LOGTAG, ">>> WIPING AXOLOTL DATABASE FOR ACCOUNT " + accountName + " <<<");
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account)+">>> WIPING AXOLOTL DATABASE FOR ACCOUNT " + accountName + " <<<");
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
String[] deleteArgs= {
|
String[] deleteArgs= {
|
||||||
accountName
|
accountName
|
||||||
|
|
Loading…
Reference in New Issue