String o = CertTools.getPartFromDN(dn, "O"); if (o != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("o", o)); } String uid = CertTools.getPartFromDN(dn, "uid"); if (uid != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("uid", uid)); } String initials = CertTools.getPartFromDN(dn, "initials"); if (initials != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("initials", initials)); } String title = CertTools.getPartFromDN(dn, "T"); if (title != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("title", title)); }
if (person) {  String sn = CertTools.getPartFromDN(dn, "SURNAME"); if ( (sn == null) && (cn != null) ) {  int index = cn.lastIndexOf(' '); if (index <=0) {  sn = cn; } else { if (index < cn.length()) sn = cn.substring(index+1); } } if (sn != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("sn", sn)); }  String gn = CertTools.getPartFromDN(dn, "GIVENNAME"); 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) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("gn", gn)); } String st = CertTools.getPartFromDN(dn, "ST"); if (st != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("st", st)); } String o = CertTools.getPartFromDN(dn, "O"); if (o != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("o", o)); } String uid = CertTools.getPartFromDN(dn, "uid"); if (uid != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("uid", uid)); } String initials = CertTools.getPartFromDN(dn, "initials"); if (initials != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("initials", initials)); } String title = CertTools.getPartFromDN(dn, "T"); if (title != null) { modSet.add(LDAPModification.REPLACE, new LDAPAttribute("title", title)); } }
    protected LDAPModificationSet getModificationSet(LDAPEntry oldEntry, String dn, boolean extra, boolean person) {        LDAPModificationSet modSet = new LDAPModificationSet();        if (extra) {            String cn = CertTools.getPartFromDN(dn, "CN");            if (cn != null) {                modSet.add(LDAPModification.REPLACE, new LDAPAttribute("cn", cn));            }            // sn means surname in LDAP, and is required for persons            String sn = CertTools.getPartFromDN(dn, "SURNAME");            if (person) {                if ( (sn == null) && (cn != null) ) {                    // Take surname to be the last part of the cn                    int index = cn.lastIndexOf(' ');                    if (index <=0) {                        // If there is no natural sn, use cn since sn is required                        sn = cn;                    } else {                        if (index < cn.length()) sn = cn.substring(index+1);                    }                }            }            if (sn != null) {                modSet.add(LDAPModification.REPLACE, new LDAPAttribute("sn", sn));            }            // gn means givenname in LDAP, and is required for persons            String gn = CertTools.getPartFromDN(dn, "GIVENNAME");            if (person) {                if ( (gn == null) && (cn != null) ) {                    // Take givenname to be the first part of the cn                    int index = cn.indexOf(' ');                    if (index <=0) {                        // If there is no natural gn/sn, ignore gn if we are using sn                        if (sn == null) gn = cn;                    } else {                        gn = cn.substring(0, index);                    }                }            }            if (gn != null) {                modSet.add(LDAPModification.REPLACE, new LDAPAttribute("gn", gn));            }            String l = CertTools.getPartFromDN(dn, "L");            if (l != null) {                modSet.add(LDAPModification.REPLACE, new LDAPAttribute("l", l));            }            String st = CertTools.getPartFromDN(dn, "ST");            if (st != null) {                modSet.add(LDAPModification.REPLACE, new LDAPAttribute("st", st));            }            String ou = CertTools.getPartFromDN(dn, "OU");            if (ou != null) {                modSet.add(LDAPModification.REPLACE, new LDAPAttribute("ou", ou));            }            String o = CertTools.getPartFromDN(dn, "O");            if (o != null) {            	modSet.add(LDAPModification.REPLACE, new LDAPAttribute("o", o));            }            String uid = CertTools.getPartFromDN(dn, "uid");            if (uid != null) {                modSet.add(LDAPModification.REPLACE, new LDAPAttribute("uid", uid));            }            String initials = CertTools.getPartFromDN(dn, "initials");            if (initials != null) {            	modSet.add(LDAPModification.REPLACE, new LDAPAttribute("initials", initials));            }                    String title = CertTools.getPartFromDN(dn, "T");            if (title != null) {            	modSet.add(LDAPModification.REPLACE, new LDAPAttribute("title", title));            }        }        return modSet;    } // getModificationSet