Search in sources :

Example 1 with CertificatePolicyInformation

use of org.xipki.ca.certprofile.xijson.CertificatePolicyInformation in project xipki by xipki.

the class CertificatePolicies method toXiCertificatePolicies.

public org.bouncycastle.asn1.x509.CertificatePolicies toXiCertificatePolicies() {
    List<CertificatePolicyInformationType> policyPairs = getCertificatePolicyInformations();
    List<CertificatePolicyInformation> policyInfos = new ArrayList<>(policyPairs.size());
    for (CertificatePolicyInformationType policyPair : policyPairs) {
        List<CertificatePolicyQualifier> qualifiers = null;
        List<PolicyQualifier> policyQualifiers = policyPair.getPolicyQualifiers();
        if (!policyQualifiers.isEmpty()) {
            qualifiers = new ArrayList<>(policyQualifiers.size());
            for (PolicyQualifier m : policyQualifiers) {
                CertificatePolicyQualifier qualifier = m.getType() == PolicyQualfierType.cpsUri ? CertificatePolicyQualifier.getInstanceForCpsUri(m.getValue()) : CertificatePolicyQualifier.getInstanceForUserNotice(m.getValue());
                qualifiers.add(qualifier);
            }
        }
        CertificatePolicyInformation cpi = new CertificatePolicyInformation(policyPair.getPolicyIdentifier().getOid(), qualifiers);
        policyInfos.add(cpi);
    }
    int size = policyInfos.size();
    PolicyInformation[] infos = new PolicyInformation[size];
    int idx = 0;
    for (CertificatePolicyInformation policyInfo : policyInfos) {
        String policyId = policyInfo.getCertPolicyId();
        List<CertificatePolicyQualifier> qualifiers = policyInfo.getQualifiers();
        ASN1Sequence policyQualifiers = null;
        if (CollectionUtil.isNotEmpty(qualifiers)) {
            policyQualifiers = createPolicyQualifiers(qualifiers);
        }
        ASN1ObjectIdentifier policyOid = new ASN1ObjectIdentifier(policyId);
        infos[idx++] = (policyQualifiers == null) ? new PolicyInformation(policyOid) : new PolicyInformation(policyOid, policyQualifiers);
    }
    return new org.bouncycastle.asn1.x509.CertificatePolicies(infos);
}
Also used : CertificatePolicyInformation(org.xipki.ca.certprofile.xijson.CertificatePolicyInformation) PolicyInformation(org.bouncycastle.asn1.x509.PolicyInformation) ArrayList(java.util.ArrayList) CertificatePolicyQualifier(org.xipki.ca.certprofile.xijson.CertificatePolicyQualifier) CertificatePolicyQualifier(org.xipki.ca.certprofile.xijson.CertificatePolicyQualifier) ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) CertificatePolicyInformation(org.xipki.ca.certprofile.xijson.CertificatePolicyInformation) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

ArrayList (java.util.ArrayList)1 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)1 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)1 PolicyInformation (org.bouncycastle.asn1.x509.PolicyInformation)1 CertificatePolicyInformation (org.xipki.ca.certprofile.xijson.CertificatePolicyInformation)1 CertificatePolicyQualifier (org.xipki.ca.certprofile.xijson.CertificatePolicyQualifier)1