/// <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);
        }
Exemplo n.º 2
0
 public Anonymous_C2(Consumer paramouter_Consumer, net.named_data.jndn.encrypt.EncryptError.OnError onError_0,
                     OnVerified onVerified_1)
 {
     this.onError        = onError_0;
     this.onVerified     = onVerified_1;
     this.outer_Consumer = paramouter_Consumer;
 }
Exemplo n.º 3
0
        public ValidationRequest(Interest interest, OnVerified onVerified,
				OnDataValidationFailed onValidationFailed, int retry, int stepCount)
        {
            interest_ = interest;
            onVerified_ = onVerified;
            onValidationFailed_ = onValidationFailed;
            retry_ = retry;
            stepCount_ = stepCount;
        }
Exemplo n.º 4
0
 public ValidationRequest(Interest interest, OnVerified onVerified,
                          OnDataValidationFailed onValidationFailed, int retry, int stepCount)
 {
     interest_           = interest;
     onVerified_         = onVerified;
     onValidationFailed_ = onValidationFailed;
     retry_     = retry;
     stepCount_ = stepCount;
 }
Exemplo n.º 5
0
 public Anonymous_C0(Consumer paramouter_Consumer, net.named_data.jndn.encrypt.EncryptError.OnError onError_0,
                     OnVerified onVerified_1, Link link_2, int nRetrials_3)
 {
     this.onError        = onError_0;
     this.onVerified     = onVerified_1;
     this.link           = link_2;
     this.nRetrials      = nRetrials_3;
     this.outer_Consumer = paramouter_Consumer;
 }
        /// <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;
        }
Exemplo n.º 7
0
        public bool VerifyMatch(IMatch match)
        {
            Console.WriteLine($"{match.SourceString} seems to match with {match.TargetString} with a rating of {match.MatchConfidence}. Confirm Match? Y or N");
            var result = Console.ReadKey().Key == ConsoleKey.Y;

            if (result)
            {
                OnVerified?.Invoke(this, match);
            }

            return(result);
        }
Exemplo n.º 8
0
        public void verifyData(Data data, OnVerified onVerified,
                               OnVerifyFailed onVerifyFailed, 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,
                                                                      onVerifyFailed);
                if (nextStep != null)
                {
                    KeyChain.VerifyCallbacks callbacks = new KeyChain.VerifyCallbacks(this, nextStep,
                                                                                      nextStep.retry_, onVerifyFailed, data);
                    try {
                        face_.expressInterest(nextStep.interest_, callbacks,
                                              callbacks);
                    } catch (IOException ex) {
                        try {
                            onVerifyFailed.onVerifyFailed(data);
                        } catch (Exception exception) {
                            logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerifyFailed",
                                        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 {
                    onVerifyFailed.onVerifyFailed(data);
                } catch (Exception ex_1) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerifyFailed", ex_1);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Express the interest, call verifyData for the fetched Data packet and call
        /// onVerified if verify succeeds. If verify fails, call
        /// onError.onError(ErrorCode.Validation, "verifyData failed"). If the interest
        /// times out, re-express nRetrials times. If the interest times out nRetrials
        /// times, or for a network Nack, call
        /// onError.onError(ErrorCode.DataRetrievalFailure, interest.getName().toUri()).
        /// </summary>
        ///
        /// <param name="interest">The Interest to express.</param>
        /// <param name="nRetrials_0">The number of retrials left after a timeout.</param>
        /// <param name="link_1">zero, don't use it.</param>
        /// <param name="onVerified_2"></param>
        /// <param name="onError_3">This calls onError.onError(errorCode, message) for an error.</param>
        internal void sendInterest(Interest interest, int nRetrials_0,
                                   Link link_1, OnVerified onVerified_2, net.named_data.jndn.encrypt.EncryptError.OnError onError_3)
        {
            // Prepare the callback functions.
            OnData onData = new Consumer.Anonymous_C2(this, onError_3, onVerified_2);

            OnNetworkNack onNetworkNack = new Consumer.Anonymous_C1(onError_3);

            OnTimeout onTimeout = new Consumer.Anonymous_C0(this, onError_3, onVerified_2, link_1, nRetrials_0);

            Interest request;

            if (link_1.getDelegations().size() == 0)
            {
                // We can use the supplied interest without copying.
                request = interest;
            }
            else
            {
                // Copy the supplied interest and add the Link.
                request = new Interest(interest);
                // This will use a cached encoding if available.
                request.setLinkWireEncoding(link_1.wireEncode());
            }

            try {
                face_.expressInterest(request, onData, onTimeout, onNetworkNack);
            } catch (IOException ex) {
                try {
                    onError_3.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.IOException,
                                      "expressInterest error: " + ex.Message);
                } catch (Exception exception) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception);
                }
            }
        }
Exemplo n.º 10
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="onVerifyFailed">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,
                        OnVerifyFailed onVerifyFailed)
 {
     verifyData(data, onVerified, onVerifyFailed, 0);
 }
Exemplo n.º 11
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);
Exemplo n.º 12
0
        public void verifyData(Data data, OnVerified verifiedCallback,
				OnDataValidationFailed failedCallback)
        {
            keyChain_.verifyData(data, verifiedCallback, failedCallback);
        }
Exemplo 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 abstract ValidationRequest checkVerificationPolicy(Data data,
                                                           int stepCount, OnVerified onVerified,
                                                           OnDataValidationFailed onValidationFailed);
Exemplo n.º 14
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="onVerifyFailed">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,
				OnVerifyFailed onVerifyFailed)
        {
            // Wrap the onVerifyFailed in an OnDataValidationFailed.
            verifyData(data, onVerified, new KeyChain.Anonymous_C1 (onVerifyFailed));
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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);
                }
            }
        }
Exemplo n.º 17
0
            public OnCertificateDownloadComplete(ConfigPolicyManager manager, Data originalData, int stepCount,
						OnVerified onVerified, OnDataValidationFailed onValidationFailed)
            {
                outer_ConfigPolicyManager = manager;
                    originalData_ = originalData;
                    stepCount_ = stepCount;
                    onVerified_ = onVerified;
                    onValidationFailed_ = onValidationFailed;
            }
Exemplo n.º 18
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>
        /// 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;
        }
Exemplo n.º 20
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;
            }
        }