use of org.nhindirect.policy.x509.SubjectKeyIdentifierExtensionField in project nhin-d by DirectProject.
the class SimpleTextV1LexiconPolicyParser_buildExpressionTest method testBuildExpression_requiredCertField_validateTokens.
public void testBuildExpression_requiredCertField_validateTokens() throws Exception {
final SimpleTextV1LexiconPolicyParser parser = new SimpleTextV1LexiconPolicyParser();
final InputStream stream = IOUtils.toInputStream("X509.TBS.EXTENSION.SubjectKeyIdentifier+ = 1.3.2.3");
Vector<SimpleTextV1LexiconPolicyParser.TokenTypeAssociation> tokens = parser.parseToTokens(stream);
// now build expressions
PolicyExpression expression = parser.buildExpression(tokens.iterator());
// check that the expression is an equals
assertNotNull(expression);
assertEquals(PolicyExpressionType.OPERATION, expression.getExpressionType());
OperationPolicyExpression operationExpression = (OperationPolicyExpression) expression;
assertEquals(PolicyOperator.EQUALS, operationExpression.getPolicyOperator());
// break down the sub operation parameters... should be a literal and an operation
expression = operationExpression.getOperands().get(0);
assertEquals(PolicyExpressionType.REFERENCE, expression.getExpressionType());
assertTrue(expression instanceof SubjectKeyIdentifierExtensionField);
assertTrue(((SubjectKeyIdentifierExtensionField) expression).isRequired());
expression = operationExpression.getOperands().get(1);
assertEquals(PolicyExpressionType.LITERAL, expression.getExpressionType());
stream.close();
}
use of org.nhindirect.policy.x509.SubjectKeyIdentifierExtensionField in project nhin-d by DirectProject.
the class SubjectKeyIdentifierExtensionField_injectReferenceValueTest method testInjectRefereneValue_keyIdDoesNotExist_notRequired_assertValue0.
public void testInjectRefereneValue_keyIdDoesNotExist_notRequired_assertValue0() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("cernerDemosCaCert.der");
final SubjectKeyIdentifierExtensionField field = new SubjectKeyIdentifierExtensionField(false);
field.injectReferenceValue(cert);
assertEquals("", field.getPolicyValue().getPolicyValue());
}
use of org.nhindirect.policy.x509.SubjectKeyIdentifierExtensionField in project nhin-d by DirectProject.
the class SubjectKeyIdentifierExtensionField_injectReferenceValueTest method testInjectRefereneValue_keyIdDoesNotExist_required_assertException.
public void testInjectRefereneValue_keyIdDoesNotExist_required_assertException() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("cernerDemosCaCert.der");
final SubjectKeyIdentifierExtensionField field = new SubjectKeyIdentifierExtensionField(true);
boolean exceptionOccured = false;
try {
field.injectReferenceValue(cert);
} catch (PolicyRequiredException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.policy.x509.SubjectKeyIdentifierExtensionField in project nhin-d by DirectProject.
the class SubjectKeyIdentifierExtensionField_injectReferenceValueTest method testInjectRefereneValue_noInjection_getPolicyValue_assertException.
public void testInjectRefereneValue_noInjection_getPolicyValue_assertException() throws Exception {
final SubjectKeyIdentifierExtensionField field = new SubjectKeyIdentifierExtensionField(true);
boolean exceptionOccured = false;
try {
field.getPolicyValue();
} catch (IllegalStateException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.policy.x509.SubjectKeyIdentifierExtensionField in project nhin-d by DirectProject.
the class SubjectKeyIdentifierExtensionField_injectReferenceValueTest method testInjectRefereneValue_keyIdUsageExists_assertValue.
public void testInjectRefereneValue_keyIdUsageExists_assertValue() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("AlAnderson@hospitalA.direct.visionshareinc.com.der");
final SubjectKeyIdentifierExtensionField field = new SubjectKeyIdentifierExtensionField(false);
field.injectReferenceValue(cert);
assertEquals("e0f63ccfeb5ce3eef5c04efe8084c92bc628682c", field.getPolicyValue().getPolicyValue());
}
Aggregations