Search in sources :

Example 1 with CorruptedNetworkDataException

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;
}
Also used : PingData(org.openkilda.floodlight.model.PingData) CorruptedNetworkDataException(org.openkilda.floodlight.error.CorruptedNetworkDataException)

Example 2 with CorruptedNetworkDataException

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;
}
Also used : DatapathId(org.projectfloodlight.openflow.types.DatapathId) UUID(java.util.UUID) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) CorruptedNetworkDataException(org.openkilda.floodlight.error.CorruptedNetworkDataException)

Example 3 with CorruptedNetworkDataException

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;
}
Also used : JWTVerificationException(com.auth0.jwt.exceptions.JWTVerificationException) DecodedJWT(com.auth0.jwt.interfaces.DecodedJWT) CorruptedNetworkDataException(org.openkilda.floodlight.error.CorruptedNetworkDataException)

Aggregations

CorruptedNetworkDataException (org.openkilda.floodlight.error.CorruptedNetworkDataException)3 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)1 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)1 UUID (java.util.UUID)1 PingData (org.openkilda.floodlight.model.PingData)1 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)1 DatapathId (org.projectfloodlight.openflow.types.DatapathId)1