Search in sources :

Example 11 with PolicyProcessException

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);
}
Also used : PolicyRequiredException(org.nhindirect.policy.PolicyRequiredException) DERObject(org.bouncycastle.asn1.DERObject) X509Name(org.bouncycastle.asn1.x509.X509Name) TBSCertificateStructure(org.bouncycastle.asn1.x509.TBSCertificateStructure) DERObjectIdentifier(org.bouncycastle.asn1.DERObjectIdentifier) PolicyRequiredException(org.nhindirect.policy.PolicyRequiredException) PolicyProcessException(org.nhindirect.policy.PolicyProcessException) PolicyProcessException(org.nhindirect.policy.PolicyProcessException)

Example 12 with PolicyProcessException

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());
}
Also used : DERObject(org.bouncycastle.asn1.DERObject) TBSCertificateStructure(org.bouncycastle.asn1.x509.TBSCertificateStructure) PolicyProcessException(org.nhindirect.policy.PolicyProcessException) PolicyProcessException(org.nhindirect.policy.PolicyProcessException)

Aggregations

PolicyProcessException (org.nhindirect.policy.PolicyProcessException)12 X509Certificate (java.security.cert.X509Certificate)4 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)3 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)3 PolicyExpression (org.nhindirect.policy.PolicyExpression)3 InternetAddress (javax.mail.internet.InternetAddress)2 DERObject (org.bouncycastle.asn1.DERObject)2 TBSCertificateStructure (org.bouncycastle.asn1.x509.TBSCertificateStructure)2 PolicyFilter (org.nhindirect.policy.PolicyFilter)2 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)2 StackMachine (org.nhindirect.policy.impl.machine.StackMachine)2 PolicyResolver (org.nhindirect.stagent.policy.PolicyResolver)2 ArrayList (java.util.ArrayList)1 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)1 DERSequence (org.bouncycastle.asn1.DERSequence)1 X509Name (org.bouncycastle.asn1.x509.X509Name)1 CMSException (org.bouncycastle.cms.CMSException)1 AuthorityInfoAccessExtentionField (org.nhindirect.policy.x509.AuthorityInfoAccessExtentionField)1 AgentException (org.nhindirect.stagent.AgentException)1 NHINDException (org.nhindirect.stagent.NHINDException)1