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 @@
org.jivesoftware.util.ParamUtils" %>
<%@ page import="java.util.HashMap" %>
<%@ 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/fmt_rt" prefix="fmt" %>
......@@ -15,6 +16,8 @@
serverType = "other";
}
LdapManager manager = LdapManager.getInstance();
// Determine the right default values based on the the server type.
String defaultGroupNameField = JiveGlobals.getXMLProperty("ldap.groupNameField");
String defaultGroupMemberField = JiveGlobals.getXMLProperty("ldap.groupMemberField");
......@@ -92,17 +95,17 @@
if (save) {
if (groupNameField != null) {
JiveGlobals.setXMLProperty("ldap.groupNameField", groupNameField);
manager.setGroupNameField(groupNameField);
}
if (groupMemberField != null) {
JiveGlobals.setXMLProperty("ldap.groupMemberField", groupMemberField);
manager.setGroupMemberField(groupMemberField);
}
if (groupDescriptionField != null) {
JiveGlobals.setXMLProperty("ldap.groupDescriptionField", groupDescriptionField);
manager.setGroupDescriptionField(groupDescriptionField);
}
JiveGlobals.setXMLProperty("ldap.posixMode", Boolean.toString(posixMode));
manager.setPosixMode(posixMode);
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.
......
<%@ page import="org.jivesoftware.util.JiveGlobals"%>
<%@ 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/fmt_rt" prefix="fmt" %>
......@@ -19,6 +20,7 @@
boolean save = request.getParameter("save") != null;
boolean test = request.getParameter("test") != null;
LdapManager manager = LdapManager.getInstance();
Map<String, String> errors = new HashMap<String, String>();
if (save || test) {
......@@ -62,36 +64,44 @@
if (save) {
// Save settings and redirect
JiveGlobals.setXMLProperty("ldap.host", host);
JiveGlobals.setXMLProperty("ldap.port", Integer.toString(port));
JiveGlobals.setXMLProperty("ldap.baseDN", baseDN);
JiveGlobals.setXMLProperty("ldap.adminDN", adminDN);
JiveGlobals.setXMLProperty("ldap.adminPassword", adminPassword);
JiveGlobals.setXMLProperty("ldap.connectionPoolEnabled",
Boolean.toString(connectionPoolEnabled));
JiveGlobals.setXMLProperty("ldap.sslEnabled", Boolean.toString(sslEnabled));
JiveGlobals.setXMLProperty("ldap.debugEnabled", Boolean.toString(debugEnabled));
JiveGlobals.setXMLProperty("ldap.autoFollowReferrals",
Boolean.toString(referralsEnabled));
Collection<String> hosts = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(host, " ,\t\n\r\f");
while (st.hasMoreTokens()) {
hosts.add(st.nextToken());
}
manager.setHosts(hosts);
manager.setPort(port);
manager.setBaseDN(baseDN);
manager.setAdminDN(adminDN);
manager.setAdminPassword(adminPassword);
manager.setConnectionPoolEnabled(connectionPoolEnabled);
manager.setSslEnabled(sslEnabled);
manager.setDebugEnabled(debugEnabled);
manager.setFollowReferralsEnabled(referralsEnabled);
// Redirect to next step.
response.sendRedirect(nextPage);
return;
}
}
}
else {
} else {
// See if there are already values for the variables defined.
host = JiveGlobals.getXMLProperty("ldap.host");
port = JiveGlobals.getXMLProperty("ldap.port", port);
baseDN = JiveGlobals.getXMLProperty("ldap.baseDN");
adminDN = JiveGlobals.getXMLProperty("ldap.adminDN");
adminPassword = JiveGlobals.getXMLProperty("ldap.adminPassword");
connectionPoolEnabled =
JiveGlobals.getXMLProperty("ldap.connectionPoolEnabled", connectionPoolEnabled);
sslEnabled = JiveGlobals.getXMLProperty("ldap.sslEnabled", sslEnabled);
debugEnabled = JiveGlobals.getXMLProperty("ldap.debugEnabled", debugEnabled);
referralsEnabled = JiveGlobals.getXMLProperty("ldap.autoFollowReferrals", referralsEnabled);
StringBuilder sb = new StringBuilder();
for (String aHost : LdapManager.getInstance().getHosts()) {
sb.append(aHost).append(", ");
}
host = sb.toString();
if (host.trim().length() > 0) {
host = host.substring(0, host.length() - 2);
}
port = manager.getPort();
baseDN = manager.getBaseDN();
adminDN = manager.getAdminDN();
adminPassword = manager.getAdminPassword();
connectionPoolEnabled = manager.isConnectionPoolEnabled();
sslEnabled = manager.isSslEnabled();
debugEnabled = manager.isDebugEnabled();
referralsEnabled = manager.isFollowReferralsEnabled();
}
%>
<html>
......
......@@ -5,6 +5,9 @@
<%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="java.util.HashMap" %>
<%@ 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/fmt_rt" prefix="fmt" %>
......@@ -18,6 +21,8 @@
serverType = "other";
}
LdapManager manager = LdapManager.getInstance();
// Determine the right default values based on the the server type.
String defaultUsernameField;
String defaultSearchFields;
......@@ -89,12 +94,19 @@
session.setAttribute("ldapVCardBean", vcardBean);
if (save) {
JiveGlobals.setXMLProperty("ldap.usernameField", usernameField);
manager.setUsernameField(usernameField);
if (searchFields != null) {
JiveGlobals.setXMLProperty("ldap.searchFields", searchFields);
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);
}
}
if (searchFilter != null) {
JiveGlobals.setXMLProperty("ldap.searchFilter", searchFilter);
manager.setSearchFilter(searchFilter);
}
// Save vCard mappings
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