private String getSubjectDirectoryAttributesStringValue(byte[] value) throws IOException { // @formatter:off /* * SubjectDirectoryAttributes ::= ASN1Sequence SIZE (1..MAX) OF Attribute * * Attribute ::= ASN1Sequence * { * type AttributeType, * values SET OF AttributeValue * } */ // @formatter:on StringBuilder sb = new StringBuilder(); SubjectDirectoryAttributes subjectDirectoryAttributes = SubjectDirectoryAttributes.getInstance(value); for (Object attribute : subjectDirectoryAttributes.getAttributes()) { ASN1ObjectIdentifier attributeType = ((Attribute) attribute).getAttrType(); String attributeTypeStr = attributeType.getId(); ASN1Encodable[] attributeValues = ((Attribute) attribute).getAttributeValues(); for (ASN1Encodable attributeValue : attributeValues) { String attributeValueStr = getAttributeValueString(attributeType, attributeValue); sb.append(MessageFormat.format("{0}={1}", attributeTypeStr, attributeValueStr)); sb.append(NEWLINE); } } return sb.toString(); }