Package javax.naming.ldap

Examples of javax.naming.ldap.Rdn


    private String getCn(X509Certificate cert) {
        String dn = getDn(cert);
        try {
            List<Rdn> rdns = new LdapName(dn).getRdns();
            for (int i = rdns.size() - 1; i >= 0; i--) {
                Rdn rdn = rdns.get(i);
                if (rdn.getType().equalsIgnoreCase("CN")) {
                    String cn = rdn.getValue().toString();
                    LOGGER.debug("certificate CN is [%s]", cn);
                    return cn;
                }
            }
        } catch (InvalidNameException ine) {
View Full Code Here


     * </p>
     */
    public void testLdapNameListOfRdn001() throws Exception {

        LinkedList<Rdn> test = new LinkedList<Rdn>();
        test.add(new Rdn("CN=commonName"));
        test.add(new Rdn("L=localityName"));
        test.add(new Rdn("ST=stateOrProvinceName"));
        test.add(new Rdn("O=organizationName"));
        test.add(new Rdn("OU=organizationalUnitName"));
        assertNotNull(new LdapName(test));

    }
View Full Code Here

     * correct.
     * </p>
     */
    public void testLdapNameListOfRdn004() throws Exception {
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        test.add(new Rdn("CN=commonName"));
        test.add(new Rdn("L=localityName"));
        test.add(new Rdn("ST=stateOrProvinceName"));
        test.add(new Rdn("O=organizationName"));
        test.add(new Rdn("OU=organizationalUnitName"));

        LdapName x = new LdapName(test);
        assertNotNull(x);
        List t = x.getRdns();

        int i = 0;
        for (Iterator iter = test.iterator(); iter.hasNext();) {
            Rdn element = (Rdn) iter.next();
            assertEquals(element.toString(), t.get(i).toString());
            i++;
        }
    }
View Full Code Here

     */
    public void testLdapNameListOfRdn005() throws Exception {
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        LdapName x = null;

        test.add(new Rdn("CN", new LinkedList()));
        test.add(new Rdn("L", new LinkedList()));
        test.add(new Rdn("ST", new LinkedList()));
        test.add(new Rdn("O", new LinkedList()));
        test.add(new Rdn("OU", new LinkedList()));

        x = new LdapName(test);
        assertNotNull(x);

        try {
View Full Code Here

        try {
            BasicAttributes bas = new BasicAttributes();
            bas.put("test2", "test2");
            bas.put("test1", "test1");
            bas.put("test3", "test3");
            Rdn rdn1 = new Rdn(bas);
            LinkedList<Rdn> rdns = new LinkedList<Rdn>();
            rdns.add(rdn1);
            LdapName ln = new LdapName(rdns);
            assertEquals("test1=test1+test2=test2+test3=test3", ln.getAll().nextElement());
        } catch (Exception e) {
View Full Code Here

     * in the LdapName and the hash of the list, this method returns the sum of
     * all Rdns hashcodes.
     * </p>
     */
    public void testHashCode002() throws Exception {
        Rdn t = new Rdn("");
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        test.add(t);
        LdapName ln = new LdapName(test);
        assertEquals(0, t.hashCode() & ln.hashCode());
        assertEquals(t.hashCode(), ln.hashCode());
    }
View Full Code Here

     * in the LdapName and the list, this method returns the sum of all Rdns
     * hashcodes.
     * </p>
     */
    public void testHashCode003() throws Exception {
        Rdn rdn1 = new Rdn("CN=commonName");
        Rdn rdn2 = new Rdn("t=test");
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        test.add(rdn1);
        test.add(rdn2);
        LdapName ln = new LdapName(test);
        assertEquals(rdn1.hashCode() + rdn2.hashCode(), ln.hashCode());
    }
View Full Code Here

     * return the strings in the LIFO way.
     * </p>
     */
    public void testToString002() throws Exception {
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        test.add(new Rdn("c1=common"));
        test.add(new Rdn("c2=common"));
        test.add(new Rdn("c3=common"));
        LdapName ln = new LdapName(test);
        String comp = "";
        for (Rdn rdn : test) {
            if (test.getFirst() == rdn) {
                comp = rdn.toString();
View Full Code Here

     * enumeration, and ordered like it should be.
     * </p>
     */
    public void testGetAll003() throws Exception {
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        Rdn a = new Rdn("cn", "test");
        Rdn b = new Rdn("uid", "test");
        Rdn c = new Rdn("l", "test");
        Rdn d = new Rdn("st", "test");
        test.add(0, a);
        test.add(1, b);
        test.add(2, c);
        test.add(3, d);
        LdapName ln = new LdapName(test);
View Full Code Here

     * was created with two Rdn.
     * </p>
     */
    public void testGet005() throws Exception {
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        test.add(0, new Rdn("t=test"));
        test.add(1, new Rdn("t1=test"));
        LdapName ln = new LdapName(test);
        assertNotNull(ln.get(0));// the range of this name is 0-1
        assertNotNull(ln.get(1));
    }
View Full Code Here

TOP

Related Classes of javax.naming.ldap.Rdn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.