diff --git a/.gitignore b/.gitignore index eed9b95..5d78464 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ target/ +nb-configuration.xml pom.xml.tag pom.xml.releaseBackup pom.xml.versionsBackup diff --git a/etc/jetty.xml b/etc/jetty.xml index 7abdbc4..ea8721a 100644 --- a/etc/jetty.xml +++ b/etc/jetty.xml @@ -3,7 +3,7 @@ - Administration Area + LDAP /etc/realm.properties diff --git a/etc/realm.properties b/etc/realm.properties index 10f1a85..59f7fab 100644 --- a/etc/realm.properties +++ b/etc/realm.properties @@ -1 +1 @@ -peter: Test123,login,admins +admin: Test123,login,admins diff --git a/pom.xml b/pom.xml index 8a68322..f02fa1d 100644 --- a/pom.xml +++ b/pom.xml @@ -52,11 +52,6 @@ commons-net 3.6 - - org.webjars - jquery - 3.4.1 - org.webjars bootstrap diff --git a/src/main/java/de/jalin/ldapadmin/ldap/DirectoryServiceRunner.java b/src/main/java/de/jalin/ldapadmin/ldap/DirectoryServiceRunner.java index 7924dea..78d27e4 100644 --- a/src/main/java/de/jalin/ldapadmin/ldap/DirectoryServiceRunner.java +++ b/src/main/java/de/jalin/ldapadmin/ldap/DirectoryServiceRunner.java @@ -3,9 +3,7 @@ package de.jalin.ldapadmin.ldap; 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; @@ -24,16 +22,40 @@ import org.apache.directory.server.protocol.shared.transport.TcpTransport; public class DirectoryServiceRunner { private static DirectoryServiceRunner serviceRunner = null; + + public static void assureServiceRunning(final String name) throws DirectoryServiceException { + if (serviceRunner == null) { + final String dnName = "dc=" + name + ",dc=example,dc=com"; + try { + serviceRunner = new DirectoryServiceRunner("example", dnName, "127.0.0.1", "10389", false); + } catch (Exception e) { + throw new DirectoryServiceException(e); + } + } + } + + public static void main(final String[] args) { + final String dnString = "dc=" + args[0] + ",dc=example,dc=com"; + final String ip = args[1]; + final String port = args[2]; + try { + final DirectoryServiceRunner ads = new DirectoryServiceRunner("example", dnString, ip, port, false); + final Entry result = ads.service.getAdminSession().lookup(new Dn(dnString)); + System.out.println("Found entry : " + result); + } catch (Exception e) { + System.err.println(e.getMessage()); + } + } private final DirectoryService service; - public DirectoryServiceRunner(final String partition, final String dnString, final String ip, final String port) throws Exception { + public DirectoryServiceRunner(final String partition, final String dnString, final String ip, final String port, final boolean useTLS) throws Exception { this.service = initService(partition); addPartition("ou=config", "config"); addPartition(dnString, partition); this.service.startup(); loadData(); - startServer(ip, port); + startServer(ip, port, useTLS); } private DirectoryService initService(final String partition) throws Exception { @@ -58,13 +80,19 @@ public class DirectoryServiceRunner { service.addPartition(partition); } - private void startServer(final String ip, final String port) throws Exception { + private void startServer(final String ip, final String port, final boolean useTLS) throws Exception { final LdapServer ldapServer = new LdapServer(); - ldapServer.setTransports(new TcpTransport(ip, Integer.parseInt(port))); + final TcpTransport tcpTransport = new TcpTransport(ip, Integer.parseInt(port)); + tcpTransport.enableSSL(useTLS); + ldapServer.setTransports(tcpTransport); ldapServer.setDirectoryService(service); ldapServer.start(); } + public void shutdown() throws Exception { + service.shutdown(); + } + private void loadData() { final File ldifDirectory = new File("ldif"); if (ldifDirectory.exists() && ldifDirectory.isDirectory()) { @@ -80,29 +108,6 @@ public class DirectoryServiceRunner { } } - public static void assureServiceRunning(final String name) throws DirectoryServiceException { - if (serviceRunner == null) { - final String dnName = "dc=" + name + ",dc=example,dc=com"; - try { - serviceRunner = new DirectoryServiceRunner("example", dnName, "127.0.0.1", "10389"); - } catch (Exception e) { - throw new DirectoryServiceException(e); - } - } - } - - public static void main(final String[] args) { - final String dnString = "dc=" + args[0] + ",dc=example,dc=com"; - final String ip = args[1]; - final String port = args[2]; - try { - final DirectoryServiceRunner ads = new DirectoryServiceRunner("example", dnString, ip, port); - final Entry result = ads.service.getAdminSession().lookup(new Dn(dnString)); - System.out.println("Found entry : " + result); - } catch (Exception e) { - System.err.println(e.getMessage()); - } - } static class DirectoryServiceException extends Exception { diff --git a/src/main/java/de/jalin/ldapadmin/server/LDAPUriParser.java b/src/main/java/de/jalin/ldapadmin/server/LDAPUriParser.java new file mode 100644 index 0000000..361462f --- /dev/null +++ b/src/main/java/de/jalin/ldapadmin/server/LDAPUriParser.java @@ -0,0 +1,37 @@ +package de.jalin.ldapadmin.server; + +public class LDAPUriParser { + + private final boolean useTLS; + private final String dn; + private final String port; + private final String host; + + public LDAPUriParser (final String uri) { + final String[] uriParts = uri.split("\\/"); + final String protocol = uriParts[0]; + final String hostAndPort = uriParts[2]; + final String[] hostAndPortParts = hostAndPort.split(":"); + host = hostAndPortParts[0]; + port = hostAndPortParts[1]; + dn = uriParts[3]; + useTLS = protocol.toLowerCase().startsWith("ldaps"); + } + + public String getDn() { + return dn; + } + + public String getHost() { + return host; + } + + public String getPort() { + return port; + } + + public boolean isUseTLS() { + return useTLS; + } + +} diff --git a/src/main/java/de/jalin/ldapadmin/server/WebappDirectoryServer.java b/src/main/java/de/jalin/ldapadmin/server/WebappDirectoryServer.java index 10d5c3a..15e5755 100644 --- a/src/main/java/de/jalin/ldapadmin/server/WebappDirectoryServer.java +++ b/src/main/java/de/jalin/ldapadmin/server/WebappDirectoryServer.java @@ -1,20 +1,37 @@ package de.jalin.ldapadmin.server; +import de.jalin.ldapadmin.ldap.DirectoryServiceRunner; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; +@WebListener public class WebappDirectoryServer implements ServletContextListener { + private DirectoryServiceRunner directoryServer; + @Override public void contextInitialized(final ServletContextEvent evt) { - final ServletContext ctx = evt.getServletContext(); - final String uri = ctx.getInitParameter("uri"); + try { + final ServletContext ctx = evt.getServletContext(); + final String uri = ctx.getInitParameter("uri"); + final LDAPUriParser uriParser = new LDAPUriParser(uri); + directoryServer = new DirectoryServiceRunner("main", uriParser.getDn(), uriParser.getHost(), uriParser.getPort(), uriParser.isUseTLS()); + } catch (Exception ex) { + Logger.getLogger(WebappDirectoryServer.class.getName()).log(Level.SEVERE, null, ex); + } } @Override public void contextDestroyed(final ServletContextEvent evt) { + try { + directoryServer.shutdown(); + } catch (Exception ex) { + Logger.getLogger(WebappDirectoryServer.class.getName()).log(Level.SEVERE, null, ex); + } } - } diff --git a/src/main/java/de/jalin/ldapadmin/web/GroupServlet.java b/src/main/java/de/jalin/ldapadmin/web/GroupServlet.java index c97e091..7170982 100644 --- a/src/main/java/de/jalin/ldapadmin/web/GroupServlet.java +++ b/src/main/java/de/jalin/ldapadmin/web/GroupServlet.java @@ -20,7 +20,7 @@ import de.jalin.ldapadmin.ldap.LDAPSessionException; import de.jalin.ldapadmin.ldap.NoGroupMembersException; import de.jalin.ldapadmin.ldap.UsersDAO; -@WebServlet(name = "LdapGroup", urlPatterns = {"/group/*"}) +@WebServlet(name = "LdapGroup", urlPatterns = {"/group/*"}, loadOnStartup = 1) public class GroupServlet extends AbstractLDAPServlet { private static final long serialVersionUID = 1L; @@ -56,7 +56,7 @@ public class GroupServlet extends AbstractLDAPServlet { } catch (LDAPSessionException e) { throwServletException(httpSession, e); } - req.getRequestDispatcher("/WEB-INF/group.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/group.jsp").forward(req, resp); //$NON-NLS-1$ } @Override @@ -98,7 +98,7 @@ public class GroupServlet extends AbstractLDAPServlet { if (grp.getMembers().isEmpty()) { httpSession.setAttribute("group", grp); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("GroupServlet.no_empty_group")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/group.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/group.jsp").forward(req, resp); //$NON-NLS-1$ return; } try { @@ -106,7 +106,7 @@ public class GroupServlet extends AbstractLDAPServlet { } catch (NoGroupMembersException e) { httpSession.setAttribute("group", grp); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("GroupServlet.no_empty_group")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/group.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/group.jsp").forward(req, resp); //$NON-NLS-1$ return; } } @@ -122,7 +122,7 @@ public class GroupServlet extends AbstractLDAPServlet { if (grp.getMembers().isEmpty()) { httpSession.setAttribute("group", grp); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("GroupServlet.no_empty_group")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/group.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/group.jsp").forward(req, resp); //$NON-NLS-1$ return; } try { @@ -130,7 +130,7 @@ public class GroupServlet extends AbstractLDAPServlet { } catch (AlreadyBoundException e) { httpSession.setAttribute("group", grp); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("GroupServlet.group_exists")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/group.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/group.jsp").forward(req, resp); //$NON-NLS-1$ return; } resp.sendRedirect(req.getContextPath() + req.getServletPath() + "/" + grp.getDn()); //$NON-NLS-1$ diff --git a/src/main/java/de/jalin/ldapadmin/web/GroupsServlet.java b/src/main/java/de/jalin/ldapadmin/web/GroupsServlet.java index 8262c76..e1f2f25 100644 --- a/src/main/java/de/jalin/ldapadmin/web/GroupsServlet.java +++ b/src/main/java/de/jalin/ldapadmin/web/GroupsServlet.java @@ -14,7 +14,7 @@ import de.jalin.ldapadmin.ldap.GroupsDAO; import de.jalin.ldapadmin.ldap.LDAPSessionException; import de.jalin.ldapadmin.ldap.UsersDAO; -@WebServlet(name = "LdapGroups", urlPatterns = {"/groups"}) +@WebServlet(name = "LdapGroups", urlPatterns = {"/groups"}, loadOnStartup = 1) public class GroupsServlet extends AbstractLDAPServlet { private static final long serialVersionUID = 1L; @@ -33,7 +33,7 @@ public class GroupsServlet extends AbstractLDAPServlet { } catch (LDAPSessionException e) { throwServletException(httpSession, e); } - req.getRequestDispatcher("/WEB-INF/groups.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/groups.jsp").forward(req, resp); //$NON-NLS-1$ } } diff --git a/src/main/java/de/jalin/ldapadmin/web/LogoutServlet.java b/src/main/java/de/jalin/ldapadmin/web/LogoutServlet.java index bc08099..516ed71 100644 --- a/src/main/java/de/jalin/ldapadmin/web/LogoutServlet.java +++ b/src/main/java/de/jalin/ldapadmin/web/LogoutServlet.java @@ -8,7 +8,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -@WebServlet(name = "Logout", urlPatterns = {"/logout"}) +@WebServlet(name = "Logout", urlPatterns = {"/logout"}, loadOnStartup = 1) public class LogoutServlet extends AbstractLDAPServlet { private static final long serialVersionUID = 1L; diff --git a/src/main/java/de/jalin/ldapadmin/web/Messages.java b/src/main/java/de/jalin/ldapadmin/web/Messages.java index 1dc736f..6016d5a 100644 --- a/src/main/java/de/jalin/ldapadmin/web/Messages.java +++ b/src/main/java/de/jalin/ldapadmin/web/Messages.java @@ -6,7 +6,7 @@ import java.util.ResourceBundle; public class Messages { - private static final String BUNDLE_NAME = "de.jalin.ldapadmin.admin.web.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "de.jalin.ldapadmin.web.messages"; //$NON-NLS-1$ private final ResourceBundle resourceBundle; diff --git a/src/main/java/de/jalin/ldapadmin/web/ProfileServlet.java b/src/main/java/de/jalin/ldapadmin/web/ProfileServlet.java index 24e69cd..9c8c068 100644 --- a/src/main/java/de/jalin/ldapadmin/web/ProfileServlet.java +++ b/src/main/java/de/jalin/ldapadmin/web/ProfileServlet.java @@ -18,7 +18,7 @@ import de.jalin.ldapadmin.ldap.LDAPSessionException; import de.jalin.ldapadmin.ldap.SimplePasswordException; import de.jalin.ldapadmin.ldap.UsersDAO; -@WebServlet(name = "LdapProfile", urlPatterns = {"/profile", "/profile/*"}) +@WebServlet(name = "LdapProfile", urlPatterns = {"/profile", "/profile/*"}, loadOnStartup = 1) public class ProfileServlet extends AbstractLDAPServlet { private static final long serialVersionUID = 1L; @@ -52,7 +52,7 @@ public class ProfileServlet extends AbstractLDAPServlet { } catch (LDAPSessionException e) { throwServletException(httpSession, e); } - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ } @Override @@ -85,12 +85,12 @@ public class ProfileServlet extends AbstractLDAPServlet { } catch (SimplePasswordException e) { httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("ResetPasswordServlet.simple_password")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ return; } catch (ValidationException e) { httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("ProfileServlet.inputfield") + e.getFieldname() + " " + e.getCondition()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ return; } try { @@ -102,14 +102,14 @@ public class ProfileServlet extends AbstractLDAPServlet { httpSession.setAttribute("successmessage", messages.getString("ProfileServlet.password_changed")); //$NON-NLS-1$ //$NON-NLS-2$ httpSession.setAttribute("operation", "profile"); //$NON-NLS-1$ //$NON-NLS-2$ httpSession.setAttribute("user", usr); //$NON-NLS-1$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); + req.getRequestDispatcher("/user.jsp").forward(req, resp); } } catch (LDAPSessionException e) { final String excMessage = e.getMessage(); if (excMessage != null && excMessage.contains("invalid reuse of password")) { //$NON-NLS-1$ httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("ProfileServlet.invalid_reuse")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ return; } throwServletException(httpSession, e); diff --git a/src/main/java/de/jalin/ldapadmin/web/ResetPasswordServlet.java b/src/main/java/de/jalin/ldapadmin/web/ResetPasswordServlet.java index 4bd694a..e17a873 100644 --- a/src/main/java/de/jalin/ldapadmin/web/ResetPasswordServlet.java +++ b/src/main/java/de/jalin/ldapadmin/web/ResetPasswordServlet.java @@ -26,7 +26,7 @@ import de.jalin.ldapadmin.ldap.LDAPSessionException; import de.jalin.ldapadmin.ldap.SimplePasswordException; import de.jalin.ldapadmin.ldap.UsersDAO; -@WebServlet(name = "ResetPassword", urlPatterns = {"/passwordreset"}) +@WebServlet(name = "ResetPassword", urlPatterns = {"/passwordreset"}, loadOnStartup = 1) public class ResetPasswordServlet extends AbstractLDAPServlet { private static final long serialVersionUID = 1L; @@ -57,17 +57,17 @@ public class ResetPasswordServlet extends AbstractLDAPServlet { final UsersDAO usrDAO = new UsersDAO(ldapSession); final User usr = usrDAO.read("uid=" + uidAndEMail[0] + ",ou=users,"); //$NON-NLS-1$ //$NON-NLS-2$ httpSession.setAttribute("user", usr); //$NON-NLS-1$ - req.getRequestDispatcher("/WEB-INF/new-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/new-password.jsp").forward(req, resp); //$NON-NLS-1$ return; } catch (LDAPSessionException e) { LOG.warning("no valid password reset request"); httpSession.setAttribute("errormessage", new Messages(req.getLocale()).getString("ResetPasswordServlet.no_valid_passwordreset_request")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/reset-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/reset-password.jsp").forward(req, resp); //$NON-NLS-1$ return; } } } - req.getRequestDispatcher("/WEB-INF/reset-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/reset-password.jsp").forward(req, resp); //$NON-NLS-1$ } @Override @@ -85,26 +85,26 @@ public class ResetPasswordServlet extends AbstractLDAPServlet { if (password1 != null && !password1.isEmpty()) { if (password2 == null || !password2.equals(password1)) { httpSession.setAttribute("errormessage", messages.getString("ResetPasswordServlet.passwords_donot_match")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/new-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/new-password.jsp").forward(req, resp); //$NON-NLS-1$ return; } else { try { sessUsr.setAndValidatePassword(password1); usrDAO.update(sessUsr); httpSession.setAttribute("successmessage", messages.getString("ResetPasswordServlet.password_changed")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/new-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/new-password.jsp").forward(req, resp); //$NON-NLS-1$ return; } catch (SimplePasswordException e) { httpSession.setAttribute("user", sessUsr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("ResetPasswordServlet.simple_password")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/new-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/new-password.jsp").forward(req, resp); //$NON-NLS-1$ return; } catch (LDAPSessionException e) { final String excMessage = e.getMessage(); if (excMessage != null && excMessage.contains("invalid reuse of password")) { //$NON-NLS-1$ httpSession.setAttribute("user", sessUsr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("ResetPasswordServlet.invalid_password_reuse")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/new-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/new-password.jsp").forward(req, resp); //$NON-NLS-1$ return; } throwServletException(httpSession, e); @@ -139,7 +139,7 @@ public class ResetPasswordServlet extends AbstractLDAPServlet { } if (login.isEmpty() || email.isEmpty()) { httpSession.setAttribute("errormessage", messages.getString("ResetPasswordServlet.error_sending_password_reset")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/reset-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/reset-password.jsp").forward(req, resp); //$NON-NLS-1$ return; } printStream.println(login + ":" + email); //$NON-NLS-1$ @@ -156,7 +156,7 @@ public class ResetPasswordServlet extends AbstractLDAPServlet { } catch (LDAPSessionException | IOException e) { LOG.severe("smtp problem"); httpSession.setAttribute("errormessage", messages.getString("ResetPasswordServlet.error_sending_password_reset")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/reset-password.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/reset-password.jsp").forward(req, resp); //$NON-NLS-1$ return; } httpSession.invalidate(); diff --git a/src/main/java/de/jalin/ldapadmin/web/UserServlet.java b/src/main/java/de/jalin/ldapadmin/web/UserServlet.java index ce9d716..4028b54 100644 --- a/src/main/java/de/jalin/ldapadmin/web/UserServlet.java +++ b/src/main/java/de/jalin/ldapadmin/web/UserServlet.java @@ -23,7 +23,7 @@ import de.jalin.ldapadmin.ldap.RequiredAttributeException; import de.jalin.ldapadmin.ldap.SimplePasswordException; import de.jalin.ldapadmin.ldap.UsersDAO; -@WebServlet(name = "LdapUser", urlPatterns = {"/user/*"}) +@WebServlet(name = "LdapUser", urlPatterns = {"/user/*"}, loadOnStartup = 1) public class UserServlet extends AbstractLDAPServlet { private static final long serialVersionUID = 1L; @@ -59,7 +59,7 @@ public class UserServlet extends AbstractLDAPServlet { } catch (LDAPSessionException e) { throwServletException(httpSession, e); } - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ } @Override @@ -126,12 +126,12 @@ public class UserServlet extends AbstractLDAPServlet { } catch (SimplePasswordException e) { httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("ResetPasswordServlet.simple_password")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ return; } catch (ValidationException e) { httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("UserServlet.input_field") + " \"" + e.getFieldname() + "\" " + e.getCondition()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ return; } final GroupsDAO groupsDAO = new GroupsDAO(ldapSession); @@ -168,22 +168,22 @@ public class UserServlet extends AbstractLDAPServlet { if (excMessage != null && excMessage.contains("invalid reuse of password")) { //$NON-NLS-1$ httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("UserServlet.invalid_password_reuse")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ return; } throwServletException(httpSession, e); } catch (NoGroupMembersException e) { httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("UserServlet.group_last_member")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ } catch (RequiredAttributeException e) { httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("UserServlet.the_input_field") + " " + e.getFieldname() + " " + messages.getString("UserServlet.is_required")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ } catch (AlreadyBoundException e) { httpSession.setAttribute("user", usr); //$NON-NLS-1$ httpSession.setAttribute("errormessage", messages.getString("UserServlet.user_exists")); //$NON-NLS-1$ //$NON-NLS-2$ - req.getRequestDispatcher("/WEB-INF/user.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/user.jsp").forward(req, resp); //$NON-NLS-1$ } } diff --git a/src/main/java/de/jalin/ldapadmin/web/UsersServlet.java b/src/main/java/de/jalin/ldapadmin/web/UsersServlet.java index be5127d..5a90086 100644 --- a/src/main/java/de/jalin/ldapadmin/web/UsersServlet.java +++ b/src/main/java/de/jalin/ldapadmin/web/UsersServlet.java @@ -15,7 +15,7 @@ import de.jalin.ldapadmin.ldap.GroupsDAO; import de.jalin.ldapadmin.ldap.LDAPSessionException; import de.jalin.ldapadmin.ldap.UsersDAO; -@WebServlet(name = "LdapUsers", urlPatterns = {"/users"}) +@WebServlet(name = "LdapUsers", urlPatterns = {"/users"}, loadOnStartup = 1) public class UsersServlet extends AbstractLDAPServlet { private static final long serialVersionUID = 1L; @@ -35,7 +35,7 @@ public class UsersServlet extends AbstractLDAPServlet { } catch (LDAPSessionException e) { throwServletException(httpSession, e); } - req.getRequestDispatcher("/WEB-INF/users.jsp").forward(req, resp); //$NON-NLS-1$ + req.getRequestDispatcher("/users.jsp").forward(req, resp); //$NON-NLS-1$ } } diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties index 0f38366..e6b9dc4 100644 --- a/src/main/resources/config.properties +++ b/src/main/resources/config.properties @@ -1,4 +1,4 @@ -provider.url=ldap://localhost:10389/dc=example,dc=com +provider.url=ldap://localhost:10389/dc=domain,dc=example,dc=com security.principal=uid=admin,ou=system -security.password=secret +security.password=streng-geheim smtp.host=localhost diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 5c5e5cb..6752654 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,13 +1,12 @@ - - + COOKIE - + + uri + ldap://localhost:10389/dc=domain,dc=example,dc=com + default /css/* @@ -15,11 +14,9 @@ *.css *.js - /contact.jsp - 403 /access-denied.jsp @@ -32,7 +29,6 @@ 503 /servlet-exception.jsp - Public access @@ -47,7 +43,6 @@ /servlet-exception.jsp - Profile Area @@ -60,7 +55,6 @@ login - Administrative Area @@ -73,22 +67,18 @@ admins - FORM - Administration Area + LDAP /login.jsp /loginfail.jsp - admins - login - - \ No newline at end of file + diff --git a/src/main/webapp/group.jsp b/src/main/webapp/group.jsp index 215b3b6..6de5118 100644 --- a/src/main/webapp/group.jsp +++ b/src/main/webapp/group.jsp @@ -50,7 +50,7 @@
- + diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp index 2e1ab7e..76c3e99 100644 --- a/src/main/webapp/login.jsp +++ b/src/main/webapp/login.jsp @@ -6,39 +6,39 @@ - + - - + +
-

+

-
-
-
- -
- -
-
-
- -
- -
-
- -
- -
-
-
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+
-
+
diff --git a/src/main/webapp/loginfail.jsp b/src/main/webapp/loginfail.jsp index 43f6182..912f454 100644 --- a/src/main/webapp/loginfail.jsp +++ b/src/main/webapp/loginfail.jsp @@ -6,43 +6,43 @@ - + - - + +
-

-
- × - -
+

+
+ × + +
-
-
-
- -
- -
-
-
- -
- -
-
- -
- -
-
-
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+
-
+
diff --git a/src/main/webapp/user.jsp b/src/main/webapp/user.jsp index 4e51cf8..e66440b 100644 --- a/src/main/webapp/user.jsp +++ b/src/main/webapp/user.jsp @@ -128,7 +128,7 @@
- + diff --git a/src/test/java/de/jalin/ldapadmin/server/TestLDAPUriParser.java b/src/test/java/de/jalin/ldapadmin/server/TestLDAPUriParser.java new file mode 100644 index 0000000..54717b6 --- /dev/null +++ b/src/test/java/de/jalin/ldapadmin/server/TestLDAPUriParser.java @@ -0,0 +1,17 @@ +package de.jalin.ldapadmin.server; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class TestLDAPUriParser { + + @Test + public void testLDAPUriParser() { + final LDAPUriParser ldapUriParser = new LDAPUriParser("ldap://localhost:10389/dc=example,dc=com"); + assertEquals("localhost", ldapUriParser.getHost()); + assertEquals("10389", ldapUriParser.getPort()); + assertEquals("dc=example,dc=com", ldapUriParser.getDn()); + assertEquals(false, ldapUriParser.isUseTLS()); + } + +}