remove unused external email and jsps

This commit is contained in:
Peter Hormanns 2021-12-07 19:41:17 +01:00
parent 1d521e7ba0
commit 694d20e4b7
22 changed files with 35 additions and 109 deletions

View File

@ -5,7 +5,7 @@
<groupId>de.jalin.ldapadmin</groupId> <groupId>de.jalin.ldapadmin</groupId>
<artifactId>ldapadmin</artifactId> <artifactId>ldapadmin</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.0.1</version> <version>1.0.2</version>
<name>LDAP Admin Webapp</name> <name>LDAP Admin Webapp</name>
<properties> <properties>

View File

@ -18,8 +18,7 @@ public class User implements Serializable, LDAPBean {
private String firstname; private String firstname;
private String lastname; private String lastname;
private String displayname; private String displayname;
private String emailInternal; private String email;
private String emailExternal;
private String phone; private String phone;
private String mobile; private String mobile;
private List<String> groups; private List<String> groups;
@ -79,20 +78,12 @@ public class User implements Serializable, LDAPBean {
this.displayname = displayname; this.displayname = displayname;
} }
public String getEmailInternal() { public String getEmail() {
return emailInternal; return email;
} }
public void setEmailInternal(String email) { public void setEmail(String email) {
this.emailInternal = email; this.email = email;
}
public String getEmailExternal() {
return emailExternal;
}
public void setEmailExternal(String email) {
this.emailExternal = email;
} }
public String getPhone() { public String getPhone() {
@ -121,7 +112,7 @@ public class User implements Serializable, LDAPBean {
@Override @Override
public String toString() { public String toString() {
return getFirstname() + " " + getLastname() + " (" + getLogin() + ", " + getEmailExternal() + ")"; return getFirstname() + " " + getLastname() + " (" + getLogin() + ", " + getEmail() + ")";
} }
@Override @Override

View File

@ -16,7 +16,6 @@ public class LDAPConfig {
private String smtpFromAddress; private String smtpFromAddress;
private String smtpHost; private String smtpHost;
private String smtpPort; private String smtpPort;
private String smtpInternalDomains;
private String pacAdmin; private String pacAdmin;
private String pacPassword; private String pacPassword;
private String tempDir; private String tempDir;
@ -28,7 +27,6 @@ public class LDAPConfig {
smtpHost = "localhost"; smtpHost = "localhost";
smtpPort = "25"; smtpPort = "25";
smtpFromAddress = "nobody@example.com"; smtpFromAddress = "nobody@example.com";
smtpInternalDomains = "example.com,example.org";
tempDir = System.getProperty("java.io.tmpdir"); tempDir = System.getProperty("java.io.tmpdir");
try { try {
final Properties props = loadConfig(); final Properties props = loadConfig();
@ -38,7 +36,6 @@ public class LDAPConfig {
smtpHost = props.getProperty("smtp.host", smtpHost); smtpHost = props.getProperty("smtp.host", smtpHost);
smtpPort = props.getProperty("smtp.port", smtpPort); smtpPort = props.getProperty("smtp.port", smtpPort);
smtpFromAddress = props.getProperty("smtp.from", smtpFromAddress); smtpFromAddress = props.getProperty("smtp.from", smtpFromAddress);
smtpInternalDomains = props.getProperty("smtp.internal", smtpInternalDomains);
pacAdmin = props.getProperty("pac.user", "xyz00"); pacAdmin = props.getProperty("pac.user", "xyz00");
pacPassword = props.getProperty("pac.password", "secret"); pacPassword = props.getProperty("pac.password", "secret");
tempDir = props.getProperty("temp.dir", tempDir); tempDir = props.getProperty("temp.dir", tempDir);
@ -78,10 +75,6 @@ public class LDAPConfig {
return smtpFromAddress; return smtpFromAddress;
} }
public String getSmtpInternalDomains() {
return smtpInternalDomains;
}
public String getTempDir() { public String getTempDir() {
return tempDir; return tempDir;
} }

View File

@ -30,8 +30,7 @@ public class UsersDAO {
final User usr = new User(); final User usr = new User();
usr.setFirstname(session.getStringValue(attribs, "givenName")); usr.setFirstname(session.getStringValue(attribs, "givenName"));
usr.setLastname(session.getStringValue(attribs, "sn")); usr.setLastname(session.getStringValue(attribs, "sn"));
usr.setEmailInternal(session.getStringValue(attribs, "mail")); usr.setEmail(session.getStringValue(attribs, "mail"));
usr.setEmailExternal(session.getStringValue(attribs, "description"));
usr.setLogin(session.getStringValue(attribs, "uid")); usr.setLogin(session.getStringValue(attribs, "uid"));
usr.setPhone(session.getStringValue(attribs, "telephoneNumber")); usr.setPhone(session.getStringValue(attribs, "telephoneNumber"));
usr.setMobile(session.getStringValue(attribs, "mobile")); usr.setMobile(session.getStringValue(attribs, "mobile"));
@ -68,15 +67,11 @@ public class UsersDAO {
} }
attributes.put("sn", lastname); attributes.put("sn", lastname);
final BasicAttribute mail = new BasicAttribute("mail"); final BasicAttribute mail = new BasicAttribute("mail");
final String emailInternal = usr.getEmailInternal(); final String email = usr.getEmail();
if (hasValue(emailInternal)) { if (hasValue(email)) {
mail.add(emailInternal); mail.add(email);
} }
attributes.put(mail); attributes.put(mail);
final String emailExternal = usr.getEmailExternal();
if (hasValue(emailExternal)) {
attributes.put("description", emailExternal);
}
attributes.put("uid", uid); attributes.put("uid", uid);
attributes.put("cn", uid); attributes.put("cn", uid);
final String telephone = usr.getPhone(); final String telephone = usr.getPhone();
@ -107,8 +102,7 @@ public class UsersDAO {
final User usr = new User(); final User usr = new User();
usr.setFirstname(session.getStringValue(attribs, "givenName")); usr.setFirstname(session.getStringValue(attribs, "givenName"));
usr.setLastname(session.getStringValue(attribs, "sn")); usr.setLastname(session.getStringValue(attribs, "sn"));
usr.setEmailExternal(session.getStringValue(attribs, "description")); usr.setEmail(session.getStringValue(attribs, "mail"));
usr.setEmailInternal(session.getStringValue(attribs, "mail"));
usr.setLogin(session.getStringValue(attribs, "uid")); usr.setLogin(session.getStringValue(attribs, "uid"));
usr.setPhone(session.getStringValue(attribs, "telephoneNumber")); usr.setPhone(session.getStringValue(attribs, "telephoneNumber"));
usr.setMobile(session.getStringValue(attribs, "mobile")); usr.setMobile(session.getStringValue(attribs, "mobile"));
@ -127,13 +121,9 @@ public class UsersDAO {
final List<ModificationItem> updates = new ArrayList<ModificationItem>(); final List<ModificationItem> updates = new ArrayList<ModificationItem>();
addStringAttrUpdate(updates, attribs, "displayName", usr.getDisplayname()); addStringAttrUpdate(updates, attribs, "displayName", usr.getDisplayname());
final ArrayList<String> emailAdressList = new ArrayList<String>(); final ArrayList<String> emailAdressList = new ArrayList<String>();
final String emailInternal = usr.getEmailInternal(); final String email = usr.getEmail();
if (hasValue(emailInternal)) { if (hasValue(email)) {
emailAdressList.add(emailInternal); emailAdressList.add(email);
}
final String emailExternal = usr.getEmailExternal();
if (hasValue(emailExternal)) {
addStringAttrUpdate(updates, attribs, "description", emailExternal);
} }
addMultiValueAttrUpdate(updates, attribs, "mail", emailAdressList); addMultiValueAttrUpdate(updates, attribs, "mail", emailAdressList);
addStringAttrUpdate(updates, attribs, "givenName", usr.getFirstname()); addStringAttrUpdate(updates, attribs, "givenName", usr.getFirstname());

View File

@ -19,7 +19,7 @@ import de.jalin.ldapadmin.ldap.LDAPSessionException;
import de.jalin.ldapadmin.ldap.SimplePasswordException; import de.jalin.ldapadmin.ldap.SimplePasswordException;
import de.jalin.ldapadmin.ldap.UsersDAO; 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 { public class ProfileServlet extends AbstractLDAPServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -142,12 +142,9 @@ public class ResetPasswordServlet extends AbstractLDAPServlet {
final SortedMap<String, User> usersMap = usrDAO.loadUsers(); final SortedMap<String, User> usersMap = usrDAO.loadUsers();
final Collection<User> allUsers = usersMap.values(); final Collection<User> allUsers = usersMap.values();
for (User usr : allUsers) { for (User usr : allUsers) {
if (usr.getEmailInternal() != null && usr.getEmailInternal().equalsIgnoreCase(loginOrEMail)) { if (usr.getEmail() != null && usr.getEmail().equalsIgnoreCase(loginOrEMail)) {
login = usr.getLogin(); login = usr.getLogin();
email = usr.getEmailExternal(); email = usr.getEmail();
if (email == null || email.isEmpty()) {
email = usr.getEmailInternal();
}
salutation = usr.getFirstname() + " " + usr.getLastname(); salutation = usr.getFirstname() + " " + usr.getLastname();
} }
} }
@ -155,10 +152,7 @@ public class ResetPasswordServlet extends AbstractLDAPServlet {
final User usr = usrDAO.read("uid=" + loginOrEMail + ",ou=users,"); final User usr = usrDAO.read("uid=" + loginOrEMail + ",ou=users,");
if (usr != null) { if (usr != null) {
login = usr.getLogin(); login = usr.getLogin();
email = usr.getEmailExternal(); email = usr.getEmail();
if (email == null || email.isEmpty()) {
email = usr.getEmailInternal();
}
salutation = usr.getFirstname() + " " + usr.getLastname(); salutation = usr.getFirstname() + " " + usr.getLastname();
} }
} }

View File

@ -85,7 +85,6 @@ public class UserServlet extends AbstractLDAPServlet {
final String firstname = req.getParameter("firstname"); final String firstname = req.getParameter("firstname");
final String lastname = req.getParameter("lastname"); final String lastname = req.getParameter("lastname");
final String email = req.getParameter("email"); final String email = req.getParameter("email");
final String emailExt = req.getParameter("extemail");
final String phone = req.getParameter("phone"); final String phone = req.getParameter("phone");
final String mobile = req.getParameter("mobile"); final String mobile = req.getParameter("mobile");
final String password = req.getParameter("password"); final String password = req.getParameter("password");
@ -98,8 +97,7 @@ public class UserServlet extends AbstractLDAPServlet {
usr.setFirstname(firstname); usr.setFirstname(firstname);
usr.setLastname(lastname); usr.setLastname(lastname);
usr.setDisplayname(firstname + " " + lastname); usr.setDisplayname(firstname + " " + lastname);
usr.setEmailInternal(email); usr.setEmail(email);
usr.setEmailExternal(emailExt);
usr.setPhone(phone); usr.setPhone(phone);
usr.setMobile(mobile); usr.setMobile(mobile);
final List<String> memberships = new ArrayList<>(); final List<String> memberships = new ArrayList<>();

View File

@ -1,2 +0,0 @@
contact.title=LDAP Administration
contact.text=We 'll answer your questions gladly.

View File

@ -1,2 +0,0 @@
contact.title=LDAP Administration
contact.text=Ihre Fragen beantworten wir Ihnen gern.

View File

@ -1,2 +0,0 @@
contact.title=LDAP Administration
contact.text=We 'll answer your questions gladly.

View File

@ -11,7 +11,7 @@
<url-pattern>*.js</url-pattern> <url-pattern>*.js</url-pattern>
</servlet-mapping> </servlet-mapping>
<welcome-file-list> <welcome-file-list>
<welcome-file>/index.jsp</welcome-file> <welcome-file>/profile</welcome-file>
</welcome-file-list> </welcome-file-list>
<error-page> <error-page>
<error-code>403</error-code> <error-code>403</error-code>
@ -28,8 +28,6 @@
<security-constraint> <security-constraint>
<web-resource-collection> <web-resource-collection>
<web-resource-name>Public access</web-resource-name> <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>*.css</url-pattern>
<url-pattern>*.js</url-pattern> <url-pattern>*.js</url-pattern>
<url-pattern>/css/*</url-pattern> <url-pattern>/css/*</url-pattern>
@ -43,9 +41,9 @@
<security-constraint> <security-constraint>
<web-resource-collection> <web-resource-collection>
<web-resource-name>Profile Area</web-resource-name> <web-resource-name>Profile Area</web-resource-name>
<url-pattern>/</url-pattern>
<url-pattern>/profile</url-pattern> <url-pattern>/profile</url-pattern>
<url-pattern>/profile/*</url-pattern> <url-pattern>/profile/*</url-pattern>
<url-pattern>/</url-pattern>
</web-resource-collection> </web-resource-collection>
<auth-constraint> <auth-constraint>
<role-name>ldapadmin</role-name> <role-name>ldapadmin</role-name>

View File

@ -1,19 +0,0 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setBundle basename="de.jalin.ldapadmin.contact"/>
<!DOCTYPE html>
<html lang="{language}">
<jsp:include page="template/header.jsp"/>
<body>
<jsp:include page="template/navbar.jsp"/>
<!-- Page Content -->
<div class="container">
<h1><fmt:message key="contact.title"/></h1>
<p><fmt:message key="contact.text"/></p>
<a href="mailto:service@example.com">E-Mail an <em>service@example.com</em></a>
</div>
<jsp:include page="template/footer.jsp"/>
</body>
</html>

View File

@ -11,16 +11,13 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </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>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li> <li>
<a href="<c:url value="/profile"/>"><fmt:message key="navbar.item.profile"/></a> <a href="<c:url value="/profile"/>"><fmt:message key="navbar.item.profile"/></a>
</li> </li>
<li>
<a href="<c:url value="/contact.jsp"/>"><fmt:message key="navbar.item.contact"/></a>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </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>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">

View File

@ -84,15 +84,7 @@
<div class="col-sm-9"> <div class="col-sm-9">
<input <input
type="email" class="form-control" id="email" name="email" type="email" class="form-control" id="email" name="email"
value="${user.emailInternal}" placeholder="Enter email"> value="${user.email}" 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">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -61,7 +61,7 @@ public class TestCreateGroup {
final User newUser = new User(); final User newUser = new User();
newUser.setDn(USERS_DN.replace("${uid}", uid)); newUser.setDn(USERS_DN.replace("${uid}", uid));
newUser.setDisplayname(fn + " " + ln); newUser.setDisplayname(fn + " " + ln);
newUser.setEmailInternal(fn.toLowerCase() + "." + ln.toLowerCase() + "@example.com"); newUser.setEmail(fn.toLowerCase() + "." + ln.toLowerCase() + "@example.com");
newUser.setFirstname(fn); newUser.setFirstname(fn);
newUser.setLastname(ln); newUser.setLastname(ln);
newUser.setLogin(uid); newUser.setLogin(uid);

View File

@ -40,8 +40,7 @@ public class TestCreateUser {
final User newUser = new User(); final User newUser = new User();
newUser.setDn(USERS_DN); newUser.setDn(USERS_DN);
newUser.setDisplayname("Peter Petersen"); newUser.setDisplayname("Peter Petersen");
newUser.setEmailInternal("peter.petersen@example.com"); newUser.setEmail("peter.petersen@example.com");
newUser.setEmailExternal("peter.petersen@external.com");
newUser.setFirstname("Peter"); newUser.setFirstname("Peter");
newUser.setLastname("Petersen"); newUser.setLastname("Petersen");
newUser.setLogin("pet"); newUser.setLogin("pet");
@ -51,8 +50,7 @@ public class TestCreateUser {
dao.create(newUser); dao.create(newUser);
final User createdUser = dao.loadUsers().get(USERS_DN); final User createdUser = dao.loadUsers().get(USERS_DN);
assertNotNull("should exist", createdUser); assertNotNull("should exist", createdUser);
assertTrue("peter.petersen@example.com".equals(createdUser.getEmailInternal())); assertTrue("peter.petersen@example.com".equals(createdUser.getEmail()));
assertTrue("peter.petersen@external.com".equals(createdUser.getEmailExternal()));
} catch (LDAPSessionException | RequiredAttributeException | AlreadyBoundException e) { } catch (LDAPSessionException | RequiredAttributeException | AlreadyBoundException e) {
fail(e.getMessage()); fail(e.getMessage());
} }

View File

@ -40,7 +40,7 @@ public class TestDeleteUser {
final User newUser = new User(); final User newUser = new User();
newUser.setDn(USERS_DN); newUser.setDn(USERS_DN);
newUser.setDisplayname("Hein Hanssen"); newUser.setDisplayname("Hein Hanssen");
newUser.setEmailInternal("hein.hanssen@example.com"); newUser.setEmail("hein.hanssen@example.com");
newUser.setFirstname("Hein"); newUser.setFirstname("Hein");
newUser.setLastname("Hanssen"); newUser.setLastname("Hanssen");
newUser.setLogin("hei"); newUser.setLogin("hei");

View File

@ -40,7 +40,7 @@ public class TestReadUser {
final User newUser = new User(); final User newUser = new User();
newUser.setDn(USERS_DN); newUser.setDn(USERS_DN);
newUser.setDisplayname("Chris Christansen"); newUser.setDisplayname("Chris Christansen");
newUser.setEmailInternal("chris.christansen@example.com"); newUser.setEmail("chris.christansen@example.com");
newUser.setFirstname("Chris"); newUser.setFirstname("Chris");
newUser.setLastname("Christansen"); newUser.setLastname("Christansen");
newUser.setLogin("chr"); newUser.setLogin("chr");
@ -52,7 +52,7 @@ public class TestReadUser {
assertNotNull("should exist", createdUser); assertNotNull("should exist", createdUser);
final User readUser = dao.read(USERS_DN); final User readUser = dao.read(USERS_DN);
assertNotNull(readUser); assertNotNull(readUser);
assertTrue("chris.christansen@example.com".equals(readUser.getEmailInternal())); assertTrue("chris.christansen@example.com".equals(readUser.getEmail()));
} catch (LDAPSessionException | RequiredAttributeException | AlreadyBoundException e) { } catch (LDAPSessionException | RequiredAttributeException | AlreadyBoundException e) {
fail(e.getMessage()); fail(e.getMessage());
} }

View File

@ -48,7 +48,7 @@ public class TestUpdateAsBindUser {
final User newUser = new User(); final User newUser = new User();
newUser.setDn(USERS_DN); newUser.setDn(USERS_DN);
newUser.setDisplayname("Paul Paulsen"); newUser.setDisplayname("Paul Paulsen");
newUser.setEmailInternal("paul.paulsen@example.com"); newUser.setEmail("paul.paulsen@example.com");
newUser.setFirstname("Paul"); newUser.setFirstname("Paul");
newUser.setLastname("Pausen"); newUser.setLastname("Pausen");
newUser.setLogin("pau"); newUser.setLogin("pau");

View File

@ -31,7 +31,7 @@ public class TestUpdateAsSimpleUser {
final User newUser = new User(); final User newUser = new User();
newUser.setDn(USERS_DN); newUser.setDn(USERS_DN);
newUser.setDisplayname("Paul Petersen"); newUser.setDisplayname("Paul Petersen");
newUser.setEmailInternal("paul.petersen@example.com"); newUser.setEmail("paul.petersen@example.com");
newUser.setFirstname("Paul"); newUser.setFirstname("Paul");
newUser.setLastname("Petersen"); newUser.setLastname("Petersen");
newUser.setLogin("plp"); newUser.setLogin("plp");
@ -61,7 +61,7 @@ public class TestUpdateAsSimpleUser {
final User newUser = new User(); final User newUser = new User();
newUser.setDn(USERS_DN); newUser.setDn(USERS_DN);
newUser.setDisplayname("Micha Michaelsen"); newUser.setDisplayname("Micha Michaelsen");
newUser.setEmailInternal("micha.michaelsen@example.com"); newUser.setEmail("micha.michaelsen@example.com");
newUser.setFirstname("Michael"); newUser.setFirstname("Michael");
newUser.setLastname("Michaelsen"); newUser.setLastname("Michaelsen");
newUser.setLogin("mic"); newUser.setLogin("mic");

View File

@ -43,7 +43,7 @@ public class TestUpdateUser {
final User newUser = new User(); final User newUser = new User();
newUser.setDn(USERS_DN); newUser.setDn(USERS_DN);
newUser.setDisplayname("Klaas Clahsen"); newUser.setDisplayname("Klaas Clahsen");
newUser.setEmailInternal("klaas.clahsen@example.com"); newUser.setEmail("klaas.clahsen@example.com");
newUser.setFirstname("Klaas"); newUser.setFirstname("Klaas");
newUser.setLastname("Klahsen"); newUser.setLastname("Klahsen");
newUser.setLogin("kla"); newUser.setLogin("kla");