Search in sources :

Example 1 with ConstantExtValue

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

the class ExtensionsChecker method buildConstantExtesions.

// method getExtensionValue
public static Map<ASN1ObjectIdentifier, QaExtensionValue> buildConstantExtesions(ExtensionsType extensionsType) throws CertprofileException {
    if (extensionsType == null) {
        return null;
    }
    Map<ASN1ObjectIdentifier, QaExtensionValue> map = new HashMap<>();
    for (ExtensionType m : extensionsType.getExtension()) {
        if (m.getValue() == null || !(m.getValue().getAny() instanceof ConstantExtValue)) {
            continue;
        }
        ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(m.getType().getValue());
        if (Extension.subjectAlternativeName.equals(oid) || Extension.subjectInfoAccess.equals(oid) || Extension.biometricInfo.equals(oid)) {
            continue;
        }
        ConstantExtValue extConf = (ConstantExtValue) m.getValue().getAny();
        byte[] encodedValue = extConf.getValue();
        ASN1StreamParser parser = new ASN1StreamParser(encodedValue);
        try {
            parser.readObject();
        } catch (IOException ex) {
            throw new CertprofileException("could not parse the constant extension value", ex);
        }
        QaExtensionValue extension = new QaExtensionValue(m.isCritical(), encodedValue);
        map.put(oid, extension);
    }
    if (CollectionUtil.isEmpty(map)) {
        return null;
    }
    return Collections.unmodifiableMap(map);
}
Also used : QaExtensionValue(org.xipki.ca.qa.internal.QaExtensionValue) HashMap(java.util.HashMap) CertprofileException(org.xipki.ca.api.profile.CertprofileException) ExtensionType(org.xipki.ca.certprofile.x509.jaxb.ExtensionType) IOException(java.io.IOException) ConstantExtValue(org.xipki.ca.certprofile.x509.jaxb.ConstantExtValue) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) ASN1StreamParser(org.bouncycastle.asn1.ASN1StreamParser)

Example 2 with ConstantExtValue

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

the class ProfileConfCreatorDemo method createConstantExtValue.

private static ExtensionValueType createConstantExtValue(byte[] bytes, String desc) {
    ConstantExtValue extValue = new ConstantExtValue();
    extValue.setValue(bytes);
    if (StringUtil.isNotBlank(desc)) {
        extValue.setDescription(desc);
    }
    return createExtensionValueType(extValue);
}
Also used : ConstantExtValue(org.xipki.ca.certprofile.x509.jaxb.ConstantExtValue)

Example 3 with ConstantExtValue

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

the class X509CertprofileQa method buildConstantExtesions.

public static Map<ASN1ObjectIdentifier, QaExtensionValue> buildConstantExtesions(ExtensionsType extensionsType) throws CertprofileException {
    if (extensionsType == null) {
        return null;
    }
    Map<ASN1ObjectIdentifier, QaExtensionValue> map = new HashMap<>();
    for (ExtensionType m : extensionsType.getExtension()) {
        if (m.getValue() == null || !(m.getValue().getAny() instanceof ConstantExtValue)) {
            continue;
        }
        ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(m.getType().getValue());
        if (Extension.subjectAlternativeName.equals(oid) || Extension.subjectInfoAccess.equals(oid) || Extension.biometricInfo.equals(oid)) {
            continue;
        }
        ConstantExtValue extConf = (ConstantExtValue) m.getValue().getAny();
        byte[] encodedValue = extConf.getValue();
        ASN1StreamParser parser = new ASN1StreamParser(encodedValue);
        try {
            parser.readObject();
        } catch (IOException ex) {
            throw new CertprofileException("could not parse the constant extension value", ex);
        }
        QaExtensionValue extension = new QaExtensionValue(m.isCritical(), encodedValue);
        map.put(oid, extension);
    }
    if (CollectionUtil.isEmpty(map)) {
        return null;
    }
    return Collections.unmodifiableMap(map);
}
Also used : QaExtensionValue(org.xipki.ca.qa.internal.QaExtensionValue) HashMap(java.util.HashMap) CertprofileException(org.xipki.ca.api.profile.CertprofileException) ExtensionType(org.xipki.ca.certprofile.x509.jaxb.ExtensionType) IOException(java.io.IOException) ConstantExtValue(org.xipki.ca.certprofile.x509.jaxb.ConstantExtValue) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) ASN1StreamParser(org.bouncycastle.asn1.ASN1StreamParser)

Example 4 with ConstantExtValue

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

the class XmlX509CertprofileUtil method buildConstantExtesions.

// method buildExtKeyUsageOptions
public static Map<ASN1ObjectIdentifier, ExtensionValue> buildConstantExtesions(ExtensionsType extensionsType) throws CertprofileException {
    if (extensionsType == null) {
        return null;
    }
    Map<ASN1ObjectIdentifier, ExtensionValue> map = new HashMap<>();
    for (ExtensionType m : extensionsType.getExtension()) {
        ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(m.getType().getValue());
        if (Extension.subjectAlternativeName.equals(oid) || Extension.subjectInfoAccess.equals(oid) || Extension.biometricInfo.equals(oid)) {
            continue;
        }
        if (m.getValue() == null || !(m.getValue().getAny() instanceof ConstantExtValue)) {
            continue;
        }
        ConstantExtValue extConf = (ConstantExtValue) m.getValue().getAny();
        byte[] encodedValue = extConf.getValue();
        ASN1StreamParser parser = new ASN1StreamParser(encodedValue);
        ASN1Encodable value;
        try {
            value = parser.readObject();
        } catch (IOException ex) {
            throw new CertprofileException("could not parse the constant extension value", ex);
        }
        ExtensionValue extension = new ExtensionValue(m.isCritical(), value);
        map.put(oid, extension);
    }
    if (CollectionUtil.isEmpty(map)) {
        return null;
    }
    return Collections.unmodifiableMap(map);
}
Also used : ExtensionValue(org.xipki.ca.api.profile.ExtensionValue) HashMap(java.util.HashMap) CertprofileException(org.xipki.ca.api.profile.CertprofileException) ExtensionType(org.xipki.ca.certprofile.x509.jaxb.ExtensionType) ASN1Encodable(org.bouncycastle.asn1.ASN1Encodable) IOException(java.io.IOException) ConstantExtValue(org.xipki.ca.certprofile.x509.jaxb.ConstantExtValue) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) ASN1StreamParser(org.bouncycastle.asn1.ASN1StreamParser)

Aggregations

ConstantExtValue (org.xipki.ca.certprofile.x509.jaxb.ConstantExtValue)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)3 ASN1StreamParser (org.bouncycastle.asn1.ASN1StreamParser)3 CertprofileException (org.xipki.ca.api.profile.CertprofileException)3 ExtensionType (org.xipki.ca.certprofile.x509.jaxb.ExtensionType)3 QaExtensionValue (org.xipki.ca.qa.internal.QaExtensionValue)2 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)1 ExtensionValue (org.xipki.ca.api.profile.ExtensionValue)1