Search in sources :

Example 6 with SubjectAttributeField

use of org.nhindirect.policy.x509.SubjectAttributeField in project nhin-d by DirectProject.

the class SubjectAttributeField_injectReferenceValueTest method testInjectRefereneValue_rdnSingleAttributeExists_assertValue.

public void testInjectRefereneValue_rdnSingleAttributeExists_assertValue() throws Exception {
    final X509Certificate cert = TestUtils.loadCertificate("altNameOnly.der");
    final SubjectAttributeField field = new SubjectAttributeField(true, RDNAttributeIdentifier.COMMON_NAME);
    field.injectReferenceValue(cert);
    final Collection<String> values = field.getPolicyValue().getPolicyValue();
    assertEquals(1, values.size());
    Iterator<String> str = values.iterator();
    assertEquals("altNameOnly", str.next());
}
Also used : SubjectAttributeField(org.nhindirect.policy.x509.SubjectAttributeField) X509Certificate(java.security.cert.X509Certificate)

Example 7 with SubjectAttributeField

use of org.nhindirect.policy.x509.SubjectAttributeField in project nhin-d by DirectProject.

the class SubjectAttributeField_injectReferenceValueTest method testInjectRefereneValue_rdnAttributeDoesNotExist_required_throwException.

public void testInjectRefereneValue_rdnAttributeDoesNotExist_required_throwException() throws Exception {
    final X509Certificate cert = TestUtils.loadCertificate("altNameOnly.der");
    final SubjectAttributeField field = new SubjectAttributeField(true, RDNAttributeIdentifier.INITIALS);
    boolean exceptionOccured = false;
    try {
        field.injectReferenceValue(cert);
    } catch (PolicyRequiredException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : PolicyRequiredException(org.nhindirect.policy.PolicyRequiredException) SubjectAttributeField(org.nhindirect.policy.x509.SubjectAttributeField) X509Certificate(java.security.cert.X509Certificate)

Aggregations

SubjectAttributeField (org.nhindirect.policy.x509.SubjectAttributeField)7 X509Certificate (java.security.cert.X509Certificate)4 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 LiteralPolicyExpression (org.nhindirect.policy.LiteralPolicyExpression)1 OperationPolicyExpression (org.nhindirect.policy.OperationPolicyExpression)1 PolicyExpression (org.nhindirect.policy.PolicyExpression)1 PolicyGrammarException (org.nhindirect.policy.PolicyGrammarException)1 PolicyParseException (org.nhindirect.policy.PolicyParseException)1 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)1 IssuerAttributeField (org.nhindirect.policy.x509.IssuerAttributeField)1 RDNAttributeIdentifier (org.nhindirect.policy.x509.RDNAttributeIdentifier)1 TBSFieldName (org.nhindirect.policy.x509.TBSFieldName)1