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());
}
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);
}
Aggregations