Search in sources :

Example 1 with CertificatePolicyCpsUriExtensionField

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

the class CertificatePolicyCpsUriExtensionField_injectReferenceValueTest method testInjectRefereneValue_policyQualUriNotExist_required_assertException.

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

Example 2 with CertificatePolicyCpsUriExtensionField

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

the class CertificatePolicyCpsUriExtensionField_injectReferenceValueTest method testInjectRefereneValue_policyQualUriExists_assertValue.

public void testInjectRefereneValue_policyQualUriExists_assertValue() throws Exception {
    final X509Certificate cert = TestUtils.loadCertificate("CernerDirectProviderCA.der");
    final CertificatePolicyCpsUriExtensionField field = new CertificatePolicyCpsUriExtensionField(false);
    field.injectReferenceValue(cert);
    Collection<String> pols = field.getPolicyValue().getPolicyValue();
    assertTrue(pols.contains("http://www.cerner.com/CPS"));
}
Also used : X509Certificate(java.security.cert.X509Certificate) CertificatePolicyCpsUriExtensionField(org.nhindirect.policy.x509.CertificatePolicyCpsUriExtensionField)

Example 3 with CertificatePolicyCpsUriExtensionField

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

the class CertificatePolicyCpsUriExtensionField_injectReferenceValueTest method testInjectRefereneValue_policyQualUriDoesNotExist_notRequired_assertValueEmpty.

public void testInjectRefereneValue_policyQualUriDoesNotExist_notRequired_assertValueEmpty() throws Exception {
    final X509Certificate cert = TestUtils.loadCertificate("altNameOnly.der");
    final CertificatePolicyCpsUriExtensionField field = new CertificatePolicyCpsUriExtensionField(false);
    field.injectReferenceValue(cert);
    assertTrue(field.getPolicyValue().getPolicyValue().isEmpty());
}
Also used : X509Certificate(java.security.cert.X509Certificate) CertificatePolicyCpsUriExtensionField(org.nhindirect.policy.x509.CertificatePolicyCpsUriExtensionField)

Example 4 with CertificatePolicyCpsUriExtensionField

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

the class CertificatePolicyCpsUriExtensionField_injectReferenceValueTest method testInjectRefereneValue_policyQualUriExistsAndRequired_assertValue.

public void testInjectRefereneValue_policyQualUriExistsAndRequired_assertValue() throws Exception {
    final X509Certificate cert = TestUtils.loadCertificate("CernerDirectProviderCA.der");
    final CertificatePolicyCpsUriExtensionField field = new CertificatePolicyCpsUriExtensionField(true);
    field.injectReferenceValue(cert);
    Collection<String> pols = field.getPolicyValue().getPolicyValue();
    assertTrue(pols.contains("http://www.cerner.com/CPS"));
}
Also used : X509Certificate(java.security.cert.X509Certificate) CertificatePolicyCpsUriExtensionField(org.nhindirect.policy.x509.CertificatePolicyCpsUriExtensionField)

Example 5 with CertificatePolicyCpsUriExtensionField

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

the class CertificatePolicyCpsUriExtensionField_injectReferenceValueTest method testInjectRefereneValue_noInjection_getPolicyValue_assertException.

public void testInjectRefereneValue_noInjection_getPolicyValue_assertException() throws Exception {
    final CertificatePolicyCpsUriExtensionField field = new CertificatePolicyCpsUriExtensionField(true);
    boolean exceptionOccured = false;
    try {
        field.getPolicyValue();
    } catch (IllegalStateException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : CertificatePolicyCpsUriExtensionField(org.nhindirect.policy.x509.CertificatePolicyCpsUriExtensionField)

Aggregations

CertificatePolicyCpsUriExtensionField (org.nhindirect.policy.x509.CertificatePolicyCpsUriExtensionField)6 X509Certificate (java.security.cert.X509Certificate)5 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)1