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); } } }
/// <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="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> /// <returns>null for no further step for looking up a certificate chain.</returns> public override ValidationRequest checkVerificationPolicy(Data data, int stepCount, OnVerified onVerified, OnVerifyFailed onVerifyFailed) { // wireEncode returns the cached encoding if available. if (verify(data.getSignature(), data.wireEncode())) { try { onVerified.onVerified(data); } catch (Exception ex) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerified", ex); } } else { try { onVerifyFailed.onVerifyFailed(data); } catch (Exception ex_0) { logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onVerifyFailed", ex_0); } } // No more steps, so return a null ValidationRequest. return(null); }