use of org.nhindirect.policy.x509.AuthorityInfoAccessExtentionField in project nhin-d by DirectProject.
the class AuthorityInfoAccessExtentionField_injectReferenceValueTest method testInjectRefereneValue_aiaExists_assertValue.
public void testInjectRefereneValue_aiaExists_assertValue() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("CernerDirectProviderCA.der");
final AuthorityInfoAccessExtentionField field = new AuthorityInfoAccessExtentionField(false);
field.injectReferenceValue(cert);
Collection<String> usages = field.getPolicyValue().getPolicyValue();
assertFalse(field.getPolicyValue().getPolicyValue().isEmpty());
assertTrue(usages.contains(AuthorityInfoAccessMethodIdentifier.OCSP.getName() + ":" + "http://ca.cerner.com/OCSP"));
assertTrue(usages.contains(AuthorityInfoAccessMethodIdentifier.CA_ISSUERS.getName() + ":" + "http://ca.cerner.com/public/root.der"));
}
use of org.nhindirect.policy.x509.AuthorityInfoAccessExtentionField in project nhin-d by DirectProject.
the class AuthorityInfoAccessExtentionField_injectReferenceValueTest method testInjectRefereneValue_noInjection_getPolicyValue_assertException.
public void testInjectRefereneValue_noInjection_getPolicyValue_assertException() throws Exception {
final AuthorityInfoAccessExtentionField field = new AuthorityInfoAccessExtentionField(true);
boolean exceptionOccured = false;
try {
field.getPolicyValue();
} catch (IllegalStateException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.policy.x509.AuthorityInfoAccessExtentionField in project nhin-d by DirectProject.
the class AuthorityInfoAccessExtentionField_injectReferenceValueTest method testInjectRefereneValue_aiaDoesNotExist_notRequired_assertValueEmpty.
public void testInjectRefereneValue_aiaDoesNotExist_notRequired_assertValueEmpty() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("altNameOnly.der");
final AuthorityInfoAccessExtentionField field = new AuthorityInfoAccessExtentionField(false);
field.injectReferenceValue(cert);
assertTrue(field.getPolicyValue().getPolicyValue().isEmpty());
}
use of org.nhindirect.policy.x509.AuthorityInfoAccessExtentionField in project nhin-d by DirectProject.
the class AuthorityInfoAccessExtentionField_injectReferenceValueTest method testInjectRefereneValue_aiaDoesNotExist_required_assertException.
public void testInjectRefereneValue_aiaDoesNotExist_required_assertException() throws Exception {
final X509Certificate cert = TestUtils.loadCertificate("altNameOnly.der");
final AuthorityInfoAccessExtentionField field = new AuthorityInfoAccessExtentionField(true);
boolean exceptionOccured = false;
try {
field.injectReferenceValue(cert);
} catch (PolicyRequiredException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.policy.x509.AuthorityInfoAccessExtentionField in project nhin-d by DirectProject.
the class TrustChainValidator method getIntermediateCertsByAIA.
/**
* Retrieves intermediate certificate using the AIA extension.
* @param certificate The certificate to search for AIA extensions.
* @return Returns a collection of intermediate certs using the AIA extension. If the AIA extension does not exists
* or the certificate cannot be downloaded from the URL, then an empty list is returned.
*/
protected Collection<X509Certificate> getIntermediateCertsByAIA(X509Certificate certificate) {
final Collection<X509Certificate> retVal = new ArrayList<X509Certificate>();
// check to see if there are extensions
final AuthorityInfoAccessExtentionField aiaField = new AuthorityInfoAccessExtentionField(false);
try {
// we can get all names from the AuthorityInfoAccessExtentionField objects
aiaField.injectReferenceValue(certificate);
final Collection<String> urlPairs = aiaField.getPolicyValue().getPolicyValue();
// look through all of the values (if they exist) for caIssuers
for (String urlPair : urlPairs) {
if (urlPair.startsWith(CA_ISSUER_CHECK_STRING)) {
// the url pair is in the format of caIssuer:URL... need to break it
// apart to get the url
final String url = urlPair.substring(CA_ISSUER_CHECK_STRING.length());
// now pull the certificate from the URL
try {
final Collection<X509Certificate> intermCerts = downloadCertsFromAIA(url);
retVal.addAll(intermCerts);
} catch (NHINDException e) {
LOGGER.warn("Intermediate cert cannot be resolved from AIA extension.", e);
}
}
}
}///CLOVER:OFF
catch (PolicyProcessException e) {
LOGGER.warn("Intermediate cert cannot be resolved from AIA extension.", e);
}
return retVal;
}
Aggregations