Search in sources :

Example 1 with GeneralSubtreeBaseType

use of org.xipki.ca.certprofile.x509.jaxb.GeneralSubtreeBaseType 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);
}
Also used : KeyUsageControl(org.xipki.ca.api.profile.x509.KeyUsageControl) ExtKeyUsageControl(org.xipki.ca.api.profile.x509.ExtKeyUsageControl) UsageType(org.xipki.ca.certprofile.x509.jaxb.UsageType) HashSet(java.util.HashSet)

Example 2 with GeneralSubtreeBaseType

use of org.xipki.ca.certprofile.x509.jaxb.GeneralSubtreeBaseType in project xipki by xipki.

the class ProfileConfCreatorDemo method createNameConstraints.

private static NameConstraints createNameConstraints() {
    NameConstraints ret = new NameConstraints();
    GeneralSubtreesType permitted = new GeneralSubtreesType();
    GeneralSubtreeBaseType single = new GeneralSubtreeBaseType();
    single.setDirectoryName("O=example organization, C=DE");
    permitted.getBase().add(single);
    ret.setPermittedSubtrees(permitted);
    GeneralSubtreesType excluded = new GeneralSubtreesType();
    single = new GeneralSubtreeBaseType();
    single.setDirectoryName("OU=bad OU, O=example organization, C=DE");
    excluded.getBase().add(single);
    ret.setExcludedSubtrees(excluded);
    return ret;
}
Also used : NameConstraints(org.xipki.ca.certprofile.x509.jaxb.NameConstraints) GeneralSubtreeBaseType(org.xipki.ca.certprofile.x509.jaxb.GeneralSubtreeBaseType) GeneralSubtreesType(org.xipki.ca.certprofile.x509.jaxb.GeneralSubtreesType)

Aggregations

HashSet (java.util.HashSet)1 ExtKeyUsageControl (org.xipki.ca.api.profile.x509.ExtKeyUsageControl)1 KeyUsageControl (org.xipki.ca.api.profile.x509.KeyUsageControl)1 GeneralSubtreeBaseType (org.xipki.ca.certprofile.x509.jaxb.GeneralSubtreeBaseType)1 GeneralSubtreesType (org.xipki.ca.certprofile.x509.jaxb.GeneralSubtreesType)1 NameConstraints (org.xipki.ca.certprofile.x509.jaxb.NameConstraints)1 UsageType (org.xipki.ca.certprofile.x509.jaxb.UsageType)1