use of org.openkilda.floodlight.error.CorruptedNetworkDataException in project open-kilda by telstra.
the class PingResponseCommand method call.
@Override
public Command call() {
log.debug("{} - {}", getClass().getCanonicalName(), input);
byte[] payload = unwrap();
if (payload == null) {
return null;
}
log.info("Receive flow ping packet from switch {} OF-xid:{}", input.getDpId(), input.getMessage().getXid());
try {
PingData pingData = decode(payload);
getContext().setCorrelationId(pingData.getPingId().toString());
process(pingData);
} catch (CorruptedNetworkDataException e) {
logPing.error(String.format("dpid:%s %s", input.getDpId(), e));
}
return null;
}
use of org.openkilda.floodlight.error.CorruptedNetworkDataException in project open-kilda by telstra.
the class PingData method of.
/**
* Build {@link PingData} from {@link DecodedJWT} token.
*/
public static PingData of(DecodedJWT token) throws CorruptedNetworkDataException {
PingData data;
try {
DatapathId ingress = DatapathId.of(token.getClaim(makeIngressDatapathRef()).asLong());
int ingressPortNumber = token.getClaim(makeIngressPortRef()).asInt();
DatapathId egress = DatapathId.of(token.getClaim(makeEgressDatapathRef()).asLong());
UUID packetId = UUID.fromString(token.getClaim(makePingIdRef()).asString());
data = new PingData(ingressPortNumber, ingress, egress, packetId);
data.setSenderLatency(token.getClaim(makeIngressLatencyRef()).asLong());
data.setSendTime(token.getClaim(makeTimestampRef()).asLong());
} catch (NullPointerException e) {
throw new CorruptedNetworkDataException(String.format("Corrupted flow verification package (%s)", token));
}
return data;
}
use of org.openkilda.floodlight.error.CorruptedNetworkDataException in project open-kilda by telstra.
the class DataSignature method verify.
/**
* Verify data signature.
*/
public DecodedJWT verify(byte[] payload) throws CorruptedNetworkDataException {
String payloadStr = new String(payload, Charset.forName("UTF-8"));
DecodedJWT token;
try {
token = signVerification.verify(payloadStr);
} catch (JWTVerificationException e) {
throw new CorruptedNetworkDataException(String.format("Bad signature: %s", e));
}
return token;
}
Aggregations