/** * Adds an attribute by type and value to the end of the attribute list. * * @param typeOid OID of attribute type. * @param value Attribute value. */ public void add(final String typeOid, final String value) { final StandardAttributeType type = StandardAttributeType.fromOid(typeOid); if (type != null) { add(new Attribute(type, value)); } else { add(new Attribute(new UnknownAttributeType(typeOid), value)); } }
/** * Converts the given X.500 principal to a list of relative distinguished names that contains the attributes * comprising the DN. * * @param principal Principal to convert. * * @return X500 principal as an RDN sequence. */ public static RDNSequence readX500Principal(final X500Principal principal) { final X500Name name = X500Name.getInstance(principal.getEncoded()); final RDNSequence sequence = new RDNSequence(); for (org.bouncycastle.asn1.x500.RDN rdn : name.getRDNs()) { final Attributes attributes = new Attributes(); for (AttributeTypeAndValue tv : rdn.getTypesAndValues()) { attributes.add(tv.getType().getId(), tv.getValue().toString()); } sequence.add(new RDN(attributes)); } return sequence; } }