Code example for X500Principal

0
        assertFirstCn("ou=a, cn=  a  b  ,o=x", "a  b"); 
        assertFirstCn("cn=\"  a  b  \" ,o=x", "  a  b  "); 
    } 
 
    private void assertFirstCn(String dn, String expected) {
        X500Principal principal = new X500Principal(dn);
        assertEquals("dn:" + dn, expected, new DistinguishedNameParser(principal).find("cn"));
    } 
 
    public void testVerify() { 
        assertTrue(verifier.verify("imap.g.com", new StubX509Certificate("cn=imap.g.com")));
        assertFalse(verifier.verify("imap.g.com", new StubX509Certificate("cn=imap2.g.com")));
        assertFalse(verifier.verify("imap.g.com", new StubX509Certificate("cn=sub.imap.g.com")));
    } 
 
    /** 
     * If a subjectAltName extension of type ALT_DNS_NAME is present, that MUST 
     * be used as the identity and the CN should be ignored. 
     */ 
    public void testSubjectAltNameAndCn() { 
        assertFalse(verifier.verify("imap.g.com", new StubX509Certificate("")