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);
}
Aggregations