/// <summary> /// Asynchronously validate the Interest. /// </summary> /// /// <param name="interest">The Interest to validate, which is copied.</param> /// <param name="successCallback"></param> /// <param name="failureCallback">ValidationError.</param> public void validate(Interest interest, InterestValidationSuccessCallback successCallback, InterestValidationFailureCallback failureCallback) { InterestValidationState state = new InterestValidationState(interest, successCallback, failureCallback); logger_.log(ILOG.J2CsMapping.Util.Logging.Level.FINE, "Start validating interest {0}", interest .getName().toUri()); policy_.checkPolicy(interest, state, new Validator.Anonymous_C2(this)); }
/// <param name="state">On error, this calls state.fail and returns false.</param> /// <param name="keyName_0">The key name.</param> /// <param name="timestamp_1">The timestamp as milliseconds since Jan 1, 1970 UTC.</param> /// <returns>On success, return true. On error, call state.fail and return false.</returns> private bool checkTimestamp(ValidationState state, Name keyName_0, double timestamp_1) { cleanUp(); // nowOffsetMilliseconds_ is only used for testing. double now = net.named_data.jndn.util.Common.getNowMilliseconds() + nowOffsetMilliseconds_; if (timestamp_1 < now - options_.gracePeriod_ || timestamp_1 > now + options_.gracePeriod_) { state.fail(new ValidationError(net.named_data.jndn.security.v2.ValidationError.POLICY_ERROR, "Timestamp is outside the grace period for key " + keyName_0.toUri())); return(false); } int index = findByKeyName(keyName_0); if (index >= 0) { if (timestamp_1 <= container_[index].timestamp_) { state.fail(new ValidationError(net.named_data.jndn.security.v2.ValidationError.POLICY_ERROR, "Timestamp is reordered for key " + keyName_0.toUri())); return(false); } } InterestValidationState interestState = (InterestValidationState)state; interestState .addSuccessCallback(new ValidationPolicyCommandInterest.Anonymous_C0(this, timestamp_1, keyName_0)); return(true); }