Verwaltung von LDAP Accounts und Gruppen
Peter Hormanns
2021-12-07 694d20e4b72fbb2283a8f4230ee781e2839d9273
remove unused external email and jsps
18 files modified
4 files deleted
144 ■■■■ changed files
pom.xml 2 ●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/beans/User.java 21 ●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/ldap/LDAPConfig.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/ldap/UsersDAO.java 26 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/web/ProfileServlet.java 2 ●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/web/ResetPasswordServlet.java 12 ●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/web/UserServlet.java 4 ●●● patch | view | raw | blame | history
src/main/resources/de/jalin/ldapadmin/contact.properties 2 ●●●●● patch | view | raw | blame | history
src/main/resources/de/jalin/ldapadmin/contact_de.properties 2 ●●●●● patch | view | raw | blame | history
src/main/resources/de/jalin/ldapadmin/contact_en.properties 2 ●●●●● patch | view | raw | blame | history
src/main/webapp/WEB-INF/web.xml 6 ●●●●● patch | view | raw | blame | history
src/main/webapp/index.jsp 19 ●●●●● patch | view | raw | blame | history
src/main/webapp/template/empty-navbar.jsp 5 ●●●● patch | view | raw | blame | history
src/main/webapp/template/navbar.jsp 2 ●●● patch | view | raw | blame | history
src/main/webapp/user.jsp 10 ●●●● patch | view | raw | blame | history
src/test/java/de/jalin/ldapadmin/ldap/TestCreateGroup.java 2 ●●● patch | view | raw | blame | history
src/test/java/de/jalin/ldapadmin/ldap/TestCreateUser.java 6 ●●●●● patch | view | raw | blame | history
src/test/java/de/jalin/ldapadmin/ldap/TestDeleteUser.java 2 ●●● patch | view | raw | blame | history
src/test/java/de/jalin/ldapadmin/ldap/TestReadUser.java 4 ●●●● patch | view | raw | blame | history
src/test/java/de/jalin/ldapadmin/ldap/TestUpdateAsBindUser.java 2 ●●● patch | view | raw | blame | history
src/test/java/de/jalin/ldapadmin/ldap/TestUpdateAsSimpleUser.java 4 ●●●● patch | view | raw | blame | history
src/test/java/de/jalin/ldapadmin/ldap/TestUpdateUser.java 2 ●●● patch | view | raw | blame | history
pom.xml
@@ -5,7 +5,7 @@
    <groupId>de.jalin.ldapadmin</groupId>
    <artifactId>ldapadmin</artifactId>
    <packaging>war</packaging>
    <version>1.0.1</version>
    <version>1.0.2</version>
    <name>LDAP Admin Webapp</name>
    
    <properties>
src/main/java/de/jalin/ldapadmin/beans/User.java
@@ -18,8 +18,7 @@
    private String firstname;
    private String lastname;
    private String displayname;
    private String emailInternal;
    private String emailExternal;
    private String email;
    private String phone;
    private String mobile;
    private List<String> groups;
@@ -79,20 +78,12 @@
        this.displayname = displayname;
    }
    public String getEmailInternal() {
        return emailInternal;
    public String getEmail() {
        return email;
    }
    public void setEmailInternal(String email) {
        this.emailInternal = email;
    }
    public String getEmailExternal() {
        return emailExternal;
    }
    public void setEmailExternal(String email) {
        this.emailExternal = email;
    public void setEmail(String email) {
        this.email = email;
    }
    public String getPhone() {
@@ -121,7 +112,7 @@
    @Override
    public String toString() {
        return getFirstname() + " " + getLastname() + " (" + getLogin() + ", " + getEmailExternal() + ")";
        return getFirstname() + " " + getLastname() + " (" + getLogin() + ", " + getEmail() + ")";
    }
    @Override
src/main/java/de/jalin/ldapadmin/ldap/LDAPConfig.java
@@ -16,7 +16,6 @@
    private String smtpFromAddress;
    private String smtpHost;
    private String smtpPort;
    private String smtpInternalDomains;
    private String pacAdmin;
    private String pacPassword;
    private String tempDir;
@@ -28,7 +27,6 @@
        smtpHost = "localhost";
        smtpPort = "25";
        smtpFromAddress = "nobody@example.com";
        smtpInternalDomains = "example.com,example.org";
        tempDir = System.getProperty("java.io.tmpdir");
        try {
            final Properties props = loadConfig();
@@ -38,7 +36,6 @@
            smtpHost = props.getProperty("smtp.host", smtpHost);
            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);
@@ -76,10 +73,6 @@
    public String getSmtpFromAddress() {
        return smtpFromAddress;
    }
    public String getSmtpInternalDomains() {
        return smtpInternalDomains;
    }
    public String getTempDir() {
src/main/java/de/jalin/ldapadmin/ldap/UsersDAO.java
@@ -30,8 +30,7 @@
            final User usr = new User();
            usr.setFirstname(session.getStringValue(attribs, "givenName"));
            usr.setLastname(session.getStringValue(attribs, "sn"));
            usr.setEmailInternal(session.getStringValue(attribs, "mail"));
            usr.setEmailExternal(session.getStringValue(attribs, "description"));
            usr.setEmail(session.getStringValue(attribs, "mail"));
            usr.setLogin(session.getStringValue(attribs, "uid"));
            usr.setPhone(session.getStringValue(attribs, "telephoneNumber"));
            usr.setMobile(session.getStringValue(attribs, "mobile"));
@@ -68,15 +67,11 @@
        }
        attributes.put("sn", lastname);
        final BasicAttribute mail = new BasicAttribute("mail");
        final String emailInternal = usr.getEmailInternal();
        if (hasValue(emailInternal)) {
            mail.add(emailInternal);
        final String email = usr.getEmail();
        if (hasValue(email)) {
            mail.add(email);
        }
        attributes.put(mail);
        final String emailExternal = usr.getEmailExternal();
        if (hasValue(emailExternal)) {
            attributes.put("description", emailExternal);
        }
        attributes.put("uid", uid);
        attributes.put("cn", uid);
        final String telephone = usr.getPhone();
@@ -107,8 +102,7 @@
        final User usr = new User();
        usr.setFirstname(session.getStringValue(attribs, "givenName"));
        usr.setLastname(session.getStringValue(attribs, "sn"));
        usr.setEmailExternal(session.getStringValue(attribs, "description"));
        usr.setEmailInternal(session.getStringValue(attribs, "mail"));
        usr.setEmail(session.getStringValue(attribs, "mail"));
        usr.setLogin(session.getStringValue(attribs, "uid"));
        usr.setPhone(session.getStringValue(attribs, "telephoneNumber"));
        usr.setMobile(session.getStringValue(attribs, "mobile"));
@@ -127,13 +121,9 @@
        final List<ModificationItem> updates = new ArrayList<ModificationItem>();
        addStringAttrUpdate(updates, attribs, "displayName", usr.getDisplayname());
        final ArrayList<String> emailAdressList = new ArrayList<String>();
        final String emailInternal = usr.getEmailInternal();
        if (hasValue(emailInternal)) {
            emailAdressList.add(emailInternal);
        }
        final String emailExternal = usr.getEmailExternal();
        if (hasValue(emailExternal)) {
            addStringAttrUpdate(updates, attribs, "description", emailExternal);
        final String email = usr.getEmail();
        if (hasValue(email)) {
            emailAdressList.add(email);
        }
        addMultiValueAttrUpdate(updates, attribs, "mail", emailAdressList);
        addStringAttrUpdate(updates, attribs, "givenName", usr.getFirstname());
src/main/java/de/jalin/ldapadmin/web/ProfileServlet.java
@@ -19,7 +19,7 @@
import de.jalin.ldapadmin.ldap.SimplePasswordException;
import de.jalin.ldapadmin.ldap.UsersDAO;
@WebServlet(name = "LdapProfile", urlPatterns = {"/profile", "/profile/*"}, loadOnStartup = 1)
@WebServlet(name = "LdapProfile", urlPatterns = {"/", "/profile", "/profile/*"}, loadOnStartup = 1)
public class ProfileServlet extends AbstractLDAPServlet {
    private static final long serialVersionUID = 1L;
src/main/java/de/jalin/ldapadmin/web/ResetPasswordServlet.java
@@ -142,12 +142,9 @@
                    final SortedMap<String, User> usersMap = usrDAO.loadUsers();
                    final Collection<User> allUsers = usersMap.values();
                    for (User usr : allUsers) {
                        if (usr.getEmailInternal() != null && usr.getEmailInternal().equalsIgnoreCase(loginOrEMail)) {
                        if (usr.getEmail() != null && usr.getEmail().equalsIgnoreCase(loginOrEMail)) {
                            login = usr.getLogin();
                            email = usr.getEmailExternal();
                            if (email == null || email.isEmpty()) {
                                email = usr.getEmailInternal();
                            }
                            email = usr.getEmail();
                            salutation = usr.getFirstname() + " " + usr.getLastname();
                        }
                    }
@@ -155,10 +152,7 @@
                    final User usr = usrDAO.read("uid=" + loginOrEMail + ",ou=users,");
                    if (usr != null) {
                        login = usr.getLogin();
                        email = usr.getEmailExternal();
                        if (email == null || email.isEmpty()) {
                            email = usr.getEmailInternal();
                        }
                        email = usr.getEmail();
                        salutation = usr.getFirstname() + " " + usr.getLastname();
                    }
                }
src/main/java/de/jalin/ldapadmin/web/UserServlet.java
@@ -85,7 +85,6 @@
        final String firstname = req.getParameter("firstname");
        final String lastname = req.getParameter("lastname");
        final String email = req.getParameter("email");
        final String emailExt = req.getParameter("extemail");
        final String phone = req.getParameter("phone");
        final String mobile = req.getParameter("mobile");
        final String password = req.getParameter("password");
@@ -98,8 +97,7 @@
        usr.setFirstname(firstname);
        usr.setLastname(lastname);
        usr.setDisplayname(firstname + " " + lastname);
        usr.setEmailInternal(email);
        usr.setEmailExternal(emailExt);
        usr.setEmail(email);
        usr.setPhone(phone);
        usr.setMobile(mobile);
        final List<String> memberships = new ArrayList<>();
src/main/resources/de/jalin/ldapadmin/contact.properties
File was deleted
src/main/resources/de/jalin/ldapadmin/contact_de.properties
File was deleted
src/main/resources/de/jalin/ldapadmin/contact_en.properties
File was deleted
src/main/webapp/WEB-INF/web.xml
@@ -11,7 +11,7 @@
        <url-pattern>*.js</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
        <welcome-file>/profile</welcome-file>
    </welcome-file-list>
    <error-page>
        <error-code>403</error-code>
@@ -28,8 +28,6 @@
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Public access</web-resource-name>
            <url-pattern>/</url-pattern>
            <url-pattern>/index.jsp</url-pattern>
            <url-pattern>*.css</url-pattern>
            <url-pattern>*.js</url-pattern>
            <url-pattern>/css/*</url-pattern>
@@ -43,9 +41,9 @@
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Profile Area</web-resource-name>
            <url-pattern>/</url-pattern>
            <url-pattern>/profile</url-pattern>
            <url-pattern>/profile/*</url-pattern>
            <url-pattern>/</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>ldapadmin</role-name>
src/main/webapp/index.jsp
File was deleted
src/main/webapp/template/empty-navbar.jsp
@@ -11,15 +11,12 @@
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="<c:url value="/index.jsp"/>"><fmt:message key="navbar.title"/></a>
            <a class="navbar-brand"><fmt:message key="navbar.title"/></a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li>
                    <a href="<c:url value="/profile"/>"><fmt:message key="navbar.item.profile"/></a>
                </li>
                <li>
                    <a href="<c:url value="/contact.jsp"/>"><fmt:message key="navbar.item.contact"/></a>
                </li>
            </ul>
        </div>
src/main/webapp/template/navbar.jsp
@@ -11,7 +11,7 @@
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="<c:url value="/index.jsp"/>"><fmt:message key="navbar.title"/></a>
            <a class="navbar-brand"><fmt:message key="navbar.title"/></a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
src/main/webapp/user.jsp
@@ -84,15 +84,7 @@
                            <div class="col-sm-9">
                                <input
                                    type="email" class="form-control" id="email" name="email"
                                    value="${user.emailInternal}" placeholder="Enter email">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="extemail" class="col-sm-3 control-label"><fmt:message key="users.label.extemail"/></label>
                            <div class="col-sm-9">
                                <input
                                    type="email" class="form-control" id="extemail" name="extemail"
                                    value="${user.emailExternal}" placeholder="Enter email">
                                    value="${user.email}" placeholder="Enter email">
                            </div>
                        </div>
                        <div class="form-group">
src/test/java/de/jalin/ldapadmin/ldap/TestCreateGroup.java
@@ -61,7 +61,7 @@
        final User newUser = new User();
        newUser.setDn(USERS_DN.replace("${uid}", uid));
        newUser.setDisplayname(fn + " " + ln);
        newUser.setEmailInternal(fn.toLowerCase() + "." + ln.toLowerCase() + "@example.com");
        newUser.setEmail(fn.toLowerCase() + "." + ln.toLowerCase() + "@example.com");
        newUser.setFirstname(fn);
        newUser.setLastname(ln);
        newUser.setLogin(uid);
src/test/java/de/jalin/ldapadmin/ldap/TestCreateUser.java
@@ -40,8 +40,7 @@
            final User newUser = new User();
            newUser.setDn(USERS_DN);
            newUser.setDisplayname("Peter Petersen");
            newUser.setEmailInternal("peter.petersen@example.com");
            newUser.setEmailExternal("peter.petersen@external.com");
            newUser.setEmail("peter.petersen@example.com");
            newUser.setFirstname("Peter");
            newUser.setLastname("Petersen");
            newUser.setLogin("pet");
@@ -51,8 +50,7 @@
            dao.create(newUser);
            final User createdUser = dao.loadUsers().get(USERS_DN);
            assertNotNull("should exist", createdUser);
            assertTrue("peter.petersen@example.com".equals(createdUser.getEmailInternal()));
            assertTrue("peter.petersen@external.com".equals(createdUser.getEmailExternal()));
            assertTrue("peter.petersen@example.com".equals(createdUser.getEmail()));
        } catch (LDAPSessionException | RequiredAttributeException | AlreadyBoundException e) {
            fail(e.getMessage());
        }
src/test/java/de/jalin/ldapadmin/ldap/TestDeleteUser.java
@@ -40,7 +40,7 @@
            final User newUser = new User();
            newUser.setDn(USERS_DN);
            newUser.setDisplayname("Hein Hanssen");
            newUser.setEmailInternal("hein.hanssen@example.com");
            newUser.setEmail("hein.hanssen@example.com");
            newUser.setFirstname("Hein");
            newUser.setLastname("Hanssen");
            newUser.setLogin("hei");
src/test/java/de/jalin/ldapadmin/ldap/TestReadUser.java
@@ -40,7 +40,7 @@
            final User newUser = new User();
            newUser.setDn(USERS_DN);
            newUser.setDisplayname("Chris Christansen");
            newUser.setEmailInternal("chris.christansen@example.com");
            newUser.setEmail("chris.christansen@example.com");
            newUser.setFirstname("Chris");
            newUser.setLastname("Christansen");
            newUser.setLogin("chr");
@@ -52,7 +52,7 @@
            assertNotNull("should exist", createdUser);
            final User readUser = dao.read(USERS_DN);
            assertNotNull(readUser);
            assertTrue("chris.christansen@example.com".equals(readUser.getEmailInternal()));
            assertTrue("chris.christansen@example.com".equals(readUser.getEmail()));
        } catch (LDAPSessionException | RequiredAttributeException | AlreadyBoundException e) {
            fail(e.getMessage());
        }
src/test/java/de/jalin/ldapadmin/ldap/TestUpdateAsBindUser.java
@@ -48,7 +48,7 @@
            final User newUser = new User();
            newUser.setDn(USERS_DN);
            newUser.setDisplayname("Paul Paulsen");
            newUser.setEmailInternal("paul.paulsen@example.com");
            newUser.setEmail("paul.paulsen@example.com");
            newUser.setFirstname("Paul");
            newUser.setLastname("Pausen");
            newUser.setLogin("pau");
src/test/java/de/jalin/ldapadmin/ldap/TestUpdateAsSimpleUser.java
@@ -31,7 +31,7 @@
        final User newUser = new User();
        newUser.setDn(USERS_DN);
        newUser.setDisplayname("Paul Petersen");
        newUser.setEmailInternal("paul.petersen@example.com");
        newUser.setEmail("paul.petersen@example.com");
        newUser.setFirstname("Paul");
        newUser.setLastname("Petersen");
        newUser.setLogin("plp");
@@ -61,7 +61,7 @@
            final User newUser = new User();
            newUser.setDn(USERS_DN);
            newUser.setDisplayname("Micha Michaelsen");
            newUser.setEmailInternal("micha.michaelsen@example.com");
            newUser.setEmail("micha.michaelsen@example.com");
            newUser.setFirstname("Michael");
            newUser.setLastname("Michaelsen");
            newUser.setLogin("mic");
src/test/java/de/jalin/ldapadmin/ldap/TestUpdateUser.java
@@ -43,7 +43,7 @@
            final User newUser = new User();
            newUser.setDn(USERS_DN);
            newUser.setDisplayname("Klaas Clahsen");
            newUser.setEmailInternal("klaas.clahsen@example.com");
            newUser.setEmail("klaas.clahsen@example.com");
            newUser.setFirstname("Klaas");
            newUser.setLastname("Klahsen");
            newUser.setLogin("kla");