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