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 @@ ...@@ -142,6 +142,13 @@
## Added key: 'setup.admin.settings.test.status-error' ## Added key: 'setup.admin.settings.test.status-error'
## Added key: 'setup.admin.settings.test.error-user' ## Added key: 'setup.admin.settings.test.error-user'
## Added key: 'setup.admin.settings.test.error-password' ## 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 # Wildfire
...@@ -1285,6 +1292,7 @@ setup.admin.settings.info=Enter settings for the system administrator account (u ...@@ -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 \ setup.admin.settings.ldap.info=Choose one or more users from your LDAP directory to be administrators by \
entering their usernames. entering their usernames.
setup.admin.settings.error=There were errors when updating the admin account. Please see below. 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=Current Password:
setup.admin.settings.current_password_description=If this is a new installation, the current \ setup.admin.settings.current_password_description=If this is a new installation, the current \
password will be 'admin'. password will be 'admin'.
...@@ -1500,6 +1508,16 @@ setup.ldap.user.vcard.pager=Pager ...@@ -1500,6 +1508,16 @@ setup.ldap.user.vcard.pager=Pager
setup.ldap.user.vcard.business=Business setup.ldap.user.vcard.business=Business
setup.ldap.user.vcard.title=Job Title setup.ldap.user.vcard.title=Job Title
setup.ldap.user.vcard.department=Department 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. \ 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. 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 ...@@ -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.server-logs.descr=Presione para ver los logs del servidor
sidebar.manage-updates=Administrar Actualizaciones sidebar.manage-updates=Administrar Actualizaciones
sidebar.manage-updates.descr=Presione para administrar actualizaciones del servidor o plugins 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=Configuraci\u00f3n de Correo
sidebar.server-email.descr=Presione para configurar el correo sidebar.server-email.descr=Presione para configurar el correo
sidebar.sidebar-server-settings=Configuraci\u00f3n del Servidor 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 ...@@ -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 \ 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. 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.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=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_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. setup.admin.settings.current_password_error=Por favor ingrese la contrase\u00f1a actual correcta.
...@@ -1265,6 +1264,17 @@ setup.ldap.user.vcard.pager=Buscapersonas ...@@ -1265,6 +1264,17 @@ setup.ldap.user.vcard.pager=Buscapersonas
setup.ldap.user.vcard.business=Comercial setup.ldap.user.vcard.business=Comercial
setup.ldap.user.vcard.title=Puesto de trabajo setup.ldap.user.vcard.title=Puesto de trabajo
setup.ldap.user.vcard.department=Departmento 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. \ 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. Si necesita mayor informaci\u00f3n sobre un campo, lleve el rat\u00f3n al icono de ayuda correspondiente.
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<excludes> <excludes>
<pattern>/setup/setup-completed.jsp*</pattern> <pattern>/setup/setup-completed.jsp*</pattern>
<pattern>/setup/setup-ldap-server_test.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>/setup/setup-admin-settings_test.jsp*</pattern>
<pattern>/login.jsp*</pattern> <pattern>/login.jsp*</pattern>
<pattern>/plugin-icon.jsp*</pattern> <pattern>/plugin-icon.jsp*</pattern>
......
...@@ -9,11 +9,13 @@ ...@@ -9,11 +9,13 @@
org.jivesoftware.util.StringUtils, org.jivesoftware.util.StringUtils,
org.jivesoftware.wildfire.XMPPServer, org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.wildfire.auth.AuthFactory, org.jivesoftware.wildfire.auth.AuthFactory,
org.jivesoftware.wildfire.user.User, org.jivesoftware.wildfire.ldap.LdapManager,
org.jivesoftware.wildfire.user.UserManager" %> org.jivesoftware.wildfire.user.User" %>
<%@ page import="javax.servlet.http.HttpSession"%> <%@ page import="org.jivesoftware.wildfire.user.UserManager"%>
<%@ page import="java.util.*"%> <%@ page import="org.xmpp.packet.JID"%>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="java.net.URLEncoder" %> <%@ 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/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" %>
...@@ -34,11 +36,11 @@ ...@@ -34,11 +36,11 @@
<% <%
// Get parameters // Get parameters
String username = ParamUtils.getParameter(request,"username"); String username = ParamUtils.getParameter(request, "username");
String password = ParamUtils.getParameter(request,"password"); String password = ParamUtils.getParameter(request, "password");
String email = ParamUtils.getParameter(request,"email"); String email = ParamUtils.getParameter(request, "email");
String newPassword = ParamUtils.getParameter(request,"newPassword"); String newPassword = ParamUtils.getParameter(request, "newPassword");
String newPasswordConfirm = ParamUtils.getParameter(request,"newPasswordConfirm"); String newPasswordConfirm = ParamUtils.getParameter(request, "newPasswordConfirm");
boolean doContinue = request.getParameter("continue") != null; boolean doContinue = request.getParameter("continue") != null;
boolean doSkip = request.getParameter("doSkip") != null; boolean doSkip = request.getParameter("doSkip") != null;
...@@ -61,24 +63,23 @@ ...@@ -61,24 +63,23 @@
} }
// Error checks // Error checks
Map<String,String> errors = new HashMap<String,String>(); Map<String, String> errors = new HashMap<String, String>();
if (doContinue) { if (doContinue) {
if (password == null) { if (password == null) {
errors.put("password","password"); errors.put("password", "password");
} }
if (email == null) { if (email == null) {
errors.put("email","email"); errors.put("email", "email");
} }
if (newPassword == null) { if (newPassword == null) {
errors.put("newPassword","newPassword"); errors.put("newPassword", "newPassword");
} }
if (newPasswordConfirm == null) { if (newPasswordConfirm == null) {
errors.put("newPasswordConfirm","newPasswordConfirm"); errors.put("newPasswordConfirm", "newPasswordConfirm");
} }
if (newPassword != null && newPasswordConfirm != null if (newPassword != null && newPasswordConfirm != null
&& !newPassword.equals(newPasswordConfirm)) && !newPassword.equals(newPasswordConfirm)) {
{ errors.put("match", "match");
errors.put("match","match");
} }
// if no errors, continue: // if no errors, continue:
if (errors.size() == 0) { if (errors.size() == 0) {
...@@ -100,23 +101,41 @@ ...@@ -100,23 +101,41 @@
} }
catch (Exception e) { catch (Exception e) {
System.err.println("Could not find UserManager"); 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 " + "setting the new admin information. Please check your error "
+ "logs and try to remedy the problem."); + "logs and try to remedy the problem.");
} }
} }
} }
if(ldapFinished){ if (ldapFinished) {
setSetupFinished(session); setSetupFinished(session);
// All good so redirect // All good so redirect
response.sendRedirect("setup-finished.jsp"); response.sendRedirect("setup-finished.jsp");
return; return;
} }
if(addAdmin){ if (addAdmin) {
final String admin = request.getParameter("administrator"); final String admin = request.getParameter("administrator");
if(admin != null){ 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"); String currentList = JiveGlobals.getXMLProperty("admin.authorizedUsernames");
final List users = new ArrayList(StringUtils.stringToCollection(currentList)); final List users = new ArrayList(StringUtils.stringToCollection(currentList));
users.add(admin); users.add(admin);
...@@ -124,7 +143,7 @@ ...@@ -124,7 +143,7 @@
String userList = StringUtils.collectionToString(users); String userList = StringUtils.collectionToString(users);
JiveGlobals.setXMLProperty("admin.authorizedUsernames", userList); JiveGlobals.setXMLProperty("admin.authorizedUsernames", userList);
} }
else { } else {
errors.put("administrator", ""); errors.put("administrator", "");
} }
} }
...@@ -142,8 +161,7 @@ ...@@ -142,8 +161,7 @@
String newUserList = StringUtils.collectionToString(temporaryUserList); String newUserList = StringUtils.collectionToString(temporaryUserList);
if (temporaryUserList.size() == 0) { if (temporaryUserList.size() == 0) {
JiveGlobals.setXMLProperty("admin.authorizedUsernames", ""); JiveGlobals.setXMLProperty("admin.authorizedUsernames", "");
} } else {
else {
JiveGlobals.setXMLProperty("admin.authorizedUsernames", newUserList); JiveGlobals.setXMLProperty("admin.authorizedUsernames", newUserList);
} }
} }
...@@ -151,12 +169,14 @@ ...@@ -151,12 +169,14 @@
// This handles the case of reverting back to default settings from LDAP. Will // This handles the case of reverting back to default settings from LDAP. Will
// add admin to the authorizedUsername list if the authorizedUsername list contains // add admin to the authorizedUsername list if the authorizedUsername list contains
// entries. // entries.
if(!ldap && !doTest){ if (!ldap && !doTest) {
String currentAdminList = JiveGlobals.getXMLProperty("admin.authorizedUsernames"); String currentAdminList = JiveGlobals.getXMLProperty("admin.authorizedUsernames");
List<String> adminCollection = new ArrayList<String>(StringUtils.stringToCollection(currentAdminList)); 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"); adminCollection.add("admin");
JiveGlobals.setXMLProperty("admin.authorizedUsernames", StringUtils.collectionToString(adminCollection)); JiveGlobals.setXMLProperty("admin.authorizedUsernames",
StringUtils.collectionToString(adminCollection));
} }
} }
%> %>
...@@ -179,17 +199,21 @@ ...@@ -179,17 +199,21 @@
<% if (errors.size() > 0) { %> <% if (errors.size() > 0) { %>
<span class="jive-error-text"> <div class="error">
<% if (errors.get("general") != null) { %> <% if (errors.get("general") != null) { %>
<%= errors.get("general") %> <%= errors.get("general") %>
<% } else if (errors.get("administrator") != null) { %>
<fmt:message key="setup.admin.settings.username-error" />
<% } else { %> <% } else { %>
<fmt:message key="setup.admin.settings.error" /> <fmt:message key="setup.admin.settings.error" />
<% } %> <% } %>
</span> </div>
<% } %> <% } %>
...@@ -340,8 +364,27 @@ document.acctform.newPassword.focus(); ...@@ -340,8 +364,27 @@ document.acctform.newPassword.focus();
<% } else { %> <% } else {
<% if (doTest) { 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(); StringBuffer testLink = new StringBuffer();
testLink.append("setup-admin-settings_test.jsp?username="); testLink.append("setup-admin-settings_test.jsp?username=");
testLink.append(URLEncoder.encode(username, "UTF-8")); testLink.append(URLEncoder.encode(username, "UTF-8"));
......
<%@ page import="org.jivesoftware.util.BeanUtils, <%@ page import="org.jivesoftware.admin.LdapUserProfile,
org.jivesoftware.util.BeanUtils,
org.jivesoftware.util.JiveGlobals, org.jivesoftware.util.JiveGlobals,
org.jivesoftware.util.LocaleUtils, org.jivesoftware.util.LocaleUtils" %>
org.jivesoftware.util.ParamUtils" %> <%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="org.jivesoftware.wildfire.XMPPServer"%> <%@ page import="org.jivesoftware.wildfire.XMPPServer" %>
<%@ page import="java.util.HashMap" %> <%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %> <%@ page import="java.util.Map" %>
...@@ -27,9 +28,22 @@ ...@@ -27,9 +28,22 @@
} }
// Determine the right default values based on the the server type. // Determine the right default values based on the the server type.
String defaultUsernameField = JiveGlobals.getXMLProperty("ldap.usernameField"); String defaultUsernameField;
String defaultSearchFields = JiveGlobals.getXMLProperty("ldap.searchFields"); String defaultSearchFields;
String defaultSearchFilter = JiveGlobals.getXMLProperty("ldap.searchFilter"); 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 {
// 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 (serverType.equals("activedirectory")) {
if (!vcardBean.loadFromProperties()) { if (!vcardBean.loadFromProperties()) {
// Initialize vCard mappings // Initialize vCard mappings
...@@ -42,8 +56,7 @@ ...@@ -42,8 +56,7 @@
if (defaultSearchFilter == null) { if (defaultSearchFilter == null) {
defaultSearchFilter = "(objectClass=organizationalPerson)"; defaultSearchFilter = "(objectClass=organizationalPerson)";
} }
} } else {
else {
if (!vcardBean.loadFromProperties()) { if (!vcardBean.loadFromProperties()) {
// Initialize vCard mappings // Initialize vCard mappings
vcardBean.initForOpenLDAP(); vcardBean.initForOpenLDAP();
...@@ -52,6 +65,7 @@ ...@@ -52,6 +65,7 @@
defaultUsernameField = "uid"; defaultUsernameField = "uid";
} }
} }
}
String usernameField = defaultUsernameField; String usernameField = defaultUsernameField;
String searchFields = defaultSearchFields; String searchFields = defaultSearchFields;
...@@ -60,7 +74,9 @@ ...@@ -60,7 +74,9 @@
Map<String, String> errors = new HashMap<String, String>(); Map<String, String> errors = new HashMap<String, String>();
boolean save = request.getParameter("save") != null; 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"); usernameField = ParamUtils.getParameter(request, "usernameField");
if (usernameField == null) { if (usernameField == null) {
errors.put("username", errors.put("username",
...@@ -73,6 +89,15 @@ ...@@ -73,6 +89,15 @@
// Save settings and redirect. // Save settings and redirect.
if (errors.isEmpty()) { if (errors.isEmpty()) {
// 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);
session.setAttribute("ldapVCardBean", vcardBean);
if (save) {
JiveGlobals.setXMLProperty("ldap.usernameField", usernameField); JiveGlobals.setXMLProperty("ldap.usernameField", usernameField);
if (searchFields != null) { if (searchFields != null) {
JiveGlobals.setXMLProperty("ldap.searchFields", searchFields); JiveGlobals.setXMLProperty("ldap.searchFields", searchFields);
...@@ -89,18 +114,12 @@ ...@@ -89,18 +114,12 @@
JiveGlobals.setXMLProperty("provider.auth.className", JiveGlobals.setXMLProperty("provider.auth.className",
"org.jivesoftware.wildfire.ldap.LdapAuthProvider"); "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 // Redirect
response.sendRedirect("setup-ldap-group.jsp?serverType=" + serverType); response.sendRedirect("setup-ldap-group.jsp?serverType=" + serverType);
return; return;
} }
} }
}
%> %>
<html> <html>
<head> <head>
...@@ -111,6 +130,24 @@ ...@@ -111,6 +130,24 @@
<body> <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> <h1><fmt:message key="setup.ldap.profile" />: <span><fmt:message key="setup.ldap.user_mapping" /></h1>
<!-- BEGIN jive-contentBox_stepbar --> <!-- BEGIN jive-contentBox_stepbar -->
...@@ -250,7 +287,7 @@ ...@@ -250,7 +287,7 @@
<strong><fmt:message key="setup.ldap.user.vcard.birthday" /></strong> <strong><fmt:message key="setup.ldap.user.vcard.birthday" /></strong>
</td> </td>
<td class="jive-vcardTable-value jive-vardBorderBottom"> <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> </td>
</tr> </tr>
<tr> <tr>
...@@ -440,10 +477,7 @@ ...@@ -440,10 +477,7 @@
<!-- BEGIN right-aligned buttons --> <!-- BEGIN right-aligned buttons -->
<div align="right"> <div align="right">
<%--<a href="setup-ldap-user_test.jsp" class="lbOn" id="jive-setup-test2"> <input type="Submit" name="test" value="<fmt:message key="setup.ldap.test" />" id="jive-setup-test" border="0">
<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="save" value="<fmt:message key="setup.ldap.continue" />" id="jive-setup-save" border="0"> <input type="Submit" name="save" value="<fmt:message key="setup.ldap.continue" />" id="jive-setup-save" border="0">
</div> </div>
......
<%@ page import="org.jivesoftware.admin.LdapUserProfile" %>
<%@ page import="org.jivesoftware.admin.plugin.LdapUserTester" %>
<%@ page import="org.jivesoftware.util.LocaleUtils" %>
<%@ page import="org.jivesoftware.util.Log" %>
<%@ page import="org.jivesoftware.util.ParamUtils" %>
<%@ page import="org.jivesoftware.wildfire.ldap.LdapManager" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%
String errorDetail = null;
Map<String, String> attributes = null;
Map<String, String> settings = (Map<String, String>) session.getAttribute("ldapSettings");
Map<String, String> userSettings = (Map<String, String>) session.getAttribute("ldapUserSettings");
LdapUserProfile vCardSettings = (LdapUserProfile) session.getAttribute("ldapVCardBean");
int userIndex = ParamUtils.getIntParameter(request, "userIndex", -1);
if (settings != null && userSettings != null && vCardSettings != null) {
LdapManager manager = new LdapManager(settings);
manager.setUsernameField(userSettings.get("ldap.usernameField"));
manager.setSearchFilter(userSettings.get("ldap.searchFilter"));
// Build the tester with the recreated LdapManager and vcard mapping information
LdapUserTester tester = new LdapUserTester(manager, vCardSettings);
List<String> usernames = new ArrayList<String>();
try {
usernames = tester.getSample(40);
}
catch (Exception e) {
// Inform user that an error occurred while trying to get users data
errorDetail = LocaleUtils.getLocalizedString("setup.ldap.user.test.error-loading-users");
Log.error("Error occurred while trying to get users data from LDAP", e);
}
if (usernames.isEmpty()) {
// Inform user that no users were found
errorDetail = LocaleUtils.getLocalizedString("setup.ldap.user.test.users-not-found");
} else {
// Pick a user from the sample list of users
userIndex = userIndex + 1;
if (usernames.size() <= userIndex) {
userIndex = 0;
}
// Get attributes for selected user
attributes = tester.getAttributes(usernames.get(userIndex));
}
}
else {
// Information was not found in the HTTP Session. Internal error?
errorDetail = LocaleUtils.getLocalizedString("setup.ldap.user.test.internal-server-error");
}
%>
<html> <html>
<head> <head>
<meta name="decorator" content="none"/> <meta name="decorator" content="none"/>
</head> </head>
<body> <body>
<script type="text/javascript" language="javascript" src="../js/tooltips/domTT.js"></script>
<script type="text/javascript" language="javascript" src="../js/tooltips/domLib.js"></script>
<style type="text/css"> <style type="text/css">
#lightbox{ #lightbox{
top: 20%; top: 20%;
...@@ -23,141 +79,214 @@ html>body .jive-testPanel { ...@@ -23,141 +79,214 @@ html>body .jive-testPanel {
<div class="jive-testPanel-content"> <div class="jive-testPanel-content">
<div align="right" class="jive-testPanel-close"> <div align="right" class="jive-testPanel-close">
<a href="#" class="lbAction" rel="deactivate">Close</a> <a href="#" class="lbAction" rel="deactivate"><fmt:message key="setup.ldap.server.test.close" /></a>
</div> </div>
<h2>Test: <span>User Mapping</span></h2> <h2><fmt:message key="setup.ldap.server.test.title" />: <span><fmt:message key="setup.ldap.user_mapping" /></span></h2>
<!--<h4 class="jive-testSuccess">Success!</h4>--> <!--<h4 class="jive-testSuccess">Success!</h4>-->
<!-- <h4 class="jive-testError">Error</h4> --> <!-- <h4 class="jive-testError">Error</h4> -->
<p>A random profile is selected for you to review. Errors in the profile values appear in red. To view another profile click 'Next ramdom profile'. When you are finished close this window.</p> <p><fmt:message key="setup.ldap.user.vcard.test.description" /></p>
<div class="jive-testpanel-vcard"> <div class="jive-testpanel-vcard">
<% if (attributes != null) { %>
<table width="331" border="0" cellpadding="0" cellspacing="1" class="jive-testTable-vcard" style="margin-right: 5px;"> <table width="331" border="0" cellpadding="0" cellspacing="1" class="jive-testTable-vcard" style="margin-right: 5px;">
<tr> <tr>
<td colspan="2" class="jive-testpanel-vcard-header">Personal</td> <td colspan="2" class="jive-testpanel-vcard-header"><fmt:message key="setup.ldap.user.vcard.personal" /></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label" width="20%">Full Name:</td> <% String value = attributes.get(LdapUserTester.NAME);
<td class="jive-testpanel-vcard-value">Sgt. Poopypants</td> boolean failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label" width="20%" onmouseover="domTT_activate(this, event, 'content', '', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.name" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Email Address:</td> <% value = attributes.get(LdapUserTester.EMAIL);
<td class="jive-testpanel-vcard-value"><a href="#">poopypants@globalmegacorp.net</a></td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.email" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Nickname:</td> <% value = attributes.get(LdapUserTester.NICKNAME);
<td class="jive-testpanel-vcard-value">poopypants</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.nickname" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Date of Birth:</td> <% value = attributes.get(LdapUserTester.BIRTHDAY);
<td class="jive-testpanel-vcard-value">January 1, 1970</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.birthday" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td colspan="2"></td> <td colspan="2"></td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="jive-testpanel-vcard-header">Home</td> <td colspan="2" class="jive-testpanel-vcard-header"><fmt:message key="setup.ldap.user.vcard.home" /></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Street Address:</td> <% value = attributes.get(LdapUserTester.HOME_STREET);
<td class="jive-testpanel-vcard-value">79549 NW Narup Rd</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.street" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">City:</td> <% value = attributes.get(LdapUserTester.HOME_CITY);
<td class="jive-testpanel-vcard-value">Banks</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.city" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">State/Province:</td> <% value = attributes.get(LdapUserTester.HOME_STATE);
<td class="jive-testpanel-vcard-value">OR</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.state" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Postal Code:</td> <% value = attributes.get(LdapUserTester.HOME_ZIP);
<td class="jive-testpanel-vcard-value">97106</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.pcode" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Country:</td> <% value = attributes.get(LdapUserTester.HOME_COUNTRY);
<td class="jive-testpanel-vcard-value">USA</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.country" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Phone:</td> <% value = attributes.get(LdapUserTester.HOME_PHONE);
<td class="jive-testpanel-vcard-value">503-324-5151</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.phone" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Mobile:</td> <% value = attributes.get(LdapUserTester.HOME_MOBILE);
<td class="jive-testpanel-vcard-value"></td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.mobile" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Fax:</td> <% value = attributes.get(LdapUserTester.HOME_FAX);
<td class="jive-testpanel-vcard-value"><strong>error mapping field</strong></td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.fax" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Pager:</td> <% value = attributes.get(LdapUserTester.HOME_PAGER);
<td class="jive-testpanel-vcard-value"></td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.pager" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
</table> </table>
<table width="331" border="0" cellpadding="0" cellspacing="1" class="jive-testTable-vcard"> <table width="331" border="0" cellpadding="0" cellspacing="1" class="jive-testTable-vcard">
<tr> <tr>
<td colspan="2" class="jive-testpanel-vcard-header">Business</td> <td colspan="2" class="jive-testpanel-vcard-header"><fmt:message key="setup.ldap.user.vcard.business" /></td>
</tr>
<tr>
<td class="jive-testpanel-vcard-label" width="20%">Street Address:</td>
<td class="jive-testpanel-vcard-value">49823 Martinazzi Avenue Suite 523</td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">City:</td> <% value = attributes.get(LdapUserTester.BUSINESS_STREET);
<td class="jive-testpanel-vcard-value">Beverly Hills</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label" width="20%"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.street" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">State/Province:</td> <% value = attributes.get(LdapUserTester.BUSINESS_CITY);
<td class="jive-testpanel-vcard-value">CA</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.city" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Postal Code:</td> <% value = attributes.get(LdapUserTester.BUSINESS_STATE);
<td class="jive-testpanel-vcard-value">90210</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.state" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Country:</td> <% value = attributes.get(LdapUserTester.BUSINESS_ZIP);
<td class="jive-testpanel-vcard-value">USA</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.pcode" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Job Title:</td> <% value = attributes.get(LdapUserTester.BUSINESS_COUNTRY);
<td class="jive-testpanel-vcard-value">Regional Sales Manager Person</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.country" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Department:</td> <% value = attributes.get(LdapUserTester.BUSINESS_JOB_TITLE);
<td class="jive-testpanel-vcard-value">Sales</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.title" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Phone:</td> <% value = attributes.get(LdapUserTester.BUSINESS_DEPARTMENT);
<td class="jive-testpanel-vcard-value">123-456-7890</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.department" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Mobile:</td> <% value = attributes.get(LdapUserTester.BUSINESS_PHONE);
<td class="jive-testpanel-vcard-value">321-654-0987</td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.phone" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Fax:</td> <% value = attributes.get(LdapUserTester.BUSINESS_MOBILE);
<td class="jive-testpanel-vcard-value"></td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.mobile" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Pager:</td> <% value = attributes.get(LdapUserTester.BUSINESS_FAX);
<td class="jive-testpanel-vcard-value"></td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.fax" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td class="jive-testpanel-vcard-label">Web Page:</td> <% value = attributes.get(LdapUserTester.BUSINESS_PAGER);
<td class="jive-testpanel-vcard-value"><a href="#">http://www.globalmegacorp.net</a></td> failed = value != null && value.contains("{");
%>
<td class="jive-testpanel-vcard-label"><%= value != null ? "<strong>" : ""%><fmt:message key="setup.ldap.user.vcard.pager" />:<%= value != null ? "</strong>" : ""%></td>
<td class="jive-testpanel-vcard-value"><%= failed ? "<strong>" : ""%><%= value != null ? value : ""%><%= failed ? "</strong>" : ""%></td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="jive-testpanel-vcard-next"> <td colspan="2" class="jive-testpanel-vcard-next">
<a href="#">Next random profile</a> <a href="setup-ldap-user.jsp?test=true&serverType=<%= ParamUtils.getParameter(request, "serverType")%>&userIndex=<%=userIndex%>"><fmt:message key="setup.ldap.user.vcard.test.random" /></a>
</td> </td>
</tr> </tr>
</table> </table>
<% } else { %>
<h4 class="jive-testError"><fmt:message key="setup.ldap.server.test.status-error" /></h4>
<p><%= errorDetail %></p>
<% } %>
</div> </div>
</div> </div>
......
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