public void testGetAttributes_fromName() { RDNAttributeIdentifier.COMMON_NAME.Name.Should().Be(RDNAttributeIdentifier.FromName("CN").Name); RDNAttributeIdentifier.COMMON_NAME.OID.Should().Be(RDNAttributeIdentifier.FromName("CN").OID); RDNAttributeIdentifier.FromName("CN.").Should().BeNull(); RDNAttributeIdentifier.COUNTRY.Name.Should().Be("C"); }
/// <summary> /// Builds a certificate reference expression that is a <see cref="ITBSField{T}"/> /// </summary> /// <param name="token"></param> /// <returns></returns> public IPolicyExpression BuildTBSField(String token) //throws PolicyParseException { dynamic retVal = null; TBSFieldName fieldName = TBSFieldName.FromToken(token); if (fieldName != null) { try { dynamic fieldRefClass = fieldName.GetReferenceClass(token); if (fieldRefClass == null) { throw new PolicyParseException("TBSField with token name " + token + " has not been implemented yet."); } if (fieldRefClass.GetType() == typeof(IssuerAttributeField) || fieldRefClass.GetType() == typeof(SubjectAttributeField)) { bool required = token.EndsWith("+"); String rdnLookupToken = (required) ? token.Substring(0, token.Length - 1) : token; RDNAttributeIdentifier identifier = RDNAttributeIdentifier.FromName(rdnLookupToken); retVal = fieldRefClass.GetType() == typeof(IssuerAttributeField) ? new IssuerAttributeField(required, identifier) : new SubjectAttributeField(required, identifier); } else { retVal = fieldRefClass as IPolicyExpression; } } catch (PolicyParseException) { throw; } catch (Exception e) { throw new PolicyParseException("Error building TBSField: " + token, e); } } return(retVal); }
public IssuerAttributeField(bool requird, string rdnAttribute) : this(requird, RDNAttributeIdentifier.FromName(rdnAttribute)) { }
/// <summary> /// Constructor /// </summary> /// <param name="required">Indicates if the field is required to be present in the certificate to be compliant with the policy.</param> /// <param name="rdnAttributeId">Id of the attribute to extract from the issuer RDN</param> public IssuerAttributeField(bool required, RDNAttributeIdentifier rdnAttributeId) : base(required) { RdnAttributeId = rdnAttributeId; }
/// <summary> /// Constructor /// </summary> /// <param name="required">Indicates if the field is required to be present in the certificate to be compliant with the policy.</param> /// <param name="rdnAttributeId">Id of the attribute to extract from the subject RDN</param> public SubjectAttributeField(bool required, RDNAttributeIdentifier rdnAttributeId) : base(required, rdnAttributeId) { }