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>
<artifactId>ldapadmin</artifactId>
<packaging>war</packaging>
<version>1.0.1</version>
<version>1.0.2</version>
<name>LDAP Admin Webapp</name>
<properties>

View File

@ -18,8 +18,7 @@ public class User implements Serializable, LDAPBean {
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 @@ public class User implements Serializable, LDAPBean {
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 @@ public class User implements Serializable, LDAPBean {
@Override
public String toString() {
return getFirstname() + " " + getLastname() + " (" + getLogin() + ", " + getEmailExternal() + ")";
return getFirstname() + " " + getLastname() + " (" + getLogin() + ", " + getEmail() + ")";
}
@Override

View File

@ -16,7 +16,6 @@ public class LDAPConfig {
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 @@ public class LDAPConfig {
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 @@ public class LDAPConfig {
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);
@ -78,10 +75,6 @@ public class LDAPConfig {
return smtpFromAddress;
}
public String getSmtpInternalDomains() {
return smtpInternalDomains;
}
public String getTempDir() {
return tempDir;
}

View File

@ -30,8 +30,7 @@ public class UsersDAO {
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 @@ public class UsersDAO {
}
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 @@ public class UsersDAO {
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 @@ public class UsersDAO {
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());

View File

@ -19,7 +19,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/*"}, loadOnStartup = 1)
@WebServlet(name = "LdapProfile", urlPatterns = {"/", "/profile", "/profile/*"}, loadOnStartup = 1)
public class ProfileServlet extends AbstractLDAPServlet {
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 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 @@ public class ResetPasswordServlet extends AbstractLDAPServlet {
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();
}
}

View File

@ -85,7 +85,6 @@ public class UserServlet extends AbstractLDAPServlet {
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 @@ public class UserServlet extends AbstractLDAPServlet {
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<>();

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>
</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>

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>
</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>
</div>

View File

@ -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">

View File

@ -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">

View File

@ -61,7 +61,7 @@ public class TestCreateGroup {
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);

View File

@ -40,8 +40,7 @@ public class TestCreateUser {
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 @@ public class TestCreateUser {
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());
}

View File

@ -40,7 +40,7 @@ public class TestDeleteUser {
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");

View File

@ -40,7 +40,7 @@ public class TestReadUser {
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 @@ public class TestReadUser {
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());
}

View File

@ -48,7 +48,7 @@ public class TestUpdateAsBindUser {
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");

View File

@ -31,7 +31,7 @@ public class TestUpdateAsSimpleUser {
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 @@ public class TestUpdateAsSimpleUser {
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");

View File

@ -43,7 +43,7 @@ public class TestUpdateUser {
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");