Example usage for javax.naming.ldap Rdn Rdn

List of usage examples for javax.naming.ldap Rdn Rdn

Introduction

In this page you can find the example usage for javax.naming.ldap Rdn Rdn.

Prototype

public Rdn(Rdn rdn) 

Source Link

Document

Constructs an Rdn from the given rdn .

Usage

From source file:RdntoString.java

public static void main(String args[]) throws Exception {
    Rdn rdn = new Rdn("cn=Juicy\\,Fruit");
    String str = rdn.toString();/* w  ww .  j  a va  2  s . c o  m*/
    System.out.println(str);
    Rdn rdn2 = new Rdn(str);
    System.out.println(rdn.equals(rdn2)); // true
}

From source file:RdnConstructors.java

public static void main(String args[]) throws Exception {
    /**//  w  ww.  ja  v  a  2  s .com
     * There are four ways of constructing an Rdn
     */
    Rdn rdn1 = new Rdn("ou= Juicy\\, Fruit");
    System.out.println("rdn1:" + rdn1.toString());

    Rdn rdn2 = new Rdn(rdn1);
    System.out.println("rdn2:" + rdn2.toString());

    Attributes attrs = new BasicAttributes();
    attrs.put("ou", "Juicy, Fruit");
    attrs.put("cn", "Mango");
    Rdn rdn3 = new Rdn(attrs);
    System.out.println("rdn3:" + rdn3.toString());

    Rdn rdn4 = new Rdn("ou", "Juicy, Fruit");
    System.out.println("rdn4:" + rdn4.toString());
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    /**//from  w w w.  j  a  v a2  s . c  o  m
     * Compare: 1) same RDN sequence with an type/value pairs ordered
     * differently. 2) RDN sequence of different length. 3) RDN sequence of
     * different Case.
     */
    Rdn one = new Rdn("ou=Sales+cn=Bob");
    Rdn two = new Rdn("cn=Bob+ou=Sales");
    Rdn three = new Rdn("ou=Sales+cn=Bob+c=US");
    Rdn four = new Rdn("cn=lowercase");
    Rdn five = new Rdn("cn=LowerCASE");
    System.out.println(one.equals(two)); // true
    System.out.println(two.equals(three)); // false
    System.out.println(one.equals(three)); // false
    System.out.println(four.equals(five)); // true
}

From source file:CompareRdns.java

public static void main(String args[]) throws Exception {

    /**/*  w  w  w  .  j  a  v a 2  s.  co m*/
     * Compare: 1) same RDN sequence with an type/value pairs ordered
     * differently. 2) RDN sequence of different length. 3) RDN sequence of
     * different Case.
     */
    Rdn one = new Rdn("ou=Sales+cn=Bob");
    Rdn two = new Rdn("cn=Bob+ou=Sales");
    Rdn three = new Rdn("ou=Sales+cn=Bob+c=US");
    Rdn four = new Rdn("cn=lowercase");
    Rdn five = new Rdn("cn=LowerCASE");
    System.out.println(one.equals(two)); // true
    System.out.println(two.equals(three)); // false
    System.out.println(one.equals(three)); // false
    System.out.println(four.equals(five)); // true
}

From source file:RdnGetters.java

public static void main(String args[]) throws Exception {
    Attributes attrs = new BasicAttributes();
    attrs.put("o", "Yellow");
    attrs.put("cn", "Mango");

    byte[] mangoJuice = new byte[6];
    for (int i = 0; i < mangoJuice.length; i++) {
        mangoJuice[i] = (byte) i;
    }//w w w.j  ava  2 s . c o  m
    attrs.put("ou", mangoJuice);
    Rdn rdn = new Rdn(attrs);

    System.out.println();
    System.out.println("size:" + rdn.size());
    System.out.println("getType(): " + rdn.getType());
    System.out.println("getValue(): " + rdn.getValue());

    // test toAttributes
    System.out.println();
    System.out.println("toAttributes(): " + rdn.toAttributes());
}

From source file:org.easy.ldap.NamingFactory.java

public static Rdn createRdn(String rdn) {
    try {/*from   ww w.j a  v  a  2 s .co m*/
        return new Rdn(rdn);
    } catch (InvalidNameException e) {
        throw new RuntimeException(rdn, e);
    }
}

From source file:org.tolven.gatekeeper.CertificateHelper.java

public static X500Principal getX500Principal(String email, String commonName, String organizationUnitName,
        String organizationName, String stateOrProvince) {
    if (null == email || null == commonName || null == organizationUnitName || null == organizationName
            || null == stateOrProvince) {
        throw new RuntimeException(
                "Certificate requires EmailAddress, Common Name, organizationUnitName, organizationName, stateOrProvince");
    }/*from  w  w  w  .  ja  v  a2  s  .  co m*/
    Attributes attributes = new BasicAttributes();
    attributes.put(X509Name.EmailAddress.toString(), email);
    attributes.put(X509Name.CN.toString(), commonName);
    attributes.put(X509Name.OU.toString(), organizationUnitName);
    attributes.put(X509Name.O.toString(), organizationName);
    attributes.put(X509Name.ST.toString(), stateOrProvince);
    Rdn rdn;
    try {
        rdn = new Rdn(attributes);
    } catch (InvalidNameException ex) {
        throw new RuntimeException("Failed to obtain a Relative Distinguised Name", ex);
    }
    return new X500Principal(rdn.toString());
}