use of org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage.Usage in project xipki by xipki.
the class ProfileConfCreatorDemo method createSingleExtKeyUsage.
private static Usage createSingleExtKeyUsage(ASN1ObjectIdentifier usage, boolean required) {
Usage type = new Usage();
type.setValue(usage.getId());
type.setRequired(required);
String desc = getDescription(usage);
if (desc != null) {
type.setDescription(desc);
}
return type;
}
use of org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage.Usage in project xipki by xipki.
the class ProfileConfCreatorDemo method createExtendedKeyUsage.
private static ExtensionValueType createExtendedKeyUsage(ASN1ObjectIdentifier[] requiredUsages, ASN1ObjectIdentifier[] optionalUsages) {
ExtendedKeyUsage extValue = new ExtendedKeyUsage();
if (requiredUsages != null) {
List<ASN1ObjectIdentifier> oids = Arrays.asList(requiredUsages);
oids = sortOidList(oids);
for (ASN1ObjectIdentifier usage : oids) {
extValue.getUsage().add(createSingleExtKeyUsage(usage, true));
}
}
if (optionalUsages != null) {
List<ASN1ObjectIdentifier> oids = Arrays.asList(optionalUsages);
oids = sortOidList(oids);
for (ASN1ObjectIdentifier usage : oids) {
extValue.getUsage().add(createSingleExtKeyUsage(usage, false));
}
}
return createExtensionValueType(extValue);
}
use of org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage.Usage in project xipki by xipki.
the class ProfileConfCreatorDemo method createKeyUsages.
private static ExtensionValueType createKeyUsages(KeyUsageEnum[] requiredUsages, KeyUsageEnum[] optionalUsages) {
KeyUsage extValue = new KeyUsage();
if (requiredUsages != null) {
for (KeyUsageEnum m : requiredUsages) {
UsageType usage = new UsageType();
usage.setValue(m);
usage.setRequired(true);
extValue.getUsage().add(usage);
}
}
if (optionalUsages != null) {
for (KeyUsageEnum m : optionalUsages) {
UsageType usage = new UsageType();
usage.setValue(m);
usage.setRequired(false);
extValue.getUsage().add(usage);
}
}
return createExtensionValueType(extValue);
}
use of org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage.Usage in project xipki by xipki.
the class XmlX509CertprofileUtil method buildExtKeyUsageOptions.
// method buildKeyUsageOptions
public static Set<ExtKeyUsageControl> buildExtKeyUsageOptions(ExtendedKeyUsage extConf) {
ParamUtil.requireNonNull("extConf", extConf);
List<Usage> usages = extConf.getUsage();
Set<ExtKeyUsageControl> controls = new HashSet<>();
for (Usage m : usages) {
ExtKeyUsageControl usage = new ExtKeyUsageControl(new ASN1ObjectIdentifier(m.getValue()), m.isRequired());
controls.add(usage);
}
return Collections.unmodifiableSet(controls);
}
Aggregations