format code
This commit is contained in:
parent
904f4c330f
commit
22dd341de7
@ -13,7 +13,7 @@ public class Group implements Serializable, LDAPBean {
|
|||||||
private List<String> members;
|
private List<String> members;
|
||||||
|
|
||||||
public Group() {
|
public Group() {
|
||||||
members = new ArrayList<String>();
|
members = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -22,9 +22,9 @@ public class GroupsDAO {
|
|||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedMap<String, Group> loadGroups(final SortedMap<String, User> users) throws LDAPSessionException
|
public SortedMap<String, Group> loadGroups(final SortedMap<String, User> users) throws LDAPSessionException {
|
||||||
{
|
final SortedMap<String, Group> list;
|
||||||
final SortedMap<String, Group> list = new TreeMap<String, Group>();
|
list = new TreeMap<>();
|
||||||
final List<SearchResult> searchResult = session.search("ou=groups"); //$NON-NLS-1$
|
final List<SearchResult> searchResult = session.search("ou=groups"); //$NON-NLS-1$
|
||||||
for (final SearchResult result : searchResult) {
|
for (final SearchResult result : searchResult) {
|
||||||
final Attributes attribs = result.getAttributes();
|
final Attributes attribs = result.getAttributes();
|
||||||
@ -33,11 +33,9 @@ public class GroupsDAO {
|
|||||||
grp.setDn(result.getNameInNamespace());
|
grp.setDn(result.getNameInNamespace());
|
||||||
final List<String> listOfMembers = session.getListOfValues(attribs, "uniqueMember"); //$NON-NLS-1$
|
final List<String> listOfMembers = session.getListOfValues(attribs, "uniqueMember"); //$NON-NLS-1$
|
||||||
final String dn = grp.getDn();
|
final String dn = grp.getDn();
|
||||||
for (String userDN : listOfMembers) {
|
listOfMembers.stream().map((userDN) -> users.get(userDN)).map((user) -> user.getGroups()).forEachOrdered((groups) -> {
|
||||||
final User user = users.get(userDN);
|
|
||||||
final List<String> groups = user.getGroups();
|
|
||||||
groups.add(dn);
|
groups.add(dn);
|
||||||
}
|
});
|
||||||
grp.setMembers(listOfMembers);
|
grp.setMembers(listOfMembers);
|
||||||
list.put(dn, grp);
|
list.put(dn, grp);
|
||||||
}
|
}
|
||||||
@ -57,9 +55,9 @@ public class GroupsDAO {
|
|||||||
final List<String> uniqueMembers = grp.getMembers();
|
final List<String> uniqueMembers = grp.getMembers();
|
||||||
final BasicAttribute uniqMembers = new BasicAttribute("uniqueMember"); //$NON-NLS-1$
|
final BasicAttribute uniqMembers = new BasicAttribute("uniqueMember"); //$NON-NLS-1$
|
||||||
if (uniqueMembers != null && uniqueMembers.size() > 0) {
|
if (uniqueMembers != null && uniqueMembers.size() > 0) {
|
||||||
for (String dn : uniqueMembers) {
|
uniqueMembers.forEach((dn) -> {
|
||||||
uniqMembers.add(dn);
|
uniqMembers.add(dn);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
attributes.put(uniqMembers);
|
attributes.put(uniqMembers);
|
||||||
final String dn = session.createSubcontext("cn=${cn},ou=groups".replace("${cn}", name), attributes); //$NON-NLS-1$ //$NON-NLS-2$
|
final String dn = session.createSubcontext("cn=${cn},ou=groups".replace("${cn}", name), attributes); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
@ -72,11 +70,9 @@ public class GroupsDAO {
|
|||||||
grp.setDn(dn);
|
grp.setDn(dn);
|
||||||
grp.setName(session.getStringValue(attribs, "cn")); //$NON-NLS-1$
|
grp.setName(session.getStringValue(attribs, "cn")); //$NON-NLS-1$
|
||||||
final List<String> listOfMembers = session.getListOfValues(attribs, "uniqueMember"); //$NON-NLS-1$
|
final List<String> listOfMembers = session.getListOfValues(attribs, "uniqueMember"); //$NON-NLS-1$
|
||||||
for (String userDN : listOfMembers) {
|
listOfMembers.stream().map((userDN) -> users.get(userDN)).map((user) -> user.getGroups()).forEachOrdered((groups) -> {
|
||||||
final User user = users.get(userDN);
|
|
||||||
final List<String> groups = user.getGroups();
|
|
||||||
groups.add(dn);
|
groups.add(dn);
|
||||||
}
|
});
|
||||||
grp.setMembers(listOfMembers);
|
grp.setMembers(listOfMembers);
|
||||||
return grp;
|
return grp;
|
||||||
}
|
}
|
||||||
@ -85,15 +81,15 @@ public class GroupsDAO {
|
|||||||
assert grp != null;
|
assert grp != null;
|
||||||
final String name = grp.getName();
|
final String name = grp.getName();
|
||||||
assert name != null;
|
assert name != null;
|
||||||
if (grp.getMembers().size() == 0) {
|
if (grp.getMembers().isEmpty()) {
|
||||||
throw new NoGroupMembersException(name);
|
throw new NoGroupMembersException(name);
|
||||||
}
|
}
|
||||||
final BasicAttribute membersOfAttrib = new BasicAttribute("uniqueMember"); //$NON-NLS-1$
|
final BasicAttribute membersOfAttrib = new BasicAttribute("uniqueMember"); //$NON-NLS-1$
|
||||||
for (final String memberDN : grp.getMembers()) {
|
grp.getMembers().forEach((memberDN) -> {
|
||||||
membersOfAttrib.add(memberDN);
|
membersOfAttrib.add(memberDN);
|
||||||
}
|
});
|
||||||
final ModificationItem modificationItem = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, membersOfAttrib);
|
final ModificationItem modificationItem = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, membersOfAttrib);
|
||||||
session.modifyAttributes("cn=${cn},ou=groups".replace("${cn}", name), new ModificationItem[] { modificationItem }); //$NON-NLS-1$ //$NON-NLS-2$
|
session.modifyAttributes("cn=${cn},ou=groups".replace("${cn}", name), new ModificationItem[]{modificationItem}); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMemberships(final User usr) throws LDAPSessionException, NoGroupMembersException {
|
public void updateMemberships(final User usr) throws LDAPSessionException, NoGroupMembersException {
|
||||||
|
@ -20,7 +20,7 @@ import javax.naming.directory.SearchResult;
|
|||||||
|
|
||||||
public class LDAPSession {
|
public class LDAPSession {
|
||||||
|
|
||||||
private InitialDirContext ctx;
|
private InitialDirContext ctx;
|
||||||
|
|
||||||
public LDAPSession(final String providerURL, final String principal, final String password) throws LDAPSessionException {
|
public LDAPSession(final String providerURL, final String principal, final String password) throws LDAPSessionException {
|
||||||
final Properties env = new Properties();
|
final Properties env = new Properties();
|
||||||
@ -69,7 +69,8 @@ private InitialDirContext ctx;
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final int size = attribute.size();
|
final int size = attribute.size();
|
||||||
List<String> listOfValues = new ArrayList<String>();
|
List<String> listOfValues;
|
||||||
|
listOfValues = new ArrayList<>();
|
||||||
for (int idx = 0; idx < size; idx++) {
|
for (int idx = 0; idx < size; idx++) {
|
||||||
listOfValues.add((String) attribute.get(idx));
|
listOfValues.add((String) attribute.get(idx));
|
||||||
}
|
}
|
||||||
@ -91,7 +92,8 @@ private InitialDirContext ctx;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<SearchResult> search(final String name, final String attribName, final String attribValue) throws LDAPSessionException {
|
public List<SearchResult> search(final String name, final String attribName, final String attribValue) throws LDAPSessionException {
|
||||||
final List<SearchResult> searchResult = new ArrayList<SearchResult>();
|
final List<SearchResult> searchResult;
|
||||||
|
searchResult = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
Attributes matchingAttributes = new BasicAttributes();
|
Attributes matchingAttributes = new BasicAttributes();
|
||||||
matchingAttributes.put(attribName, attribValue);
|
matchingAttributes.put(attribName, attribValue);
|
||||||
@ -106,7 +108,8 @@ private InitialDirContext ctx;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<SearchResult> search(final String name) throws LDAPSessionException {
|
public List<SearchResult> search(final String name) throws LDAPSessionException {
|
||||||
final List<SearchResult> searchResult = new ArrayList<SearchResult>();
|
final List<SearchResult> searchResult;
|
||||||
|
searchResult = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
final NamingEnumeration<SearchResult> searchEnum = ctx.search(name, null);
|
final NamingEnumeration<SearchResult> searchEnum = ctx.search(name, null);
|
||||||
while (searchEnum.hasMore()) {
|
while (searchEnum.hasMore()) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package de.jalin.ldapadmin.ldap;
|
package de.jalin.ldapadmin.ldap;
|
||||||
|
|
||||||
|
|
||||||
public class PasswordValidator {
|
public class PasswordValidator {
|
||||||
|
|
||||||
private static final int MIN_PASSWORD_LEN = 6;
|
private static final int MIN_PASSWORD_LEN = 6;
|
||||||
@ -24,13 +23,15 @@ public class PasswordValidator {
|
|||||||
} else {
|
} else {
|
||||||
if (type == Character.LOWERCASE_LETTER) {
|
if (type == Character.LOWERCASE_LETTER) {
|
||||||
hasLowerCaseChar = 1;
|
hasLowerCaseChar = 1;
|
||||||
} else
|
} else {
|
||||||
if (type == Character.UPPERCASE_LETTER) {
|
if (type == Character.UPPERCASE_LETTER) {
|
||||||
hasUpperCaseChar = 1;
|
hasUpperCaseChar = 1;
|
||||||
} else
|
} else {
|
||||||
hasSpecialChar = 1;
|
hasSpecialChar = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (hasDigits + hasLowerCaseChar + hasUpperCaseChar + hasSpecialChar < 3) {
|
if (hasDigits + hasLowerCaseChar + hasUpperCaseChar + hasSpecialChar < 3) {
|
||||||
throw new SimplePasswordException("a password requires 3 out of 4 "
|
throw new SimplePasswordException("a password requires 3 out of 4 "
|
||||||
+ "different character types: lowercase, uppercase, digits and special characters");
|
+ "different character types: lowercase, uppercase, digits and special characters");
|
||||||
|
@ -22,8 +22,7 @@ public class UsersDAO {
|
|||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedMap<String, User> loadUsers() throws LDAPSessionException
|
public SortedMap<String, User> loadUsers() throws LDAPSessionException {
|
||||||
{
|
|
||||||
final SortedMap<String, User> usersHash = new TreeMap<String, User>();
|
final SortedMap<String, User> usersHash = new TreeMap<String, User>();
|
||||||
final List<SearchResult> enumeration = session.search("ou=users"); //$NON-NLS-1$
|
final List<SearchResult> enumeration = session.search("ou=users"); //$NON-NLS-1$
|
||||||
for (SearchResult result : enumeration) {
|
for (SearchResult result : enumeration) {
|
||||||
@ -124,7 +123,7 @@ public class UsersDAO {
|
|||||||
addStringAttrUpdate(updates, attribs, "mobile", usr.getMobile()); //$NON-NLS-1$
|
addStringAttrUpdate(updates, attribs, "mobile", usr.getMobile()); //$NON-NLS-1$
|
||||||
addStringAttrUpdate(updates, attribs, "telephoneNumber", usr.getPhone()); //$NON-NLS-1$
|
addStringAttrUpdate(updates, attribs, "telephoneNumber", usr.getPhone()); //$NON-NLS-1$
|
||||||
addPasswordUpdate(updates, "userPassword", usr.getPassword()); //$NON-NLS-1$
|
addPasswordUpdate(updates, "userPassword", usr.getPassword()); //$NON-NLS-1$
|
||||||
session.modifyAttributes("uid=${uid},ou=users".replace("${uid}", uid), updates.toArray(new ModificationItem[] { })); //$NON-NLS-1$ //$NON-NLS-2$
|
session.modifyAttributes("uid=${uid},ou=users".replace("${uid}", uid), updates.toArray(new ModificationItem[]{})); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(final User user) throws LDAPSessionException {
|
public void delete(final User user) throws LDAPSessionException {
|
||||||
|
@ -66,8 +66,7 @@ public class AbstractLDAPServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void throwServletException(final HttpSession session, final Exception e) throws ServletException
|
protected void throwServletException(final HttpSession session, final Exception e) throws ServletException {
|
||||||
{
|
|
||||||
session.setAttribute("servletexception", e); //$NON-NLS-1$
|
session.setAttribute("servletexception", e); //$NON-NLS-1$
|
||||||
LOG.severe(e.getMessage());
|
LOG.severe(e.getMessage());
|
||||||
throw new ServletException(e);
|
throw new ServletException(e);
|
||||||
|
@ -20,7 +20,7 @@ import de.jalin.ldapadmin.ldap.LDAPSessionException;
|
|||||||
import de.jalin.ldapadmin.ldap.NoGroupMembersException;
|
import de.jalin.ldapadmin.ldap.NoGroupMembersException;
|
||||||
import de.jalin.ldapadmin.ldap.UsersDAO;
|
import de.jalin.ldapadmin.ldap.UsersDAO;
|
||||||
|
|
||||||
@WebServlet(name="LdapGroup",urlPatterns={"/group/*"})
|
@WebServlet(name = "LdapGroup", urlPatterns = {"/group/*"})
|
||||||
public class GroupServlet extends AbstractLDAPServlet {
|
public class GroupServlet extends AbstractLDAPServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -43,7 +43,6 @@ public class GroupServlet extends AbstractLDAPServlet {
|
|||||||
httpSession.setAttribute("formdisabled", "view".equals(operation) || "delete".equals(operation) ? "disabled" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
httpSession.setAttribute("formdisabled", "view".equals(operation) || "delete".equals(operation) ? "disabled" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
||||||
httpSession.setAttribute("iddisabled", "create".equals(operation) ? "" : "disabled"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
httpSession.setAttribute("iddisabled", "create".equals(operation) ? "" : "disabled"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
|
||||||
|
|
||||||
final GroupsDAO groupsDAO = new GroupsDAO(ldapSession);
|
final GroupsDAO groupsDAO = new GroupsDAO(ldapSession);
|
||||||
final UsersDAO usersDAO = new UsersDAO(ldapSession);
|
final UsersDAO usersDAO = new UsersDAO(ldapSession);
|
||||||
try {
|
try {
|
||||||
@ -79,7 +78,8 @@ public class GroupServlet extends AbstractLDAPServlet {
|
|||||||
members = new ArrayList<>();
|
members = new ArrayList<>();
|
||||||
final HttpSession httpSession = req.getSession();
|
final HttpSession httpSession = req.getSession();
|
||||||
cleanSession(httpSession);
|
cleanSession(httpSession);
|
||||||
@SuppressWarnings("unchecked") final SortedMap<String, User> usersHash = (SortedMap<String, User>) httpSession.getAttribute("users"); //$NON-NLS-1$
|
@SuppressWarnings("unchecked")
|
||||||
|
final SortedMap<String, User> usersHash = (SortedMap<String, User>) httpSession.getAttribute("users"); //$NON-NLS-1$
|
||||||
final Iterator<String> userDNIterator = usersHash.keySet().iterator();
|
final Iterator<String> userDNIterator = usersHash.keySet().iterator();
|
||||||
while (userDNIterator.hasNext()) {
|
while (userDNIterator.hasNext()) {
|
||||||
final String userDN = userDNIterator.next();
|
final String userDN = userDNIterator.next();
|
||||||
|
@ -14,15 +14,14 @@ import de.jalin.ldapadmin.ldap.GroupsDAO;
|
|||||||
import de.jalin.ldapadmin.ldap.LDAPSessionException;
|
import de.jalin.ldapadmin.ldap.LDAPSessionException;
|
||||||
import de.jalin.ldapadmin.ldap.UsersDAO;
|
import de.jalin.ldapadmin.ldap.UsersDAO;
|
||||||
|
|
||||||
@WebServlet(name="LdapGroups",urlPatterns={"/groups"})
|
@WebServlet(name = "LdapGroups", urlPatterns = {"/groups"})
|
||||||
public class GroupsServlet extends AbstractLDAPServlet {
|
public class GroupsServlet extends AbstractLDAPServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
|
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
|
||||||
throws ServletException, IOException
|
throws ServletException, IOException {
|
||||||
{
|
|
||||||
final HttpSession httpSession = req.getSession();
|
final HttpSession httpSession = req.getSession();
|
||||||
cleanSession(httpSession);
|
cleanSession(httpSession);
|
||||||
final UsersDAO usersDAO = new UsersDAO(ldapSession);
|
final UsersDAO usersDAO = new UsersDAO(ldapSession);
|
||||||
|
@ -8,7 +8,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
@WebServlet(name="Logout",urlPatterns={"/logout"})
|
@WebServlet(name = "Logout", urlPatterns = {"/logout"})
|
||||||
public class LogoutServlet extends AbstractLDAPServlet {
|
public class LogoutServlet extends AbstractLDAPServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -19,7 +19,7 @@ public class NaiveTrustManager implements X509TrustManager {
|
|||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
SSL_CONTEXT = SSLContext.getInstance("TLSv1.2");
|
SSL_CONTEXT = SSLContext.getInstance("TLSv1.2");
|
||||||
SSL_CONTEXT.init(null, new TrustManager[] { new NaiveTrustManager() }, null);
|
SSL_CONTEXT.init(null, new TrustManager[]{new NaiveTrustManager()}, null);
|
||||||
SSLContext.setDefault(SSL_CONTEXT);
|
SSLContext.setDefault(SSL_CONTEXT);
|
||||||
} catch (NoSuchAlgorithmException | KeyManagementException e) {
|
} catch (NoSuchAlgorithmException | KeyManagementException e) {
|
||||||
throw new RuntimeException("Unable to initialise SSL context", e);
|
throw new RuntimeException("Unable to initialise SSL context", e);
|
||||||
|
@ -18,7 +18,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/*"})
|
@WebServlet(name = "LdapProfile", urlPatterns = {"/profile", "/profile/*"})
|
||||||
public class ProfileServlet extends AbstractLDAPServlet {
|
public class ProfileServlet extends AbstractLDAPServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -26,10 +26,9 @@ 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="ResetPassword",urlPatterns={"/passwordreset"})
|
@WebServlet(name = "ResetPassword", urlPatterns = {"/passwordreset"})
|
||||||
public class ResetPasswordServlet extends AbstractLDAPServlet {
|
public class ResetPasswordServlet extends AbstractLDAPServlet {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String smtpHost;
|
private String smtpHost;
|
||||||
@ -121,7 +120,7 @@ public class ResetPasswordServlet extends AbstractLDAPServlet {
|
|||||||
String salutation = ""; //$NON-NLS-1$
|
String salutation = ""; //$NON-NLS-1$
|
||||||
if (loginOrEMail != null) {
|
if (loginOrEMail != null) {
|
||||||
if (loginOrEMail.contains("@")) { //$NON-NLS-1$
|
if (loginOrEMail.contains("@")) { //$NON-NLS-1$
|
||||||
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.getEmail() != null && usr.getEmail().equalsIgnoreCase(loginOrEMail)) {
|
if (usr.getEmail() != null && usr.getEmail().equalsIgnoreCase(loginOrEMail)) {
|
||||||
@ -151,7 +150,7 @@ public class ResetPasswordServlet extends AbstractLDAPServlet {
|
|||||||
messageText.append(req.getRequestURL().toString().replaceAll("^http\\:", "https://"));
|
messageText.append(req.getRequestURL().toString().replaceAll("^http\\:", "https://"));
|
||||||
messageText.append("?token="); //$NON-NLS-1$
|
messageText.append("?token="); //$NON-NLS-1$
|
||||||
final String filename = tempFile.getName();
|
final String filename = tempFile.getName();
|
||||||
messageText.append(filename.substring(6,filename.length()-4));
|
messageText.append(filename.substring(6, filename.length() - 4));
|
||||||
messageText.append(messages.getString("ResetPasswordServlet.email_signature")); //$NON-NLS-1$
|
messageText.append(messages.getString("ResetPasswordServlet.email_signature")); //$NON-NLS-1$
|
||||||
smtpSend(smtpHost, smtpPort, messages, smtpFrom, email, messages.getString("ResetPasswordServlet.email_subject"), messageText.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
smtpSend(smtpHost, smtpPort, messages, smtpFrom, email, messages.getString("ResetPasswordServlet.email_subject"), messageText.toString()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
} catch (LDAPSessionException | IOException e) {
|
} catch (LDAPSessionException | IOException e) {
|
||||||
|
@ -23,7 +23,7 @@ import de.jalin.ldapadmin.ldap.RequiredAttributeException;
|
|||||||
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="LdapUser",urlPatterns={"/user/*"})
|
@WebServlet(name = "LdapUser", urlPatterns = {"/user/*"})
|
||||||
public class UserServlet extends AbstractLDAPServlet {
|
public class UserServlet extends AbstractLDAPServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -99,7 +99,8 @@ public class UserServlet extends AbstractLDAPServlet {
|
|||||||
usr.setMobile(mobile);
|
usr.setMobile(mobile);
|
||||||
final List<String> memberships;
|
final List<String> memberships;
|
||||||
memberships = new ArrayList<>();
|
memberships = new ArrayList<>();
|
||||||
@SuppressWarnings("unchecked") final SortedMap<String, Group> groupsHash = (SortedMap<String, Group>) httpSession.getAttribute("groups"); //$NON-NLS-1$
|
@SuppressWarnings("unchecked")
|
||||||
|
final SortedMap<String, Group> groupsHash = (SortedMap<String, Group>) httpSession.getAttribute("groups"); //$NON-NLS-1$
|
||||||
final Iterator<String> groupDNIterator = groupsHash.keySet().iterator();
|
final Iterator<String> groupDNIterator = groupsHash.keySet().iterator();
|
||||||
while (groupDNIterator.hasNext()) {
|
while (groupDNIterator.hasNext()) {
|
||||||
final String groupDN = groupDNIterator.next();
|
final String groupDN = groupDNIterator.next();
|
||||||
|
@ -15,7 +15,7 @@ import de.jalin.ldapadmin.ldap.GroupsDAO;
|
|||||||
import de.jalin.ldapadmin.ldap.LDAPSessionException;
|
import de.jalin.ldapadmin.ldap.LDAPSessionException;
|
||||||
import de.jalin.ldapadmin.ldap.UsersDAO;
|
import de.jalin.ldapadmin.ldap.UsersDAO;
|
||||||
|
|
||||||
@WebServlet(name="LdapUsers",urlPatterns={"/users"})
|
@WebServlet(name = "LdapUsers", urlPatterns = {"/users"})
|
||||||
public class UsersServlet extends AbstractLDAPServlet {
|
public class UsersServlet extends AbstractLDAPServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -29,7 +29,7 @@ public class UsersServlet extends AbstractLDAPServlet {
|
|||||||
final GroupsDAO groupsDAO = new GroupsDAO(ldapSession);
|
final GroupsDAO groupsDAO = new GroupsDAO(ldapSession);
|
||||||
try {
|
try {
|
||||||
final SortedMap<String, User> users = usersDAO.loadUsers();
|
final SortedMap<String, User> users = usersDAO.loadUsers();
|
||||||
final SortedMap<String,Group> groups = groupsDAO.loadGroups(users);
|
final SortedMap<String, Group> groups = groupsDAO.loadGroups(users);
|
||||||
httpSession.setAttribute("users", users); //$NON-NLS-1$
|
httpSession.setAttribute("users", users); //$NON-NLS-1$
|
||||||
httpSession.setAttribute("groups", groups); //$NON-NLS-1$
|
httpSession.setAttribute("groups", groups); //$NON-NLS-1$
|
||||||
} catch (LDAPSessionException e) {
|
} catch (LDAPSessionException e) {
|
||||||
|
@ -45,11 +45,11 @@ public class TestCreateGroup {
|
|||||||
udao.create(newUser2);
|
udao.create(newUser2);
|
||||||
Group login = new Group();
|
Group login = new Group();
|
||||||
login.setName("login");
|
login.setName("login");
|
||||||
login.setMembers(Arrays.asList(new String[] { newUser1.getDn(), newUser2.getDn() }));
|
login.setMembers(Arrays.asList(new String[]{newUser1.getDn(), newUser2.getDn()}));
|
||||||
gdao.create(login);
|
gdao.create(login);
|
||||||
Group admins = new Group();
|
Group admins = new Group();
|
||||||
admins.setName("admins");
|
admins.setName("admins");
|
||||||
admins.setMembers(Arrays.asList(new String[] { newUser1.getDn(), newUser2.getDn() }));
|
admins.setMembers(Arrays.asList(new String[]{newUser1.getDn(), newUser2.getDn()}));
|
||||||
gdao.create(admins);
|
gdao.create(admins);
|
||||||
} catch (LDAPSessionException | RequiredAttributeException | AlreadyBoundException e) {
|
} catch (LDAPSessionException | RequiredAttributeException | AlreadyBoundException e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user