Search in sources :

Example 1 with CertificatePolicyInformation

use of org.xipki.ca.api.profile.x509.CertificatePolicyInformation 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 2 with CertificatePolicyInformation

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

the class XmlX509Certprofile method initCertificatePolicies.

private void initCertificatePolicies(Set<ASN1ObjectIdentifier> extnIds, ExtensionsType extensionsType) throws CertprofileException {
    ASN1ObjectIdentifier type = Extension.certificatePolicies;
    if (!extensionControls.containsKey(type)) {
        return;
    }
    extnIds.remove(type);
    CertificatePolicies extConf = (CertificatePolicies) getExtensionValue(type, extensionsType, CertificatePolicies.class);
    if (extConf == null) {
        return;
    }
    List<CertificatePolicyInformation> policyInfos = XmlX509CertprofileUtil.buildCertificatePolicies(extConf);
    org.bouncycastle.asn1.x509.CertificatePolicies value = XmlX509CertprofileUtil.createCertificatePolicies(policyInfos);
    this.certificatePolicies = new ExtensionValue(extensionControls.get(type).isCritical(), value);
}
Also used : ExtensionValue(org.xipki.ca.api.profile.ExtensionValue) CertificatePolicies(org.xipki.ca.certprofile.x509.jaxb.CertificatePolicies) CertificatePolicyInformation(org.xipki.ca.api.profile.x509.CertificatePolicyInformation) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 3 with CertificatePolicyInformation

use of org.xipki.ca.api.profile.x509.CertificatePolicyInformation 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

CertificatePolicyInformation (org.xipki.ca.api.profile.x509.CertificatePolicyInformation)3 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)2 DirectoryString (org.bouncycastle.asn1.x500.DirectoryString)2 CertificatePolicyQualifier (org.xipki.ca.api.profile.x509.CertificatePolicyQualifier)2 CertificatePolicies (org.xipki.ca.certprofile.x509.jaxb.CertificatePolicies)2 ArrayList (java.util.ArrayList)1 JAXBElement (javax.xml.bind.JAXBElement)1 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)1 PolicyInformation (org.bouncycastle.asn1.x509.PolicyInformation)1 ExtensionValue (org.xipki.ca.api.profile.ExtensionValue)1 CertificatePolicyInformationType (org.xipki.ca.certprofile.x509.jaxb.CertificatePolicyInformationType)1 PolicyQualifiers (org.xipki.ca.certprofile.x509.jaxb.CertificatePolicyInformationType.PolicyQualifiers)1