use of org.xipki.ca.certprofile.x509.jaxb.UsageType 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.UsageType in project xipki by xipki.
the class XmlX509CertprofileUtil method buildKeyUsageOptions.
// method toOidList
public static Set<KeyUsageControl> buildKeyUsageOptions(org.xipki.ca.certprofile.x509.jaxb.KeyUsage extConf) {
ParamUtil.requireNonNull("extConf", extConf);
List<UsageType> usages = extConf.getUsage();
Set<KeyUsageControl> controls = new HashSet<>();
for (UsageType m : usages) {
boolean required = m.isRequired();
switch(m.getValue()) {
case CRL_SIGN:
controls.add(new KeyUsageControl(KeyUsage.cRLSign, required));
break;
case DATA_ENCIPHERMENT:
controls.add(new KeyUsageControl(KeyUsage.dataEncipherment, required));
break;
case CONTENT_COMMITMENT:
controls.add(new KeyUsageControl(KeyUsage.contentCommitment, required));
break;
case DECIPHER_ONLY:
controls.add(new KeyUsageControl(KeyUsage.decipherOnly, required));
break;
case ENCIPHER_ONLY:
controls.add(new KeyUsageControl(KeyUsage.encipherOnly, required));
break;
case DIGITAL_SIGNATURE:
controls.add(new KeyUsageControl(KeyUsage.digitalSignature, required));
break;
case KEY_AGREEMENT:
controls.add(new KeyUsageControl(KeyUsage.keyAgreement, required));
break;
case KEY_CERT_SIGN:
controls.add(new KeyUsageControl(KeyUsage.keyCertSign, required));
break;
case KEY_ENCIPHERMENT:
controls.add(new KeyUsageControl(KeyUsage.keyEncipherment, required));
break;
default:
throw new RuntimeException("should not reach here, unknown GeneralSubtreeBaseType " + m.getValue());
}
}
return Collections.unmodifiableSet(controls);
}
Aggregations