}  String gn = CertTools.getPartFromDN(dn, "GIVENNAME"); if (person) { if ( (gn == null) && (cn != null) ) {  int index = cn.indexOf(' '); if (index <=0) {  if (sn == null) gn = cn; } else { gn = cn.substring(0, index); } } } if (gn != null) { attributeSet.add(new LDAPAttribute("gn", gn));
    private LDAPAttributeSet getAttributeSet(String objectclass, String dn, boolean extra) {        LDAPAttributeSet attributeSet = new LDAPAttributeSet();        LDAPAttribute attr = new LDAPAttribute("objectclass");        attr.addValue("top");        attr.addValue("person");        attr.addValue(objectclass);        attributeSet.add(attr);                /* To Add an entry to the directory,         *   -- Create the attributes of the entry and add them to an attribute set         *   -- Specify the DN of the entry to be created         *   -- Create an LDAPEntry object with the DN and the attribute set         *   -- Call the LDAPConnection add method to add it to the directory         */        //attributeSet.add(new LDAPAttribute("objectclass", objectclass));        if (extra) {            String cn = CertTools.getPartFromDN(dn, "CN");            if (cn != null) {                attributeSet.add(new LDAPAttribute("cn", cn));            }            String sn = CertTools.getPartFromDN(dn, "SN");            if (sn != null) {                attributeSet.add(new LDAPAttribute("sn", sn));            }            String l = CertTools.getPartFromDN(dn, "L");            if (l != null) {                attributeSet.add(new LDAPAttribute("l", l));            }            String st = CertTools.getPartFromDN(dn, "ST");            if (st != null) {                attributeSet.add(new LDAPAttribute("st", st));            }            String ou = CertTools.getPartFromDN(dn, "OU");            if (ou != null) {                attributeSet.add(new LDAPAttribute("ou", ou));            }        }        return attributeSet;    } // getAttributeSet