@Override public String format(final X500Principal dn) { final StringBuilder builder = new StringBuilder(); final RDNSequence sequence = NameReader.readX500Principal(dn); int i = 0; for (RDN rdn : sequence.backward()) { if (i++ > 0) { builder.append(RDN_SEPARATOR); } int j = 0; for (Attribute attr : rdn.getAttributes()) { if (j++ > 0) { builder.append(ATV_SEPARATOR); } builder.append(attr.getType()).append('='); final AttributeType type = attr.getType(); if (type instanceof StandardAttributeType) { escape(attr.getValue(), builder); } else { encode(attr.getValue(), builder); } } } return builder.toString(); }