Ejemplo n.º 1
0
        public ValidationRequest(Interest interest, OnVerified onVerified,
				OnDataValidationFailed onValidationFailed, int retry, int stepCount)
        {
            interest_ = interest;
            onVerified_ = onVerified;
            onValidationFailed_ = onValidationFailed;
            retry_ = retry;
            stepCount_ = stepCount;
        }
Ejemplo n.º 2
0
 public ValidationRequest(Interest interest, OnVerified onVerified,
                          OnDataValidationFailed onValidationFailed, int retry, int stepCount)
 {
     interest_           = interest;
     onVerified_         = onVerified;
     onValidationFailed_ = onValidationFailed;
     retry_     = retry;
     stepCount_ = stepCount;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Override to call onVerified.onVerified(data) and to indicate no further
 /// verification step.
 /// </summary>
 ///
 /// <param name="data">The Data object with the signature to check.</param>
 /// <param name="stepCount"></param>
 /// <param name="onVerified">better error handling the callback should catch and properly handle any exceptions.</param>
 /// <param name="onValidationFailed">Override to ignore this.</param>
 /// <returns>null for no further step.</returns>
 public sealed override ValidationRequest checkVerificationPolicy(Data data,
                                                                  int stepCount, OnVerified onVerified,
                                                                  OnDataValidationFailed onValidationFailed)
 {
     try {
         onVerified.onVerified(data);
     } catch (Exception ex) {
         logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerified", ex);
     }
     return(null);
 }
        /// <summary>
        /// Override to call onVerified.onVerified(data) and to indicate no further
        /// verification step.
        /// </summary>
        ///
        /// <param name="data">The Data object with the signature to check.</param>
        /// <param name="stepCount"></param>
        /// <param name="onVerified">better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onValidationFailed">Override to ignore this.</param>
        /// <returns>null for no further step.</returns>
        public override sealed ValidationRequest checkVerificationPolicy(Data data,
				int stepCount, OnVerified onVerified,
				OnDataValidationFailed onValidationFailed)
        {
            try {
                onVerified.onVerified(data);
            } catch (Exception ex) {
                logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerified", ex);
            }
            return null;
        }
        /// <summary>
        /// Look in the IdentityStorage for the public key with the name in the
        /// KeyLocator (if available) and use it to verify the data packet.  If the
        /// public key can't be found, call onVerifyFailed.
        /// </summary>
        ///
        /// <param name="data">The Data object with the signature to check.</param>
        /// <param name="stepCount"></param>
        /// <param name="onVerified">better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onValidationFailed">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>null for no further step for looking up a certificate chain.</returns>
        public override ValidationRequest checkVerificationPolicy(Data data, int stepCount,
				OnVerified onVerified, OnDataValidationFailed onValidationFailed)
        {
            String[] failureReason = new String[] { "unknown" };
            // wireEncode returns the cached encoding if available.
            if (verify(data.getSignature(), data.wireEncode(), failureReason)) {
                try {
                    onVerified.onVerified(data);
                } catch (Exception ex) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerified", ex);
                }
            } else {
                try {
                    onValidationFailed.onDataValidationFailed(data,
                            failureReason[0]);
                } catch (Exception ex_0) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onDataValidationFailed", ex_0);
                }
            }

            // No more steps, so return a null ValidationRequest.
            return null;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Check whether the received data packet complies with the verification
        /// policy, and get the indication of the next verification step.
        /// </summary>
        ///
        /// <param name="data">The Data object with the signature to check.</param>
        /// <param name="stepCount"></param>
        /// <param name="onVerified">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onValidationFailed">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>the indication of next verification step, null if there is no
        /// further step.</returns>
        public abstract ValidationRequest checkVerificationPolicy(Data data,
				int stepCount, OnVerified onVerified,
				OnDataValidationFailed onValidationFailed);
Ejemplo n.º 7
0
        public void verifyData(Data data, OnVerified verifiedCallback,
				OnDataValidationFailed failedCallback)
        {
            keyChain_.verifyData(data, verifiedCallback, failedCallback);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Check whether the received data packet complies with the verification
 /// policy, and get the indication of the next verification step.
 /// </summary>
 ///
 /// <param name="data">The Data object with the signature to check.</param>
 /// <param name="stepCount"></param>
 /// <param name="onVerified">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
 /// <param name="onValidationFailed">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
 /// <returns>the indication of next verification step, null if there is no
 /// further step.</returns>
 public abstract ValidationRequest checkVerificationPolicy(Data data,
                                                           int stepCount, OnVerified onVerified,
                                                           OnDataValidationFailed onValidationFailed);
Ejemplo n.º 9
0
        /// <summary>
        /// Check the signature on the Data object and call either onVerify.onVerify or
        /// onVerifyFailed.onVerifyFailed.
        /// We use callback functions because verify may fetch information to check the
        /// signature.
        /// </summary>
        ///
        /// <param name="data">To set the wireEncoding, you can call data.wireDecode.</param>
        /// <param name="onVerified">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onValidationFailed">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        public void verifyData(Data data, OnVerified onVerified,
				OnDataValidationFailed onValidationFailed)
        {
            verifyData(data, onVerified, onValidationFailed, 0);
        }
Ejemplo n.º 10
0
        public void verifyData(Data data, OnVerified onVerified,
				OnDataValidationFailed onValidationFailed, int stepCount)
        {
            ILOG.J2CsMapping.Util.Logging.Logger.getLogger(this.GetType().FullName).log(ILOG.J2CsMapping.Util.Logging.Level.INFO,
                    "Enter Verify");

            if (policyManager_.requireVerify(data)) {
                ValidationRequest nextStep = policyManager_
                        .checkVerificationPolicy(data, stepCount, onVerified,
                                onValidationFailed);
                if (nextStep != null) {
                    KeyChain.VerifyCallbacks  callbacks = new KeyChain.VerifyCallbacks (this, nextStep,
                            nextStep.retry_, onValidationFailed, data);
                    try {
                        face_.expressInterest(nextStep.interest_, callbacks,
                                callbacks);
                    } catch (IOException ex) {
                        try {
                            onValidationFailed.onDataValidationFailed(data,
                                    "Error calling expressInterest " + ex);
                        } catch (Exception exception) {
                            logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
                                    "Error in onDataValidationFailed", exception);
                        }
                    }
                }
            } else if (policyManager_.skipVerifyAndTrust(data)) {
                try {
                    onVerified.onVerified(data);
                } catch (Exception ex_0) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerified", ex_0);
                }
            } else {
                try {
                    onValidationFailed
                            .onDataValidationFailed(data,
                                    "The packet has no verify rule but skipVerifyAndTrust is false");
                } catch (Exception ex_1) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onDataValidationFailed", ex_1);
                }
            }
        }
Ejemplo n.º 11
0
            public VerifyCallbacks(KeyChain chain, ValidationRequest nextStep, int retry,
						OnDataValidationFailed onValidationFailed, Data originalData)
            {
                outer_KeyChain = chain;
                    nextStep_ = nextStep;
                    retry_ = retry;
                    onValidationFailed_ = onValidationFailed;
                    originalData_ = originalData;
            }
Ejemplo n.º 12
0
        /// <summary>
        /// Look in the IdentityStorage or PibImpl for the public key with the name in the
        /// KeyLocator (if available) and use it to verify the data packet.  If the
        /// public key can't be found, call onValidationFailed.onDataValidationFailed.
        /// </summary>
        ///
        /// <param name="data">The Data object with the signature to check.</param>
        /// <param name="stepCount"></param>
        /// <param name="onVerified">better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onValidationFailed">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>null for no further step for looking up a certificate chain.</returns>
        public override ValidationRequest checkVerificationPolicy(Data data, int stepCount,
                                                                  OnVerified onVerified, OnDataValidationFailed onValidationFailed)
        {
            String[] failureReason = new String[] { "unknown" };
            // wireEncode returns the cached encoding if available.
            if (verify(data.getSignature(), data.wireEncode(), failureReason))
            {
                try {
                    onVerified.onVerified(data);
                } catch (Exception ex) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerified", ex);
                }
            }
            else
            {
                try {
                    onValidationFailed.onDataValidationFailed(data,
                                                              failureReason[0]);
                } catch (Exception ex_0) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onDataValidationFailed", ex_0);
                }
            }

            // No more steps, so return a null ValidationRequest.
            return(null);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Check whether the received data packet complies with the verification policy,
        /// and get the indication of the next verification step.
        /// </summary>
        ///
        /// <param name="data">The Data object with the signature to check.</param>
        /// <param name="stepCount"></param>
        /// <param name="onVerified">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onValidationFailed">NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>the indication of next verification step, null if there is no
        /// further step.</returns>
        public override sealed ValidationRequest checkVerificationPolicy(Data data,
				int stepCount, OnVerified onVerified,
				OnDataValidationFailed onValidationFailed)
        {
            String[] failureReason = new String[] { "unknown" };
            Interest certificateInterest = getCertificateInterest(stepCount,
                    "data", data.getName(), data.getSignature(), failureReason);
            if (certificateInterest == null) {
                try {
                    onValidationFailed.onDataValidationFailed(data,
                            failureReason[0]);
                } catch (Exception ex) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onDataValidationFailed", ex);
                }
                return null;
            }

            if (certificateInterest.getName().size() > 0)
                return new ValidationRequest(certificateInterest,
                        new ConfigPolicyManager.OnCertificateDownloadComplete (this, data, stepCount,
                                onVerified, onValidationFailed),
                        onValidationFailed, 2, stepCount + 1);
            else {
                // Certificate is known. Verify the signature.
                // wireEncode returns the cached encoding if available.
                if (verify(data.getSignature(), data.wireEncode(), failureReason)) {
                    try {
                        onVerified.onVerified(data);
                    } catch (Exception ex_0) {
                        logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerified", ex_0);
                    }
                } else {
                    try {
                        onValidationFailed.onDataValidationFailed(data,
                                failureReason[0]);
                    } catch (Exception ex_1) {
                        logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE,
                                "Error in onDataValidationFailed", ex_1);
                    }
                }

                return null;
            }
        }
Ejemplo n.º 14
0
            public OnCertificateDownloadComplete(ConfigPolicyManager manager, Data originalData, int stepCount,
						OnVerified onVerified, OnDataValidationFailed onValidationFailed)
            {
                outer_ConfigPolicyManager = manager;
                    originalData_ = originalData;
                    stepCount_ = stepCount;
                    onVerified_ = onVerified;
                    onValidationFailed_ = onValidationFailed;
            }