public void Validate(IList algorithms, IList policies, IList extensions) { if (!algorithms.Contains(this.MessageImprintAlgOid)) { throw new TspValidationException("request contains unknown algorithm.", 128); } if (policies != null && this.ReqPolicy != null && !policies.Contains(this.ReqPolicy)) { throw new TspValidationException("request contains unknown policy.", 256); } if (this.Extensions != null && extensions != null) { foreach (DerObjectIdentifier derObjectIdentifier in this.Extensions.ExtensionOids) { if (!extensions.Contains(derObjectIdentifier.Id)) { throw new TspValidationException("request contains unknown extension.", 8388608); } } } int digestLength = TspUtil.GetDigestLength(this.MessageImprintAlgOid); if (digestLength != this.GetMessageImprintDigest().Length) { throw new TspValidationException("imprint digest the wrong length.", 4); } }
/** * Validate the timestamp request, checking the digest to see if it is of an * accepted type and whether it is of the correct length for the algorithm specified. * * @param algorithms a set of string OIDS giving accepted algorithms. * @param policies if non-null a set of policies we are willing to sign under. * @param extensions if non-null a set of extensions we are willing to accept. * @throws TspException if the request is invalid, or processing fails. */ public void Validate( IList algorithms, IList policies, IList extensions) { if (!algorithms.Contains(this.MessageImprintAlgOid)) { throw new TspValidationException("request contains unknown algorithm.", PkiFailureInfo.BadAlg); } if (policies != null && this.ReqPolicy != null && !policies.Contains(this.ReqPolicy)) { throw new TspValidationException("request contains unknown policy.", PkiFailureInfo.UnacceptedPolicy); } if (this.Extensions != null && extensions != null) { foreach (DerObjectIdentifier oid in this.Extensions.ExtensionOids) { if (!extensions.Contains(oid.Id)) { throw new TspValidationException("request contains unknown extension.", PkiFailureInfo.UnacceptedExtension); } } } int digestLength = TspUtil.GetDigestLength(this.MessageImprintAlgOid); if (digestLength != this.GetMessageImprintDigest().Length) { throw new TspValidationException("imprint digest the wrong length.", PkiFailureInfo.BadDataFormat); } }
public void Validate(global::System.Collections.IList algorithms, global::System.Collections.IList policies, global::System.Collections.IList extensions) { if (!algorithms.Contains((object)MessageImprintAlgOid)) { throw new TspValidationException("request contains unknown algorithm.", 128); } if (policies != null && ReqPolicy != null && !policies.Contains((object)ReqPolicy)) { throw new TspValidationException("request contains unknown policy.", 256); } if (Extensions != null && extensions != null) { { global::System.Collections.IEnumerator enumerator = Extensions.ExtensionOids.GetEnumerator(); try { while (enumerator.MoveNext()) { DerObjectIdentifier derObjectIdentifier = (DerObjectIdentifier)enumerator.get_Current(); if (!extensions.Contains((object)derObjectIdentifier.Id)) { throw new TspValidationException("request contains unknown extension.", 8388608); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } } } int digestLength = TspUtil.GetDigestLength(MessageImprintAlgOid); if (digestLength != GetMessageImprintDigest().Length) { throw new TspValidationException("imprint digest the wrong length.", 4); } }