use of co.krypt.krypton.transport.SQSPoller in project krypton-android by kryptco.
the class Silo method pair.
public Pairing pair(Pairing pairing) throws CryptoException, TransportException {
synchronized (pairingsLock) {
Pairing oldPairing = activePairingsByUUID.get(pairing.uuid);
if (oldPairing != null) {
Log.w(TAG, "already paired with " + pairing.workstationName);
return oldPairing;
}
byte[] wrappedKey = pairing.wrapKey();
NetworkMessage wrappedKeyMessage = new NetworkMessage(NetworkMessage.Header.WRAPPED_PUBLIC_KEY, wrappedKey);
send(pairing, wrappedKeyMessage);
pairingStorage.pair(pairing);
activePairingsByUUID.put(pairing.uuid, pairing);
pollers.put(pairing, new SQSPoller(context, pairing));
if (bluetoothTransport != null) {
bluetoothTransport.add(pairing);
bluetoothTransport.send(pairing, wrappedKeyMessage);
}
}
return pairing;
}
use of co.krypt.krypton.transport.SQSPoller in project krypton-android by kryptco.
the class Silo method start.
public void start() {
synchronized (pairingsLock) {
for (Pairing pairing : activePairingsByUUID.values()) {
Log.i(TAG, "starting " + Base64.encodeAsString(pairing.workstationPublicKey));
SQSPoller poller = pollers.remove(pairing);
if (poller != null) {
poller.stop();
}
pollers.put(pairing, new SQSPoller(context, pairing));
}
}
}
use of co.krypt.krypton.transport.SQSPoller in project krypton-android by kryptco.
the class Silo method unpair.
public void unpair(Pairing pairing, boolean sendResponse) {
if (sendResponse) {
Response unpairResponse = new Response();
unpairResponse.requestID = "";
unpairResponse.unpairResponse = new UnpairResponse();
try {
send(pairing, unpairResponse);
} catch (CryptoException | TransportException e) {
e.printStackTrace();
}
}
synchronized (pairingsLock) {
pairingStorage.unpair(pairing);
activePairingsByUUID.remove(pairing.uuid);
SQSPoller poller = pollers.remove(pairing);
if (poller != null) {
poller.stop();
}
bluetoothTransport.remove(pairing);
}
}
Aggregations