Code example for X500Principal

Methods: getName

0
        p = new X500Principal("CN=user");
        p.getName("RFC2253", m1);
 
        // override builtin OIDs 
        m1 = Collections.singletonMap("2.5.4.3", "FOO");
        p = new X500Principal("CN=user");
        if (!p.getName("RFC2253", m1).startsWith("FOO")) {
            throw new Exception("mapping did not override builtin OID");
        } 
 
        // disallow CANONICAL format 
        try { 
            p.getName("CANONICAL", m1);
            throw new Exception
                ("expected IllegalArgumentException for CANONICAL format"); 
        } catch (IllegalArgumentException iae) {}
        // disallow invalid format 
        try { 
            p.getName("YABBADABBADOO", m1);
            throw new Exception
                ("expected IllegalArgumentException for invalid format"); 
        } catch (IllegalArgumentException iae) {}
 
        // map OIDs