List of usage examples for org.bouncycastle.asn1.x500 X500NameBuilder addMultiValuedRDN
public X500NameBuilder addMultiValuedRDN(AttributeTypeAndValue[] attrTAndVs)
From source file:org.metaeffekt.dcc.commons.pki.CertificateManager.java
License:Apache License
protected X500NameBuilder createNameBuilder(String prefix) { final X500NameBuilder nameBuilder = new X500NameBuilder(); String subjectString = getProperty(prefix); if (subjectString != null) { RDN[] rdns = BCStyle.INSTANCE.fromString(subjectString); for (RDN rdn : rdns) { if (rdn.isMultiValued()) { nameBuilder.addMultiValuedRDN(rdn.getTypesAndValues()); } else { nameBuilder.addRDN(rdn.getFirst()); }/*from w w w. ja v a 2s . c om*/ } } // multiple attributes can be added using an array-like notation for (Object key : componentProperties.keySet()) { final String attributeKey = String.valueOf(key); if (attributeKey.startsWith(prefix + ".")) { String attributeName = attributeKey.substring(prefix.length() + 1); if (attributeName.contains("[")) { attributeName = attributeName.substring(0, attributeName.indexOf("[")); final ASN1ObjectIdentifier oid = BCStyle.INSTANCE.attrNameToOID(attributeName); nameBuilder.addRDN(oid, getProperty(attributeKey)); } } } // the prefix.CN specifies the main CN. Per default it is the component // name in upper case. String componentCN = getProperty(prefix + "." + PROPERTY_CN, componentName.toUpperCase()); nameBuilder.addRDN(BCStyle.CN, componentCN); return nameBuilder; }