Search in sources :

Example 1 with CertificatePolicyQualifier

use of org.xipki.ca.api.profile.x509.CertificatePolicyQualifier in project xipki by xipki.

the class XmlX509CertprofileUtil method createPolicyQualifiers.

private static ASN1Sequence createPolicyQualifiers(List<CertificatePolicyQualifier> qualifiers) {
    ParamUtil.requireNonNull("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(PKCSObjectIdentifiers.id_spq_ets_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.api.profile.x509.CertificatePolicyQualifier)

Example 2 with CertificatePolicyQualifier

use of org.xipki.ca.api.profile.x509.CertificatePolicyQualifier in project xipki by xipki.

the class XmlX509CertprofileUtil method createCertificatePolicies.

public static org.bouncycastle.asn1.x509.CertificatePolicies createCertificatePolicies(List<CertificatePolicyInformation> policyInfos) throws CertprofileException {
    ParamUtil.requireNonEmpty("policyInfos", policyInfos);
    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.isNonEmpty(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 : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) PolicyInformation(org.bouncycastle.asn1.x509.PolicyInformation) CertificatePolicyInformation(org.xipki.ca.api.profile.x509.CertificatePolicyInformation) CertificatePolicyInformation(org.xipki.ca.api.profile.x509.CertificatePolicyInformation) CertificatePolicies(org.xipki.ca.certprofile.x509.jaxb.CertificatePolicies) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) CertificatePolicyQualifier(org.xipki.ca.api.profile.x509.CertificatePolicyQualifier) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 3 with CertificatePolicyQualifier

use of org.xipki.ca.api.profile.x509.CertificatePolicyQualifier in project xipki by xipki.

the class XmlX509CertprofileUtil method buildCertificatePolicies.

// method parse
public static List<CertificatePolicyInformation> buildCertificatePolicies(CertificatePolicies type) {
    List<CertificatePolicyInformationType> policyPairs = type.getCertificatePolicyInformation();
    List<CertificatePolicyInformation> policies = new ArrayList<CertificatePolicyInformation>(policyPairs.size());
    for (CertificatePolicyInformationType policyPair : policyPairs) {
        List<CertificatePolicyQualifier> qualifiers = null;
        PolicyQualifiers policyQualifiers = policyPair.getPolicyQualifiers();
        if (policyQualifiers != null) {
            List<JAXBElement<String>> cpsUriOrUserNotice = policyQualifiers.getCpsUriOrUserNotice();
            qualifiers = new ArrayList<CertificatePolicyQualifier>(cpsUriOrUserNotice.size());
            for (JAXBElement<String> element : cpsUriOrUserNotice) {
                String elementValue = element.getValue();
                CertificatePolicyQualifier qualifier = null;
                String elementName = element.getName().getLocalPart();
                qualifier = "cpsUri".equals(elementName) ? CertificatePolicyQualifier.getInstanceForCpsUri(elementValue) : CertificatePolicyQualifier.getInstanceForUserNotice(elementValue);
                qualifiers.add(qualifier);
            }
        }
        CertificatePolicyInformation cpi = new CertificatePolicyInformation(policyPair.getPolicyIdentifier().getValue(), qualifiers);
        policies.add(cpi);
    }
    return policies;
}
Also used : ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) CertificatePolicyQualifier(org.xipki.ca.api.profile.x509.CertificatePolicyQualifier) CertificatePolicyInformationType(org.xipki.ca.certprofile.x509.jaxb.CertificatePolicyInformationType) CertificatePolicyInformation(org.xipki.ca.api.profile.x509.CertificatePolicyInformation) PolicyQualifiers(org.xipki.ca.certprofile.x509.jaxb.CertificatePolicyInformationType.PolicyQualifiers)

Aggregations

CertificatePolicyQualifier (org.xipki.ca.api.profile.x509.CertificatePolicyQualifier)3 ArrayList (java.util.ArrayList)2 DirectoryString (org.bouncycastle.asn1.x500.DirectoryString)2 CertificatePolicyInformation (org.xipki.ca.api.profile.x509.CertificatePolicyInformation)2 JAXBElement (javax.xml.bind.JAXBElement)1 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 CertificatePolicies (org.xipki.ca.certprofile.x509.jaxb.CertificatePolicies)1 CertificatePolicyInformationType (org.xipki.ca.certprofile.x509.jaxb.CertificatePolicyInformationType)1 PolicyQualifiers (org.xipki.ca.certprofile.x509.jaxb.CertificatePolicyInformationType.PolicyQualifiers)1