use of org.xipki.ca.certprofile.x509.jaxb.ExtensionType in project xipki by xipki.
the class XmlX509CertprofileUtil method buildExtensionControls.
// method buildKeyAlgorithms
public static Map<ASN1ObjectIdentifier, ExtensionControl> buildExtensionControls(ExtensionsType extensionsType) throws CertprofileException {
ParamUtil.requireNonNull("extensionsType", extensionsType);
// Extension controls
Map<ASN1ObjectIdentifier, ExtensionControl> controls = new HashMap<>();
for (ExtensionType m : extensionsType.getExtension()) {
ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(m.getType().getValue());
if (controls.containsKey(oid)) {
throw new CertprofileException("duplicated definition of extension " + oid.getId());
}
ExtensionControl ctrl = new ExtensionControl(m.isCritical(), m.isRequired(), m.isPermittedInRequest());
controls.put(oid, ctrl);
}
return Collections.unmodifiableMap(controls);
}
use of org.xipki.ca.certprofile.x509.jaxb.ExtensionType 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);
}
Aggregations