external email in description

This commit is contained in:
Peter Hormanns 2020-03-20 12:02:23 +01:00
parent e06cb3dffb
commit 9e036e98b7
2 changed files with 5 additions and 21 deletions

View File

@ -4,14 +4,12 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import de.jalin.ldapadmin.ldap.LDAPConfig;
import de.jalin.ldapadmin.ldap.PasswordValidator;
import de.jalin.ldapadmin.ldap.SimplePasswordException;
public class User implements Serializable, LDAPBean {
private static final long serialVersionUID = 1L;
private static final String INTERNAL_EMAILDOMAINS = LDAPConfig.getConfig().getSmtpInternalDomains();
private String dn;
private String login;
@ -92,22 +90,6 @@ public class User implements Serializable, LDAPBean {
return emailExternal;
}
public void setEmailAddresses(List<String> emails) {
if (emails != null) {
for (final String email : emails) {
final String[] parts = email.split("@");
if (parts.length == 2) {
final String emailDomain = parts[1];
if (INTERNAL_EMAILDOMAINS.contains(emailDomain)) {
setEmailInternal(email);
} else {
setEmailExternal(email);
}
}
}
}
}
public void setEmailExternal(String email) {
this.emailExternal = email;
}

View File

@ -30,7 +30,8 @@ public class UsersDAO {
final User usr = new User();
usr.setFirstname(session.getStringValue(attribs, "givenName"));
usr.setLastname(session.getStringValue(attribs, "sn"));
usr.setEmailAddresses(session.getListOfValues(attribs, "mail"));
usr.setEmailInternal(session.getStringValue(attribs, "mail"));
usr.setEmailExternal(session.getStringValue(attribs, "description"));
usr.setLogin(session.getStringValue(attribs, "uid"));
usr.setPhone(session.getStringValue(attribs, "telephoneNumber"));
usr.setMobile(session.getStringValue(attribs, "mobile"));
@ -105,7 +106,8 @@ public class UsersDAO {
final User usr = new User();
usr.setFirstname(session.getStringValue(attribs, "givenName"));
usr.setLastname(session.getStringValue(attribs, "sn"));
usr.setEmailAddresses(session.getListOfValues(attribs, "mail"));
usr.setEmailExternal(session.getStringValue(attribs, "description"));
usr.setEmailInternal(session.getStringValue(attribs, "mail"));
usr.setLogin(session.getStringValue(attribs, "uid"));
usr.setPhone(session.getStringValue(attribs, "telephoneNumber"));
usr.setMobile(session.getStringValue(attribs, "mobile"));
@ -130,7 +132,7 @@ public class UsersDAO {
}
final String emailExternal = usr.getEmailExternal();
if (hasValue(emailExternal)) {
emailAdressList.add(emailExternal);
addStringAttrUpdate(updates, attribs, "description", emailExternal);
}
addMultiValueAttrUpdate(updates, attribs, "mail", emailAdressList);
addStringAttrUpdate(updates, attribs, "givenName", usr.getFirstname());