public static Set<String> parse( String distinguishedName, String identifier ) throws Exception
    {
        final Set<String> result = new HashSet<>();

        final LdapName ln = new LdapName( distinguishedName);
        for( final Rdn rdn : ln.getRdns() )
        {
            if( rdn.getType().equalsIgnoreCase( identifier ) )
            {
                result.add( rdn.getValue().toString() );
            }
        }
        return result;
    }
@see <a href="https://stackoverflow.com/questions/2914521/how-to-extract-cn-from-x509certificate-in-java>https://stackoverflow.com/questions/2914521/how-to-extract-cn-from-x509certificate-in-java</a>
xmppserver/src/test/java/org/jivesoftware/util/CertificateManagerTest.java