public void Read_WithQualifiers_ReturnsInstance() { var commitmentTypeIdentifier = new DerObjectIdentifier("1.2.3"); var bcCommitmentTypeQualifier = new BcCommitmentTypeQualifier(commitmentTypeIdentifier); var bcCommitmentTypeIndication = new BcCommitmentTypeIndication( PkcsObjectIdentifiers.IdCtiEtsProofOfSender, new DerSequence(bcCommitmentTypeQualifier)); var bytes = bcCommitmentTypeIndication.GetDerEncoded(); var commitmentTypeIndication = CommitmentTypeIndication.Read(bytes); Assert.Equal(1, commitmentTypeIndication.Qualifiers.Count); Assert.Equal(commitmentTypeIdentifier.ToString(), commitmentTypeIndication.Qualifiers[0].CommitmentTypeIdentifier.Value); }
/// <summary> /// Return a ProfileExtension instance based on a passed-in X509Extension /// </summary> /// <param name="oid">OID of extension</param> /// <param name="extension">X509Extension</param> /// <returns>A ProfileExtension instance</returns> internal static ProfileExtension GetExtension(DerObjectIdentifier oid, X509Extension extension) { if (extTypes.ContainsKey(oid)) { switch (extTypes[oid]) { case "AuthorityInfoAccess": return(new authorityInfoAccess(extension)); case "BasicConstraints": return(new basicConstraints(extension)); case "CertificatePolicies": return(new certificatePolicies(extension)); case "CRLDistributionPoints": return(new crlDistPoint(extension)); case "ExtendedKeyUsage": return(new extendedKeyUsage(extension)); case "InhibitAnyPolicy": return(new inhibitAnyPolicy(extension)); case "IssuerAlternativeName": return(new issuerAltName(extension)); case "SubjectKeyIdentifier": return(new subjectKeyIdentifier(extension)); case "KeyUsage": return(new keyUsage(extension)); case "NameConstraints": return(new nameConstraints(extension)); case "OCSPNocheck": return(new ocspNocheck(extension)); case "PolicyConstraints": return(new policyConstraints(extension)); case "PolicyMappings": return(new policyMappings(extension)); case "SubjectAlternativeName": return(new subjectAltName(extension)); //case "SubjectDirectoryAttributes": // return new subjectDirectoryAttributes(extension); // break; case "SubjectInfoAccess": return(new subjectInfoAccess(extension)); case "FreshestCRL": return(new freshestCRL(extension)); case "CaVersion": return(new caVersion(extension)); case "CertTemplateInfo": return(new certTemplateInfo(extension)); case "CertTemplateName": return(new certTemplateName(extension)); case "PrevCaCertHash": return(new prevCaCertHash(extension)); default: throw new ArgumentOutOfRangeException("Unknown object in factory" + oid.ToString()); } } else { return(new unknownExtension(oid, extension)); } }