Search in sources :

Example 1 with SQSPoller

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;
}
Also used : SQSPoller(co.krypt.krypton.transport.SQSPoller) NetworkMessage(co.krypt.krypton.protocol.NetworkMessage) Pairing(co.krypt.krypton.pairing.Pairing)

Example 2 with SQSPoller

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));
        }
    }
}
Also used : SQSPoller(co.krypt.krypton.transport.SQSPoller) Pairing(co.krypt.krypton.pairing.Pairing)

Example 3 with SQSPoller

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);
    }
}
Also used : HostsResponse(co.krypt.krypton.protocol.HostsResponse) GitSignResponse(co.krypt.krypton.protocol.GitSignResponse) MeResponse(co.krypt.krypton.protocol.MeResponse) SignResponse(co.krypt.krypton.protocol.SignResponse) UnpairResponse(co.krypt.krypton.protocol.UnpairResponse) AckResponse(co.krypt.krypton.protocol.AckResponse) Response(co.krypt.krypton.protocol.Response) SQSPoller(co.krypt.krypton.transport.SQSPoller) CryptoException(co.krypt.krypton.exception.CryptoException) TransportException(co.krypt.krypton.exception.TransportException) UnpairResponse(co.krypt.krypton.protocol.UnpairResponse)

Aggregations

SQSPoller (co.krypt.krypton.transport.SQSPoller)3 Pairing (co.krypt.krypton.pairing.Pairing)2 CryptoException (co.krypt.krypton.exception.CryptoException)1 TransportException (co.krypt.krypton.exception.TransportException)1 AckResponse (co.krypt.krypton.protocol.AckResponse)1 GitSignResponse (co.krypt.krypton.protocol.GitSignResponse)1 HostsResponse (co.krypt.krypton.protocol.HostsResponse)1 MeResponse (co.krypt.krypton.protocol.MeResponse)1 NetworkMessage (co.krypt.krypton.protocol.NetworkMessage)1 Response (co.krypt.krypton.protocol.Response)1 SignResponse (co.krypt.krypton.protocol.SignResponse)1 UnpairResponse (co.krypt.krypton.protocol.UnpairResponse)1