Commit 40bb3dba authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Initial version. JM-870

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5731 b35dd754-fafc-0310-a699-88a17e54d16e
parent 6c66a7f1
<%@ page import="org.jivesoftware.util.LocaleUtils" %>
<%@ page import="org.jivesoftware.util.ParamUtils, org.jivesoftware.wildfire.ldap.LdapManager, org.jivesoftware.wildfire.user.UserNotFoundException, org.xmpp.packet.JID" %>
<%@ page import="java.net.URLEncoder" %>
<%@ 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 username = ParamUtils.getParameter(request, "username");
String password = ParamUtils.getParameter(request, "password");
boolean success = false;
String errorDetail = "";
Map<String, String> settings = (Map<String, String>) session.getAttribute("ldapSettings");
Map<String, String> userSettings =
(Map<String, String>) session.getAttribute("ldapUserSettings");
// Run the test if password was provided and we have the ldap information
if (settings != null && password != null) {
LdapManager manager = new LdapManager(settings);
manager.setUsernameField(userSettings.get("ldap.usernameField"));
manager.setSearchFilter(userSettings.get("ldap.searchFilter"));
try {
String userDN = manager.findUserDN(JID.unescapeNode(username));
// See if the user authenticates.
if (manager.checkAuthentication(userDN, password)) {
// User was able to authenticate with provided password
success = true;
}
else {
errorDetail = LocaleUtils.getLocalizedString("setup.admin.settings.test.error-password");
}
}
catch (UserNotFoundException e) {
errorDetail = LocaleUtils.getLocalizedString("setup.admin.settings.test.error-user");
}
catch (Exception e) {
errorDetail = e.getMessage();
e.printStackTrace();
}
}
%>
<!-- BEGIN connection settings test panel -->
<div class="jive-testPanel">
<div class="jive-testPanel-content">
<div align="right" class="jive-testPanel-close">
<a href="#" class="lbAction" rel="deactivate"><fmt:message key="setup.ldap.server.test.close" /></a>
</div>
<h2><fmt:message key="global.test" />: <span><fmt:message key="setup.admin.settings.test.title-desc" /></span></h2>
<% if (password != null) { %>
<% if (success) { %>
<h4 class="jive-testSuccess"><fmt:message key="setup.admin.settings.test.status-success" /></h4>
<p><fmt:message key="setup.admin.settings.test.status-success.detail" /></p>
<% } else { %>
<h4 class="jive-testError"><fmt:message key="setup.admin.settings.test.status-error" /></h4>
<p><%= errorDetail %></p>
<% }
}
if (!success) {
%>
<form action="setup-admin-settings.jsp" name="testform" method="post">
<input type="hidden" name="ldap" value="true">
<input type="hidden" name="test" value="true">
<input type="hidden" name="username" value="<%= URLEncoder.encode(username, "UTF-8")%>">
<table cellpadding="3" cellspacing="2" border="0">
<tr valign="top">
<td class="jive-label">
<fmt:message key="setup.admin.settings.administrator" />:
</td>
<td>
<%= JID.unescapeNode(username) %>
</td>
<td>
&nbsp;
</td>
</tr>
<tr valign="top">
<td class="jive-label">
<fmt:message key="setup.ldap.server.password" />:
</td>
<td>
<input type="password" name="password" size="20" maxlength="50"/>
</td>
<td>
<input type="submit" name="addAdministrator" value="<fmt:message key="global.test" />"/>
</td>
</tr>
</table>
</form>
<% } %>
</div>
</div>
<!-- END connection settings test panel -->
\ No newline at end of file
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