use of co.krypt.krypton.protocol.AckResponse in project krypton-android by kryptco.
the class Silo method handle.
private void handle(Pairing pairing, Request request, String communicationMedium) throws Unrecoverable {
// Allow 15 minutes of clock skew
if (Math.abs(request.unixSeconds - (System.currentTimeMillis() / 1000)) > CLOCK_SKEW_TOLERANCE_SECONDS) {
throw new ProtocolException("invalid request time");
}
if (request.body instanceof UnpairRequest) {
unpair(pairing, false);
new Analytics(context).postEvent("device", "unpair", "request", null, false);
}
synchronized ((Silo.class.getName() + request.requestID).intern()) {
if (sendCachedResponseIfPresent(pairing, request)) {
return;
}
}
EventBus.getDefault().post(new TeamService.UpdateTeamHomeDataIfOutdated(context));
lastRequestTimeSeconds.put(pairing, System.currentTimeMillis() / 1000);
if (Policy.isApprovedNow(this, context, pairing, request)) {
respondToRequest(pairing, request, true);
} else {
if (Policy.requestApproval(context, pairing, request)) {
new Analytics(context).postEvent(request.analyticsCategory(), "requires approval", communicationMedium, null, false);
}
if (request.sendACK != null && request.sendACK) {
Response ackResponse = Response.with(request);
ackResponse.ackResponse = new AckResponse();
send(pairing, ackResponse);
}
}
}
Aggregations