robuster, hsadmin

This commit is contained in:
Peter Hormanns 2020-03-25 15:02:09 +01:00
parent ab010e0560
commit 9ea2f82a7b
5 changed files with 35 additions and 6 deletions

View File

@ -33,9 +33,15 @@ public class GroupsDAO {
grp.setDn(result.getNameInNamespace());
final List<String> listOfMembers = session.getListOfValues(attribs, "uniqueMember");
final String dn = grp.getDn();
listOfMembers.stream().map((userDN) -> users.get(userDN)).map((user) -> user.getGroups()).forEachOrdered((groups) -> {
for (final String userDN : listOfMembers) {
final User user = users.get(userDN);
if (user != null) {
final List<String> groups = user.getGroups();
groups.add(dn);
});
} else {
System.out.println("Error: " + userDN + " in group " + dn);
}
}
grp.setMembers(listOfMembers);
list.put(dn, grp);
}

View File

@ -23,6 +23,8 @@ public class LDAPConfig {
private String smtpHost;
private String smtpPort;
private String smtpInternalDomains;
private String pacAdmin;
private String pacPassword;
private String tempDir;
private LDAPConfig() {
@ -49,6 +51,8 @@ public class LDAPConfig {
smtpPort = props.getProperty("smtp.port", smtpPort);
smtpFromAddress = props.getProperty("smtp.from", smtpFromAddress);
smtpInternalDomains = props.getProperty("smtp.internal", smtpInternalDomains);
pacAdmin = props.getProperty("pac.user", "xyz00");
pacPassword = props.getProperty("pac.password", "secret");
tempDir = props.getProperty("temp.dir", tempDir);
final LDAPUriParser uriParser = new LDAPUriParser(ldapProviderUrl);
ldapDistinguishedName = uriParser.getDn();
@ -119,6 +123,13 @@ public class LDAPConfig {
return tempDir;
}
public String getPacAdmin() {
return pacAdmin;
}
public String getPacPassword() {
return pacPassword;
}
private Properties loadConfig() throws IOException {
final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("config.properties");

View File

@ -71,11 +71,11 @@ public class UsersDAO {
if (hasValue(emailInternal)) {
mail.add(emailInternal);
}
attributes.put(mail);
final String emailExternal = usr.getEmailExternal();
if (hasValue(emailExternal)) {
mail.add(emailExternal);
attributes.put("description", emailExternal);
}
attributes.put(mail);
attributes.put("uid", uid);
attributes.put("cn", uid);
final String telephone = usr.getPhone();

View File

@ -10,6 +10,7 @@ import javax.servlet.http.HttpSession;
import de.jalin.ldapadmin.beans.Group;
import de.jalin.ldapadmin.beans.User;
import de.jalin.ldapadmin.hsadmin.TicketProvider;
import de.jalin.ldapadmin.ldap.LDAPConfig;
import de.jalin.ldapadmin.ldap.LDAPSession;
import de.jalin.ldapadmin.ldap.LDAPSessionException;
@ -27,6 +28,7 @@ public class AbstractLDAPServlet extends HttpServlet {
protected LDAPSession ldapSession;
protected LDAPConfig config;
protected TicketProvider ticketProvider = null;
protected void loadData() {
users = new TreeMap<>();
@ -74,4 +76,13 @@ public class AbstractLDAPServlet extends HttpServlet {
httpSession.removeAttribute("servletexception");
}
protected TicketProvider getTicketProvider() {
if (ticketProvider == null) {
final String pacAdmin = config.getPacAdmin();
final String pacPassword = config.getPacPassword();
ticketProvider = new TicketProvider(pacAdmin, pacPassword);
}
return ticketProvider;
}
}

View File

@ -3,4 +3,5 @@ security.principal=uid=admin,ou=system
security.password=streng-geheim
smtp.host=localhost
smtp.from=nobody@example.com
smtp.internal=example.com,example.org
pac.user=xyz00
pac.password=secret