Commit 6ca81937 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

1) Added tesing of user mapping for LDAP. JM-875

2) Improved testing of admins for LDAP.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5776 b35dd754-fafc-0310-a699-88a17e54d16e
parent b08cc173
......@@ -142,6 +142,13 @@
## Added key: 'setup.admin.settings.test.status-error'
## Added key: 'setup.admin.settings.test.error-user'
## Added key: 'setup.admin.settings.test.error-password'
## Added key: 'setup.admin.settings.username-error'
## Added key: 'setup.ldap.user.vcard.personal'
## Added key: 'setup.ldap.user.vcard.test.description'
## Added key: 'setup.ldap.user.vcard.test.random'
## Added key: 'setup.ldap.user.test.error-loading-users'
## Added key: 'setup.ldap.user.test.users-not-found'
## Added key: 'setup.ldap.user.test.internal-server-error'
# Wildfire
......@@ -1285,6 +1292,7 @@ setup.admin.settings.info=Enter settings for the system administrator account (u
setup.admin.settings.ldap.info=Choose one or more users from your LDAP directory to be administrators by \
entering their usernames.
setup.admin.settings.error=There were errors when updating the admin account. Please see below.
setup.admin.settings.username-error=No username was provided or the specified username was not found.
setup.admin.settings.current_password=Current Password:
setup.admin.settings.current_password_description=If this is a new installation, the current \
password will be 'admin'.
......@@ -1500,6 +1508,16 @@ setup.ldap.user.vcard.pager=Pager
setup.ldap.user.vcard.business=Business
setup.ldap.user.vcard.title=Job Title
setup.ldap.user.vcard.department=Department
setup.ldap.user.vcard.personal=Personal
setup.ldap.user.vcard.test.description=A random profile is selected for you to review. Errors in the profile values \
appear in red. Bold fields with no value mean that an error may have been found. To view another profile click \
'Next ramdom profile'. When you are finished close this window.
setup.ldap.user.vcard.test.random=Next random profile
setup.ldap.user.test.error-loading-users=An error occured while loading sample from LDAP. Check error.log for more information.
setup.ldap.user.test.users-not-found=No users were found using the specified configuration. Try changing the base DN,\
user filter or username field.
setup.ldap.user.test.internal-server-error=Test page is not able to find required information in HTTP session.
setup.ldap.group.description=Configure how Wildfire finds and loads groups from your LDAP directory. \
If you need additional information about a field, hover your mouse over the corresponsing help icon.
......
......@@ -30,8 +30,6 @@ tab.server.descr=Presione para administrar la configuraci\u00f3n del servidor
sidebar.server-logs.descr=Presione para ver los logs del servidor
sidebar.manage-updates=Administrar Actualizaciones
sidebar.manage-updates.descr=Presione para administrar actualizaciones del servidor o plugins
sidebar.plugin-settings=Plugins
sidebar.plugin-settings.descr=Presione para ver los plugins
sidebar.server-email=Configuraci\u00f3n de Correo
sidebar.server-email.descr=Presione para configurar el correo
sidebar.sidebar-server-settings=Configuraci\u00f3n del Servidor
......@@ -1067,6 +1065,7 @@ setup.admin.settings.info=Ingrese la configuraci\u00f3n para la cuenta del admin
setup.admin.settings.ldap.info=Seleccione uno o más usuarios de su directorio LDAP para ser administradores \
de Wildfire ingresando sus nombres de usuarios.
setup.admin.settings.error=Se encontraron errores al actualizar la cuenta del administrador. Vea m\u00e1s abajo.
setup.admin.settings.username-error=No se ha especificado un nombre de usuario o no se ha encontrado un usuario con ese nombre.
setup.admin.settings.current_password=Contrase\u00f1a Actual:
setup.admin.settings.current_password_description=Si esta es una nueva instalaci\u00f3n la contrase\u00f1a actual ser\u00e1 'admin'
setup.admin.settings.current_password_error=Por favor ingrese la contrase\u00f1a actual correcta.
......@@ -1265,6 +1264,17 @@ setup.ldap.user.vcard.pager=Buscapersonas
setup.ldap.user.vcard.business=Comercial
setup.ldap.user.vcard.title=Puesto de trabajo
setup.ldap.user.vcard.department=Departmento
setup.ldap.user.vcard.personal=Personal
setup.ldap.user.vcard.test.description=Un perfil aleatorio fue seleccionado para ser revisado. Errores en los valores del perfil \
aparecen en rojo. Campos en negrita sin valor pueden indicar que un error ha sido encontrado. Para visualizar otro perfil haga clic \
en 'Siguiente perfil aleatorio'. Cuando finalice cierre esta ventana.
setup.ldap.user.vcard.test.random=Siguiente perfil aleatorio
setup.ldap.user.test.error-loading-users=Un error ha occurido mientras se cargaba una muestra desde LDAP. Verifique el error.log \
para m\u00e1s informaci\u00f3n.
setup.ldap.user.test.users-not-found=No se han encontrado usuarios utilizando la configuraci\u00f3n especificada. Intente cambiar el DN base,\
filtro de usuarios o campo con el nombre del usuario.
setup.ldap.user.test.internal-server-error=P\u00e1gina de pruebas no ha podido encontrar la informaci\u00f3n requerida en la sesi\u00f3n HTTP.
setup.ldap.group.description=Configurar la manera que Wildfire busca y carga grupos de su servidor LDAP. \
Si necesita mayor informaci\u00f3n sobre un campo, lleve el rat\u00f3n al icono de ayuda correspondiente.
......
......@@ -10,6 +10,7 @@
<excludes>
<pattern>/setup/setup-completed.jsp*</pattern>
<pattern>/setup/setup-ldap-server_test.jsp*</pattern>
<pattern>/setup/setup-ldap-user_test.jsp*</pattern>
<pattern>/setup/setup-admin-settings_test.jsp*</pattern>
<pattern>/login.jsp*</pattern>
<pattern>/plugin-icon.jsp*</pattern>
......
......@@ -9,11 +9,13 @@
org.jivesoftware.util.StringUtils,
org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.wildfire.auth.AuthFactory,
org.jivesoftware.wildfire.user.User,
org.jivesoftware.wildfire.user.UserManager" %>
<%@ page import="javax.servlet.http.HttpSession"%>
<%@ page import="java.util.*"%>
org.jivesoftware.wildfire.ldap.LdapManager,
org.jivesoftware.wildfire.user.User" %>
<%@ page import="org.jivesoftware.wildfire.user.UserManager"%>
<%@ page import="org.xmpp.packet.JID"%>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="java.net.URLEncoder" %>
<%@ 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" %>
......@@ -34,11 +36,11 @@
<%
// Get parameters
String username = ParamUtils.getParameter(request,"username");
String password = ParamUtils.getParameter(request,"password");
String email = ParamUtils.getParameter(request,"email");
String newPassword = ParamUtils.getParameter(request,"newPassword");
String newPasswordConfirm = ParamUtils.getParameter(request,"newPasswordConfirm");
String username = ParamUtils.getParameter(request, "username");
String password = ParamUtils.getParameter(request, "password");
String email = ParamUtils.getParameter(request, "email");
String newPassword = ParamUtils.getParameter(request, "newPassword");
String newPasswordConfirm = ParamUtils.getParameter(request, "newPasswordConfirm");
boolean doContinue = request.getParameter("continue") != null;
boolean doSkip = request.getParameter("doSkip") != null;
......@@ -61,24 +63,23 @@
}
// Error checks
Map<String,String> errors = new HashMap<String,String>();
Map<String, String> errors = new HashMap<String, String>();
if (doContinue) {
if (password == null) {
errors.put("password","password");
errors.put("password", "password");
}
if (email == null) {
errors.put("email","email");
errors.put("email", "email");
}
if (newPassword == null) {
errors.put("newPassword","newPassword");
errors.put("newPassword", "newPassword");
}
if (newPasswordConfirm == null) {
errors.put("newPasswordConfirm","newPasswordConfirm");
errors.put("newPasswordConfirm", "newPasswordConfirm");
}
if (newPassword != null && newPasswordConfirm != null
&& !newPassword.equals(newPasswordConfirm))
{
errors.put("match","match");
&& !newPassword.equals(newPasswordConfirm)) {
errors.put("match", "match");
}
// if no errors, continue:
if (errors.size() == 0) {
......@@ -100,31 +101,49 @@
}
catch (Exception e) {
System.err.println("Could not find UserManager");
errors.put("general","There was an unexpected error encountered when "
errors.put("general", "There was an unexpected error encountered when "
+ "setting the new admin information. Please check your error "
+ "logs and try to remedy the problem.");
}
}
}
if(ldapFinished){
if (ldapFinished) {
setSetupFinished(session);
// All good so redirect
response.sendRedirect("setup-finished.jsp");
return;
}
if(addAdmin){
if (addAdmin) {
final String admin = request.getParameter("administrator");
if(admin != null){
String currentList = JiveGlobals.getXMLProperty("admin.authorizedUsernames");
final List users = new ArrayList(StringUtils.stringToCollection(currentList));
users.add(admin);
if (admin != null) {
if (ldap) {
// Try to verify that the username exists in LDAP
Map<String, String> settings = (Map<String, String>) session.getAttribute("ldapSettings");
Map<String, String> userSettings = (Map<String, String>) session.getAttribute("ldapUserSettings");
if (settings != null) {
LdapManager manager = new LdapManager(settings);
manager.setUsernameField(userSettings.get("ldap.usernameField"));
manager.setSearchFilter(userSettings.get("ldap.searchFilter"));
try {
manager.findUserDN(JID.unescapeNode(admin));
}
catch (Exception e) {
e.printStackTrace();
errors.put("administrator", "");
}
}
}
if (errors.isEmpty()) {
String currentList = JiveGlobals.getXMLProperty("admin.authorizedUsernames");
final List users = new ArrayList(StringUtils.stringToCollection(currentList));
users.add(admin);
String userList = StringUtils.collectionToString(users);
JiveGlobals.setXMLProperty("admin.authorizedUsernames", userList);
}
else {
String userList = StringUtils.collectionToString(users);
JiveGlobals.setXMLProperty("admin.authorizedUsernames", userList);
}
} else {
errors.put("administrator", "");
}
}
......@@ -142,8 +161,7 @@
String newUserList = StringUtils.collectionToString(temporaryUserList);
if (temporaryUserList.size() == 0) {
JiveGlobals.setXMLProperty("admin.authorizedUsernames", "");
}
else {
} else {
JiveGlobals.setXMLProperty("admin.authorizedUsernames", newUserList);
}
}
......@@ -151,12 +169,14 @@
// This handles the case of reverting back to default settings from LDAP. Will
// add admin to the authorizedUsername list if the authorizedUsername list contains
// entries.
if(!ldap && !doTest){
if (!ldap && !doTest) {
String currentAdminList = JiveGlobals.getXMLProperty("admin.authorizedUsernames");
List<String> adminCollection = new ArrayList<String>(StringUtils.stringToCollection(currentAdminList));
if((!adminCollection.isEmpty() && !adminCollection.contains("admin")) || JiveGlobals.getXMLProperty("admin.authorizedJIDs") != null){
if ((!adminCollection.isEmpty() && !adminCollection.contains("admin")) ||
JiveGlobals.getXMLProperty("admin.authorizedJIDs") != null) {
adminCollection.add("admin");
JiveGlobals.setXMLProperty("admin.authorizedUsernames", StringUtils.collectionToString(adminCollection));
JiveGlobals.setXMLProperty("admin.authorizedUsernames",
StringUtils.collectionToString(adminCollection));
}
}
%>
......@@ -179,17 +199,21 @@
<% if (errors.size() > 0) { %>
<span class="jive-error-text">
<div class="error">
<% if (errors.get("general") != null) { %>
<%= errors.get("general") %>
<% } else if (errors.get("administrator") != null) { %>
<fmt:message key="setup.admin.settings.username-error" />
<% } else { %>
<fmt:message key="setup.admin.settings.error" />
<% } %>
</span>
</div>
<% } %>
......@@ -340,14 +364,33 @@ document.acctform.newPassword.focus();
<% } else { %>
<% if (doTest) {
StringBuffer testLink = new StringBuffer();
testLink.append("setup-admin-settings_test.jsp?username=");
testLink.append(URLEncoder.encode(username, "UTF-8"));
if (password != null) {
testLink.append("&password=").append(URLEncoder.encode(password, "UTF-8"));
}
<% } else {
if (errors.size() > 0) { %>
<div class="error">
<% if (errors.get("general") != null) { %>
<%= errors.get("general") %>
<% } else if (errors.get("administrator") != null) { %>
<fmt:message key="setup.admin.settings.username-error" />
<% } else { %>
<fmt:message key="setup.admin.settings.error" />
<% } %>
</div>
<% }
if (doTest) {
StringBuffer testLink = new StringBuffer();
testLink.append("setup-admin-settings_test.jsp?username=");
testLink.append(URLEncoder.encode(username, "UTF-8"));
if (password != null) {
testLink.append("&password=").append(URLEncoder.encode(password, "UTF-8"));
}
%>
<a href="<%= testLink %>" id="lbmessage" title="<fmt:message key="global.test" />" style="display:none;"></a>
......
<%@ page import="org.jivesoftware.util.BeanUtils,
<%@ page import="org.jivesoftware.admin.LdapUserProfile,
org.jivesoftware.util.BeanUtils,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.util.LocaleUtils,
org.jivesoftware.util.ParamUtils" %>
<%@ page import="org.jivesoftware.wildfire.XMPPServer"%>
org.jivesoftware.util.LocaleUtils" %>
<%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="org.jivesoftware.wildfire.XMPPServer" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
......@@ -27,29 +28,42 @@
}
// Determine the right default values based on the the server type.
String defaultUsernameField = JiveGlobals.getXMLProperty("ldap.usernameField");
String defaultSearchFields = JiveGlobals.getXMLProperty("ldap.searchFields");
String defaultSearchFilter = JiveGlobals.getXMLProperty("ldap.searchFilter");
if (serverType.equals("activedirectory")) {
if (!vcardBean.loadFromProperties()) {
// Initialize vCard mappings
vcardBean.initForActiveDirectory();
}
if (defaultUsernameField == null) {
defaultUsernameField = "sAMAccountName";
// Initialize vCard mappings
}
if (defaultSearchFilter == null) {
defaultSearchFilter = "(objectClass=organizationalPerson)";
}
String defaultUsernameField;
String defaultSearchFields;
String defaultSearchFilter;
// First check if the http session holds data from a previous post of this page
if (session.getAttribute("ldapUserSettings") != null && session.getAttribute("ldapVCardBean") != null) {
Map<String, String> userSettings = (Map<String, String>) session.getAttribute("ldapUserSettings");
defaultUsernameField = userSettings.get("ldap.usernameField");
defaultSearchFields = userSettings.get("ldap.searchFields");
defaultSearchFilter = userSettings.get("ldap.searchFilter");
vcardBean = (LdapUserProfile) session.getAttribute("ldapVCardBean");
}
else {
if (!vcardBean.loadFromProperties()) {
// Initialize vCard mappings
vcardBean.initForOpenLDAP();
}
if (defaultUsernameField == null) {
defaultUsernameField = "uid";
// No info in the session so try stored XML values or default ones
defaultUsernameField = JiveGlobals.getXMLProperty("ldap.usernameField");
defaultSearchFields = JiveGlobals.getXMLProperty("ldap.searchFields");
defaultSearchFilter = JiveGlobals.getXMLProperty("ldap.searchFilter");
if (serverType.equals("activedirectory")) {
if (!vcardBean.loadFromProperties()) {
// Initialize vCard mappings
vcardBean.initForActiveDirectory();
}
if (defaultUsernameField == null) {
defaultUsernameField = "sAMAccountName";
// Initialize vCard mappings
}
if (defaultSearchFilter == null) {
defaultSearchFilter = "(objectClass=organizationalPerson)";
}
} else {
if (!vcardBean.loadFromProperties()) {
// Initialize vCard mappings
vcardBean.initForOpenLDAP();
}
if (defaultUsernameField == null) {
defaultUsernameField = "uid";
}
}
}
......@@ -60,7 +74,9 @@
Map<String, String> errors = new HashMap<String, String>();
boolean save = request.getParameter("save") != null;
if (save) {
boolean doTest = request.getParameter("test") != null;
boolean isTesting = request.getParameter("userIndex") != null;
if ((save || doTest) && !isTesting) {
usernameField = ParamUtils.getParameter(request, "usernameField");
if (usernameField == null) {
errors.put("username",
......@@ -73,32 +89,35 @@
// Save settings and redirect.
if (errors.isEmpty()) {
JiveGlobals.setXMLProperty("ldap.usernameField", usernameField);
if (searchFields != null) {
JiveGlobals.setXMLProperty("ldap.searchFields", searchFields);
}
if (searchFilter != null) {
JiveGlobals.setXMLProperty("ldap.searchFilter", searchFilter);
}
// Save vCard mappings
vcardBean.saveProperties();
// Enable the LDAP auth and user providers. The group provider will be enabled on the next step.
JiveGlobals.setXMLProperty("provider.user.className",
"org.jivesoftware.wildfire.ldap.LdapUserProvider");
JiveGlobals.setXMLProperty("provider.auth.className",
"org.jivesoftware.wildfire.ldap.LdapAuthProvider");
// Save information in the session so we can use it in testing pages during setup
Map<String, String> settings = new HashMap<String, String>();
settings.put("ldap.usernameField", usernameField);
settings.put("ldap.searchFields", searchFields);
settings.put("ldap.searchFilter", searchFilter);
session.setAttribute("ldapUserSettings", settings);
// Redirect
response.sendRedirect("setup-ldap-group.jsp?serverType=" + serverType);
return;
session.setAttribute("ldapVCardBean", vcardBean);
if (save) {
JiveGlobals.setXMLProperty("ldap.usernameField", usernameField);
if (searchFields != null) {
JiveGlobals.setXMLProperty("ldap.searchFields", searchFields);
}
if (searchFilter != null) {
JiveGlobals.setXMLProperty("ldap.searchFilter", searchFilter);
}
// Save vCard mappings
vcardBean.saveProperties();
// Enable the LDAP auth and user providers. The group provider will be enabled on the next step.
JiveGlobals.setXMLProperty("provider.user.className",
"org.jivesoftware.wildfire.ldap.LdapUserProvider");
JiveGlobals.setXMLProperty("provider.auth.className",
"org.jivesoftware.wildfire.ldap.LdapAuthProvider");
// Redirect
response.sendRedirect("setup-ldap-group.jsp?serverType=" + serverType);
return;
}
}
}
%>
......@@ -111,6 +130,24 @@
<body>
<% if (doTest && errors.isEmpty()) {
StringBuilder sb = new StringBuilder();
sb.append("serverType=").append(serverType);
if (isTesting) {
sb.append("&userIndex=").append(request.getParameter("userIndex"));
}
%>
<a href="setup-ldap-user_test.jsp?<%= sb.toString()%>" id="lbmessage" title="<fmt:message key="global.test" />" style="display:none;"></a>
<script type="text/javascript">
function loadMsg() {
var lb = new lightbox(document.getElementById('lbmessage'));
lb.activate();
}
setTimeout('loadMsg()', 250);
</script>
<% } %>
<h1><fmt:message key="setup.ldap.profile" />: <span><fmt:message key="setup.ldap.user_mapping" /></h1>
<!-- BEGIN jive-contentBox_stepbar -->
......@@ -250,7 +287,7 @@
<strong><fmt:message key="setup.ldap.user.vcard.birthday" /></strong>
</td>
<td class="jive-vcardTable-value jive-vardBorderBottom">
<input type="text" name="dob" value="<%= vcardBean.getBirthday() %>" id="birthday" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
<input type="text" name="birthday" value="<%= vcardBean.getBirthday() %>" id="birthday" size="22" maxlength="50" onFocus="jiveRowHighlight(this);">
</td>
</tr>
<tr>
......@@ -440,10 +477,7 @@
<!-- BEGIN right-aligned buttons -->
<div align="right">
<%--<a href="setup-ldap-user_test.jsp" class="lbOn" id="jive-setup-test2">
<img src="../images/setup_btn_gearplay.gif" alt="" width="14" height="14" border="0">
<fmt:message key="setup.ldap.test" />
</a>--%>
<input type="Submit" name="test" value="<fmt:message key="setup.ldap.test" />" id="jive-setup-test" border="0">
<input type="Submit" name="save" value="<fmt:message key="setup.ldap.continue" />" id="jive-setup-save" border="0">
</div>
......
This diff is collapsed.
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