Search in sources :

Example 1 with CertificatePolicyQualifier

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

the class CertificatePolicies method createPolicyQualifiers.

// method toXiCertificatePolicies
private static ASN1Sequence createPolicyQualifiers(List<CertificatePolicyQualifier> qualifiers) {
    Args.notNull(qualifiers, "qualifiers");
    List<PolicyQualifierInfo> qualifierInfos = new ArrayList<>(qualifiers.size());
    for (CertificatePolicyQualifier qualifier : qualifiers) {
        PolicyQualifierInfo qualifierInfo;
        if (qualifier.getCpsUri() != null) {
            qualifierInfo = new PolicyQualifierInfo(qualifier.getCpsUri());
        } else if (qualifier.getUserNotice() != null) {
            UserNotice userNotice = new UserNotice(null, qualifier.getUserNotice());
            qualifierInfo = new PolicyQualifierInfo(PolicyQualifierId.id_qt_unotice, userNotice);
        } else {
            qualifierInfo = null;
        }
        if (qualifierInfo != null) {
            qualifierInfos.add(qualifierInfo);
        }
    // PolicyQualifierId qualifierId
    }
    return new DERSequence(qualifierInfos.toArray(new PolicyQualifierInfo[0]));
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ArrayList(java.util.ArrayList) PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo) UserNotice(org.bouncycastle.asn1.x509.UserNotice) CertificatePolicyQualifier(org.xipki.ca.certprofile.xijson.CertificatePolicyQualifier)

Example 2 with CertificatePolicyQualifier

use of org.xipki.ca.certprofile.xijson.CertificatePolicyQualifier 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)2 CertificatePolicyQualifier (org.xipki.ca.certprofile.xijson.CertificatePolicyQualifier)2 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)1 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)1 DERSequence (org.bouncycastle.asn1.DERSequence)1 PolicyInformation (org.bouncycastle.asn1.x509.PolicyInformation)1 PolicyQualifierInfo (org.bouncycastle.asn1.x509.PolicyQualifierInfo)1 UserNotice (org.bouncycastle.asn1.x509.UserNotice)1 CertificatePolicyInformation (org.xipki.ca.certprofile.xijson.CertificatePolicyInformation)1