Commit cf215195 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Existing LDAP objects are now dynamically updated with new settings. JM-880

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5839 b35dd754-fafc-0310-a699-88a17e54d16e
parent 60f1847a
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
org.jivesoftware.util.ParamUtils" %> org.jivesoftware.util.ParamUtils" %>
<%@ page import="java.util.HashMap" %> <%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %> <%@ page import="java.util.Map" %>
<%@ page import="org.jivesoftware.wildfire.ldap.LdapManager" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
...@@ -15,6 +16,8 @@ ...@@ -15,6 +16,8 @@
serverType = "other"; serverType = "other";
} }
LdapManager manager = LdapManager.getInstance();
// Determine the right default values based on the the server type. // Determine the right default values based on the the server type.
String defaultGroupNameField = JiveGlobals.getXMLProperty("ldap.groupNameField"); String defaultGroupNameField = JiveGlobals.getXMLProperty("ldap.groupNameField");
String defaultGroupMemberField = JiveGlobals.getXMLProperty("ldap.groupMemberField"); String defaultGroupMemberField = JiveGlobals.getXMLProperty("ldap.groupMemberField");
...@@ -92,17 +95,17 @@ ...@@ -92,17 +95,17 @@
if (save) { if (save) {
if (groupNameField != null) { if (groupNameField != null) {
JiveGlobals.setXMLProperty("ldap.groupNameField", groupNameField); manager.setGroupNameField(groupNameField);
} }
if (groupMemberField != null) { if (groupMemberField != null) {
JiveGlobals.setXMLProperty("ldap.groupMemberField", groupMemberField); manager.setGroupMemberField(groupMemberField);
} }
if (groupDescriptionField != null) { if (groupDescriptionField != null) {
JiveGlobals.setXMLProperty("ldap.groupDescriptionField", groupDescriptionField); manager.setGroupDescriptionField(groupDescriptionField);
} }
JiveGlobals.setXMLProperty("ldap.posixMode", Boolean.toString(posixMode)); manager.setPosixMode(posixMode);
if (groupSearchFilter != null) { if (groupSearchFilter != null) {
JiveGlobals.setXMLProperty("ldap.groupSearchFilter", groupSearchFilter); manager.setGroupSearchFilter(groupSearchFilter);
} }
// Enable the LDAP auth provider. The LDAP user provider will be enabled on the next step. // Enable the LDAP auth provider. The LDAP user provider will be enabled on the next step.
......
<%@ page import="org.jivesoftware.util.JiveGlobals"%>
<%@ page import="org.jivesoftware.util.LocaleUtils"%> <%@ page import="org.jivesoftware.util.LocaleUtils"%>
<%@ page import="org.jivesoftware.util.ParamUtils, java.util.HashMap, java.util.Map"%> <%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="org.jivesoftware.wildfire.ldap.LdapManager"%>
<%@ page import="java.util.*" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
boolean save = request.getParameter("save") != null; boolean save = request.getParameter("save") != null;
boolean test = request.getParameter("test") != null; boolean test = request.getParameter("test") != null;
LdapManager manager = LdapManager.getInstance();
Map<String, String> errors = new HashMap<String, String>(); Map<String, String> errors = new HashMap<String, String>();
if (save || test) { if (save || test) {
...@@ -62,36 +64,44 @@ ...@@ -62,36 +64,44 @@
if (save) { if (save) {
// Save settings and redirect // Save settings and redirect
JiveGlobals.setXMLProperty("ldap.host", host); Collection<String> hosts = new ArrayList<String>();
JiveGlobals.setXMLProperty("ldap.port", Integer.toString(port)); StringTokenizer st = new StringTokenizer(host, " ,\t\n\r\f");
JiveGlobals.setXMLProperty("ldap.baseDN", baseDN); while (st.hasMoreTokens()) {
JiveGlobals.setXMLProperty("ldap.adminDN", adminDN); hosts.add(st.nextToken());
JiveGlobals.setXMLProperty("ldap.adminPassword", adminPassword); }
JiveGlobals.setXMLProperty("ldap.connectionPoolEnabled", manager.setHosts(hosts);
Boolean.toString(connectionPoolEnabled)); manager.setPort(port);
JiveGlobals.setXMLProperty("ldap.sslEnabled", Boolean.toString(sslEnabled)); manager.setBaseDN(baseDN);
JiveGlobals.setXMLProperty("ldap.debugEnabled", Boolean.toString(debugEnabled)); manager.setAdminDN(adminDN);
JiveGlobals.setXMLProperty("ldap.autoFollowReferrals", manager.setAdminPassword(adminPassword);
Boolean.toString(referralsEnabled)); manager.setConnectionPoolEnabled(connectionPoolEnabled);
manager.setSslEnabled(sslEnabled);
manager.setDebugEnabled(debugEnabled);
manager.setFollowReferralsEnabled(referralsEnabled);
// Redirect to next step. // Redirect to next step.
response.sendRedirect(nextPage); response.sendRedirect(nextPage);
return; return;
} }
} }
} } else {
else {
// See if there are already values for the variables defined. // See if there are already values for the variables defined.
host = JiveGlobals.getXMLProperty("ldap.host"); StringBuilder sb = new StringBuilder();
port = JiveGlobals.getXMLProperty("ldap.port", port); for (String aHost : LdapManager.getInstance().getHosts()) {
baseDN = JiveGlobals.getXMLProperty("ldap.baseDN"); sb.append(aHost).append(", ");
adminDN = JiveGlobals.getXMLProperty("ldap.adminDN"); }
adminPassword = JiveGlobals.getXMLProperty("ldap.adminPassword"); host = sb.toString();
connectionPoolEnabled = if (host.trim().length() > 0) {
JiveGlobals.getXMLProperty("ldap.connectionPoolEnabled", connectionPoolEnabled); host = host.substring(0, host.length() - 2);
sslEnabled = JiveGlobals.getXMLProperty("ldap.sslEnabled", sslEnabled); }
debugEnabled = JiveGlobals.getXMLProperty("ldap.debugEnabled", debugEnabled); port = manager.getPort();
referralsEnabled = JiveGlobals.getXMLProperty("ldap.autoFollowReferrals", referralsEnabled); baseDN = manager.getBaseDN();
adminDN = manager.getAdminDN();
adminPassword = manager.getAdminPassword();
connectionPoolEnabled = manager.isConnectionPoolEnabled();
sslEnabled = manager.isSslEnabled();
debugEnabled = manager.isDebugEnabled();
referralsEnabled = manager.isFollowReferralsEnabled();
} }
%> %>
<html> <html>
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
<%@ page import="org.jivesoftware.util.ParamUtils"%> <%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="java.util.HashMap" %> <%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %> <%@ page import="java.util.Map" %>
<%@ page import="org.jivesoftware.wildfire.ldap.LdapManager" %>
<%@ page import="org.jivesoftware.wildfire.user.UserManager" %>
<%@ page import="org.jivesoftware.wildfire.ldap.LdapUserProvider" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
...@@ -18,6 +21,8 @@ ...@@ -18,6 +21,8 @@
serverType = "other"; serverType = "other";
} }
LdapManager manager = LdapManager.getInstance();
// Determine the right default values based on the the server type. // Determine the right default values based on the the server type.
String defaultUsernameField; String defaultUsernameField;
String defaultSearchFields; String defaultSearchFields;
...@@ -89,12 +94,19 @@ ...@@ -89,12 +94,19 @@
session.setAttribute("ldapVCardBean", vcardBean); session.setAttribute("ldapVCardBean", vcardBean);
if (save) { if (save) {
JiveGlobals.setXMLProperty("ldap.usernameField", usernameField); manager.setUsernameField(usernameField);
if (searchFields != null) { if (searchFields != null) {
if ("org.jivesoftware.wildfire.ldap.LdapUserProvider"
.equals(JiveGlobals.getXMLProperty("provider.user.className"))) {
// Update current instance being used
((LdapUserProvider) UserManager.getUserProvider()).setSearchFields(searchFields);
} else {
// Just update the property. It will be later used by LdapUserProvider
JiveGlobals.setXMLProperty("ldap.searchFields", searchFields); JiveGlobals.setXMLProperty("ldap.searchFields", searchFields);
} }
}
if (searchFilter != null) { if (searchFilter != null) {
JiveGlobals.setXMLProperty("ldap.searchFilter", searchFilter); manager.setSearchFilter(searchFilter);
} }
// Save vCard mappings // Save vCard mappings
vcardBean.saveProperties(); vcardBean.saveProperties();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment