Verwaltung von LDAP Accounts und Gruppen
Peter Hormanns
2021-12-03 8f09343b2cf5bf4c82b9daf7d2e889e78f26a129
remove hsadmin password reset, dependency updates
6 files modified
5 files deleted
372 ■■■■■ changed files
pom.xml 13 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/hsadmin/EMailAddressDAO.java 98 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/hsadmin/EMailAddressNotFound.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/hsadmin/MailboxDAO.java 107 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/hsadmin/MailboxNotFound.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/hsadmin/TicketProvider.java 83 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/ldap/DirectoryServiceRunner.java 8 ●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/web/AbstractLDAPServlet.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/web/ProfileServlet.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/de/jalin/ldapadmin/web/ResetPasswordServlet.java 15 ●●●● patch | view | raw | blame | history
src/main/webapp/WEB-INF/web.xml 6 ●●●● 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-SNAPSHOT</version>
    <version>1.0.1</version>
    <name>LDAP Admin Webapp</name>
    
    <properties>
@@ -55,13 +55,8 @@
        <dependency>
            <groupId>commons-net</groupId>
            <artifactId>commons-net</artifactId>
            <version>3.6</version>
            <version>3.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlrpc</groupId>
            <artifactId>xmlrpc-client</artifactId>
            <version>3.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
@@ -70,12 +65,12 @@
        <dependency>
            <groupId>org.apache.directory.server</groupId>
            <artifactId>apacheds-service</artifactId>
            <version>2.0.0.AM25</version>
            <version>2.0.0.AM26</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
src/main/java/de/jalin/ldapadmin/hsadmin/EMailAddressDAO.java
File was deleted
src/main/java/de/jalin/ldapadmin/hsadmin/EMailAddressNotFound.java
File was deleted
src/main/java/de/jalin/ldapadmin/hsadmin/MailboxDAO.java
File was deleted
src/main/java/de/jalin/ldapadmin/hsadmin/MailboxNotFound.java
File was deleted
src/main/java/de/jalin/ldapadmin/hsadmin/TicketProvider.java
File was deleted
src/main/java/de/jalin/ldapadmin/ldap/DirectoryServiceRunner.java
@@ -3,12 +3,10 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import net.sf.ehcache.Cache;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.server.core.api.CacheService;
import org.apache.directory.server.core.api.DirectoryService;
import org.apache.directory.server.core.api.partition.Partition;
import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
@@ -66,7 +64,7 @@
        directoryService.setShutdownHookEnabled(true);
        directoryService.getChangeLog().setEnabled(false);
        directoryService.setAllowAnonymousAccess(false);
        directoryService.setAccessControlEnabled(false);
        directoryService.setAccessControlEnabled(true);
        directoryService.setPasswordHidden(false);
        return directoryService;
    }
@@ -74,9 +72,7 @@
    private void addPartition(final String dnString, final String partitionId, final String partitionPath) throws LdapInvalidDnException, Exception {
        final JdbmPartitionFactory partitionFactory = new JdbmPartitionFactory();
        final SchemaManager schemaManager = service.getSchemaManager();
        final CacheService cacheService = service.getCacheService();
        final Cache cache = cacheService.getCache("dnCache");
        final DefaultDnFactory defaultDnFactory = new DefaultDnFactory(schemaManager, cache);
        final DefaultDnFactory defaultDnFactory = new DefaultDnFactory(schemaManager, 4096);
        final String parPath = partitionPath != null ? partitionPath : "ldap-data." + Double.valueOf(Math.random()).hashCode();
        final Partition partition = 
            partitionFactory.createPartition(schemaManager, defaultDnFactory, partitionId, dnString, 400, new File(parPath));
src/main/java/de/jalin/ldapadmin/web/AbstractLDAPServlet.java
@@ -10,7 +10,6 @@
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;
@@ -28,7 +27,6 @@
    protected LDAPSession ldapSession;
    protected LDAPConfig config;
    protected TicketProvider ticketProvider = null;
    protected void loadData() {
        users = new TreeMap<>();
@@ -76,13 +74,4 @@
        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;
    }
}
src/main/java/de/jalin/ldapadmin/web/ProfileServlet.java
@@ -12,12 +12,8 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.xmlrpc.XmlRpcException;
import de.jalin.ldapadmin.beans.User;
import de.jalin.ldapadmin.beans.ValidationException;
import de.jalin.ldapadmin.hsadmin.MailboxDAO;
import de.jalin.ldapadmin.hsadmin.MailboxNotFound;
import de.jalin.ldapadmin.ldap.GroupsDAO;
import de.jalin.ldapadmin.ldap.LDAPSessionException;
import de.jalin.ldapadmin.ldap.SimplePasswordException;
@@ -28,12 +24,9 @@
    private static final long serialVersionUID = 1L;
    
    private String pacAdmin;
    @Override
    public void init() throws ServletException {
        super.init();
        pacAdmin = config.getPacAdmin();
    }
    
    @Override
@@ -93,12 +86,6 @@
                    throw new ValidationException("password2", messages.getString("ProfileServlet.passwords_donot_match"));
                } else {
                    usr.setAndValidatePassword(password);
                    final MailboxDAO hsadminMailboxDAO = new MailboxDAO(getTicketProvider());
                    try {
                        hsadminMailboxDAO.changePassword(pacAdmin, usr.getLogin(), password);
                    } catch (XmlRpcException | MailboxNotFound e) {
                        System.out.println(e.getLocalizedMessage());
                    }
                }
            }
        } catch (SimplePasswordException e) {
src/main/java/de/jalin/ldapadmin/web/ResetPasswordServlet.java
@@ -18,15 +18,11 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.CharEncoding;
import org.apache.commons.net.smtp.SMTPClient;
import org.apache.commons.net.smtp.SMTPReply;
import org.apache.commons.net.smtp.SimpleSMTPHeader;
import org.apache.xmlrpc.XmlRpcException;
import de.jalin.ldapadmin.beans.User;
import de.jalin.ldapadmin.hsadmin.MailboxDAO;
import de.jalin.ldapadmin.hsadmin.MailboxNotFound;
import de.jalin.ldapadmin.ldap.LDAPSessionException;
import de.jalin.ldapadmin.ldap.SimplePasswordException;
import de.jalin.ldapadmin.ldap.UsersDAO;
@@ -39,7 +35,6 @@
    private String smtpHost;
    private String smtpPort;
    private String smtpFrom;
    private String hsadminPacAdmin;
    private String tempDir;
    @Override
@@ -48,7 +43,6 @@
        smtpHost = config.getSmtpHost();
        smtpPort = config.getSmtpPort();
        smtpFrom = config.getSmtpFromAddress();
        hsadminPacAdmin = config.getPacAdmin();
        tempDir = config.getTempDir();
    }
@@ -88,7 +82,7 @@
        final UsersDAO usrDAO = new UsersDAO(ldapSession);
        final String loginParam = req.getParameter("login");
        final User sessUsr = (User) httpSession.getAttribute("user");
        final MailboxDAO hsMailboxDAO = new MailboxDAO(getTicketProvider());
//        final MailboxDAO hsMailboxDAO = new MailboxDAO(getTicketProvider());
        if (loginParam != null && sessUsr != null && loginParam.equals(sessUsr.getLogin())) {
            final String password1 = req.getParameter("password");
            final String password2 = req.getParameter("password2");
@@ -101,11 +95,6 @@
                    try {
                        sessUsr.setAndValidatePassword(password1);
                        usrDAO.update(sessUsr);
                        try {
                            hsMailboxDAO.changePassword(hsadminPacAdmin, sessUsr.getLogin(), password1);
                        } catch (XmlRpcException | MailboxNotFound e) {
                            System.out.println(e.getLocalizedMessage());
                        }
                        httpSession.setAttribute("successmessage", messages.getString("ResetPasswordServlet.password_changed"));
                        req.getRequestDispatcher("/new-password.jsp").forward(req, resp);
                        return;
@@ -187,7 +176,7 @@
    }
    private static void smtpSend(final String smtpHost, final String smtpPort, final Messages messages, final String fromAddress, final String toAddress, final String subject, final String text) throws IOException {
        final SMTPClient client = new SMTPClient(CharEncoding.ISO_8859_1);
        final SMTPClient client = new SMTPClient();
        final String canonicalHostName = InetAddress.getLocalHost().getHostName();
        client.connect(smtpHost, Integer.parseInt(smtpPort));
        int reply = client.getReplyCode();
src/main/webapp/WEB-INF/web.xml
@@ -48,7 +48,7 @@
            <url-pattern>/</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admins</role-name>
            <role-name>ldapadmin</role-name>
            <role-name>login</role-name>
        </auth-constraint>
    </security-constraint>
@@ -65,7 +65,7 @@
            <url-pattern>/groups/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admins</role-name>
            <role-name>ldapadmin</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
@@ -77,7 +77,7 @@
        </form-login-config>
    </login-config>
    <security-role>
        <role-name>admins</role-name>
        <role-name>ldapadmin</role-name>
    </security-role>
    <security-role>
        <role-name>login</role-name>