Search in sources :

Example 1 with Usage

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;
}
Also used : KeyUsage(org.xipki.ca.certprofile.x509.jaxb.KeyUsage) ExtendedKeyUsage(org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage) Usage(org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage.Usage)

Example 2 with Usage

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);
}
Also used : ExtendedKeyUsage(org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 3 with Usage

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);
}
Also used : KeyUsage(org.xipki.ca.certprofile.x509.jaxb.KeyUsage) ExtendedKeyUsage(org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage) UsageType(org.xipki.ca.certprofile.x509.jaxb.UsageType) KeyUsageEnum(org.xipki.ca.certprofile.x509.jaxb.KeyUsageEnum)

Example 4 with Usage

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);
}
Also used : ExtendedKeyUsage(org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage) Usage(org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage.Usage) KeyUsage(org.xipki.security.KeyUsage) ExtKeyUsageControl(org.xipki.ca.api.profile.x509.ExtKeyUsageControl) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) HashSet(java.util.HashSet)

Aggregations

ExtendedKeyUsage (org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage)4 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)2 Usage (org.xipki.ca.certprofile.x509.jaxb.ExtendedKeyUsage.Usage)2 KeyUsage (org.xipki.ca.certprofile.x509.jaxb.KeyUsage)2 HashSet (java.util.HashSet)1 ExtKeyUsageControl (org.xipki.ca.api.profile.x509.ExtKeyUsageControl)1 KeyUsageEnum (org.xipki.ca.certprofile.x509.jaxb.KeyUsageEnum)1 UsageType (org.xipki.ca.certprofile.x509.jaxb.UsageType)1 KeyUsage (org.xipki.security.KeyUsage)1