use of org.nhindirect.policy.PolicyProcessException in project nhin-d by DirectProject.
the class IssuerAttributeField method injectReferenceValue.
/**
* {@inheritDoc}
*/
@Override
public void injectReferenceValue(X509Certificate value) throws PolicyProcessException {
this.certificate = value;
if (rdnAttributeId.equals(RDNAttributeIdentifier.DISTINGUISHED_NAME)) {
final Collection<String> str = Arrays.asList(certificate.getIssuerX500Principal().getName(X500Principal.RFC2253));
this.policyValue = PolicyValueFactory.getInstance(str);
return;
}
DERObject tbsValue = null;
try {
tbsValue = this.getDERObject(certificate.getTBSCertificate());
}///CLOVER:OFF
catch (Exception e) {
throw new PolicyProcessException("Exception parsing TBS certificate fields.", e);
}
///CLOVER:ON
final TBSCertificateStructure tbsStruct = TBSCertificateStructure.getInstance(tbsValue);
final X509Name x509Name = getX509Name(tbsStruct);
@SuppressWarnings("unchecked") final Vector<String> values = x509Name.getValues(new DERObjectIdentifier(getRDNAttributeFieldId().getId()));
if (values.isEmpty() && this.isRequired())
throw new PolicyRequiredException(getFieldName() + " field attribute " + rdnAttributeId.getName() + " is marked as required but is not present.");
final Collection<String> retVal = values;
this.policyValue = PolicyValueFactory.getInstance(retVal);
}
use of org.nhindirect.policy.PolicyProcessException in project nhin-d by DirectProject.
the class SubjectPublicKeyAlgorithmField method injectReferenceValue.
/**
* {@inheritDoc}
*/
@Override
public void injectReferenceValue(X509Certificate value) throws PolicyProcessException {
this.certificate = value;
DERObject tbsValue = null;
try {
tbsValue = this.getDERObject(certificate.getTBSCertificate());
}///CLOVER:OFF
catch (Exception e) {
throw new PolicyProcessException("Exception parsing TBS certificate fields.", e);
}
///CLOVER:ON
final TBSCertificateStructure tbsStruct = TBSCertificateStructure.getInstance(tbsValue);
this.policyValue = PolicyValueFactory.getInstance(tbsStruct.getSubjectPublicKeyInfo().getAlgorithmId().getObjectId().toString());
}
Aggregations