/** * Determines if the correlation context of this object is secure. * * @return <code>true</code> if context is secure, <code>false</code> otherwise */ public boolean isSecure() { return (correlationContext != null && correlationContext.get(DtlsCorrelationContext.KEY_SESSION_ID) != null); } }
private boolean isResponseStrictlyRelatedToDtlsRequest(final CorrelationContext requestContext, final CorrelationContext responseContext) { if (responseContext == null) { return false; } else { return requestContext.get(DtlsCorrelationContext.KEY_SESSION_ID) .equals(responseContext.get(DtlsCorrelationContext.KEY_SESSION_ID)) && requestContext.get(DtlsCorrelationContext.KEY_EPOCH) .equals(responseContext.get(DtlsCorrelationContext.KEY_EPOCH)) && requestContext.get(DtlsCorrelationContext.KEY_CIPHER) .equals(responseContext.get(DtlsCorrelationContext.KEY_CIPHER)); } }
private boolean isResponseRelatedToDtlsRequest(final CorrelationContext requestContext, final CorrelationContext responseContext) { if (responseContext == null) { return false; } else { return requestContext.get(DtlsCorrelationContext.KEY_SESSION_ID) .equals(responseContext.get(DtlsCorrelationContext.KEY_SESSION_ID)) && requestContext.get(DtlsCorrelationContext.KEY_CIPHER) .equals(responseContext.get(DtlsCorrelationContext.KEY_CIPHER)); } }
private boolean isResponseRelatedToRequest(final Exchange exchange, final CorrelationContext responseContext) { if (exchange.getCorrelationContext() == null) { // no correlation information available for request, thus any // additional correlation information available in the response is ignored return true; } else if (exchange.getCorrelationContext().get(DtlsCorrelationContext.KEY_SESSION_ID) != null) { // original request has been sent via a DTLS protected transport // check if the response has been received in the same DTLS session if (useStrictResponseMatching) { return isResponseStrictlyRelatedToDtlsRequest(exchange.getCorrelationContext(), responseContext); } else { return isResponseRelatedToDtlsRequest(exchange.getCorrelationContext(), responseContext); } } else { // compare message context used for sending original request to context // the response has been received in return exchange.getCorrelationContext().equals(responseContext); } }