Commit 34710ea5 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Add administrator specification page for LDAP use case.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5564 b35dd754-fafc-0310-a699-88a17e54d16e
parent 29b3d70e
...@@ -114,6 +114,9 @@ ...@@ -114,6 +114,9 @@
## Updated section: 'group.edit.*' ## Updated section: 'group.edit.*'
## Updated key: 'group.create.form' (note, old translations left in place and need updates) ## Updated key: 'group.create.form' (note, old translations left in place and need updates)
## Deleted keys from: 'group.create.*' ## Deleted keys from: 'group.create.*'
## Added key: 'setup.admin.settings.ldap.info'
## Added key: 'setup.admin.settings.administrator'
## Added key: 'setup.admin.settings.remove'
# Wildfire # Wildfire
...@@ -1245,6 +1248,8 @@ setup.admin.settings.info=Enter settings for the system administrator account (u ...@@ -1245,6 +1248,8 @@ setup.admin.settings.info=Enter settings for the system administrator account (u
below. It is important to choose a password for the account that cannot be easily guessed -- \ below. It is important to choose a password for the account that cannot be easily guessed -- \
for example, at least six characters long and containing a mix of letters and numbers. You \ for example, at least six characters long and containing a mix of letters and numbers. You \
can skip this step if you have already setup your admin account (not for first time users). can skip this step if you have already setup your admin account (not for first time users).
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.error=There were errors when updating the admin account. Please see below.
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 \
...@@ -1259,6 +1264,9 @@ setup.admin.settings.not_new_password=The new passwords do not match. ...@@ -1259,6 +1264,9 @@ setup.admin.settings.not_new_password=The new passwords do not match.
setup.admin.settings.confirm_password=Confirm Password: setup.admin.settings.confirm_password=Confirm Password:
setup.admin.settings.valid_confirm=Please enter a valid new confirmation password. setup.admin.settings.valid_confirm=Please enter a valid new confirmation password.
setup.admin.settings.skip_this_step=Skip This Step setup.admin.settings.skip_this_step=Skip This Step
setup.admin.settings.add.administrator = Add Administrator
setup.admin.settings.administrator = Administrator
setup.admin.settings.remove = Remove
# Setup completed Page # Setup completed Page
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
org.jivesoftware.wildfire.user.UserManager, org.jivesoftware.wildfire.user.UserManager,
org.jivesoftware.util.JiveGlobals" %> org.jivesoftware.util.JiveGlobals" %>
<%@ page import="org.jivesoftware.wildfire.XMPPServer"%> <%@ page import="org.jivesoftware.wildfire.XMPPServer"%>
<%@ page import="org.jivesoftware.wildfire.auth.AuthFactory"%> <%@ page import="org.jivesoftware.wildfire.auth.AuthFactory"%><%@ page import="java.util.Collection"%><%@ page import="java.util.List"%><%@ page import="java.util.ArrayList"%>
<%@ 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" %>
...@@ -41,6 +41,13 @@ ...@@ -41,6 +41,13 @@
boolean doContinue = request.getParameter("continue") != null; boolean doContinue = request.getParameter("continue") != null;
boolean doSkip = request.getParameter("doSkip") != null; boolean doSkip = request.getParameter("doSkip") != null;
boolean ldap = "true".equals(request.getParameter("ldap"));
boolean addAdmin = request.getParameter("addAdministrator") != null;
boolean deleteAdmins = request.getParameter("deleteAdmins") != null;
boolean ldapFinished = request.getParameter("ldapFinished") != null;
// Handle a skip request // Handle a skip request
if (doSkip) { if (doSkip) {
// assume the admin account is setup, so we're done: // assume the admin account is setup, so we're done:
...@@ -96,6 +103,59 @@ ...@@ -96,6 +103,59 @@
} }
} }
} }
if(ldapFinished){
setSetupFinished(session);
// All good so redirect
response.sendRedirect("setup-finished.jsp");
return;
}
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);
String userList = StringUtils.collectionToString(users);
JiveGlobals.setXMLProperty("admin.authorizedUsernames", userList);
}
else {
errors.put("administrator", "");
}
}
if (deleteAdmins) {
String[] params = request.getParameterValues("remove");
String currentAdminList = JiveGlobals.getXMLProperty("admin.authorizedUsernames");
Collection<String> adminCollection = StringUtils.stringToCollection(currentAdminList);
List temporaryUserList = new ArrayList<String>(adminCollection);
final int no = params != null ? params.length : 0;
for (int i = 0; i < no; i++) {
temporaryUserList.remove(params[i]);
}
String newUserList = StringUtils.collectionToString(temporaryUserList);
if (temporaryUserList.size() == 0) {
JiveGlobals.setXMLProperty("admin.authorizedUsernames", "");
}
else {
JiveGlobals.setXMLProperty("admin.authorizedUsernames", newUserList);
}
}
// 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){
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){
adminCollection.add("admin");
JiveGlobals.setXMLProperty("admin.authorizedUsernames", StringUtils.collectionToString(adminCollection));
}
}
%> %>
<html> <html>
<head> <head>
...@@ -109,6 +169,7 @@ ...@@ -109,6 +169,7 @@
<fmt:message key="setup.admin.settings.account" /> <fmt:message key="setup.admin.settings.account" />
</h1> </h1>
<% if(!ldap){ %>
<p> <p>
<fmt:message key="setup.admin.settings.info" /> <fmt:message key="setup.admin.settings.info" />
</p> </p>
...@@ -274,5 +335,92 @@ document.acctform.newPassword.focus(); ...@@ -274,5 +335,92 @@ document.acctform.newPassword.focus();
//--> //-->
</script> </script>
<% } else { %>
<p>
<fmt:message key="setup.admin.settings.ldap.info" />
</p>
<div class="jive-contentBox">
<form action="setup-admin-settings.jsp" name="acctform" method="post">
<!-- Admin Table -->
<table cellpadding="3" cellspacing="2" border="0">
<tr valign="top">
<td class="jive-label">
<fmt:message key="setup.admin.settings.add.administrator" />:
</td>
<td>
<input type="text" name="administrator" size="20" maxlength="50"/>
</td>
<td>
<input type="submit" name="addAdministrator" value="Add"/>
</td>
</tr>
</table>
<%
String authorizedUsernames = JiveGlobals.getXMLProperty("admin.authorizedUsernames");
boolean hasAuthorizedName = authorizedUsernames != null && authorizedUsernames.length() > 0;
%>
<% if(hasAuthorizedName) { %>
<!-- List of admins -->
<table class="jive-vcardTable" cellpadding="3" cellspacing="0" border="0">
<tr>
<th nowrap><fmt:message key="setup.admin.settings.administrator" /></th>
<th width="1%" nowrap><fmt:message key="setup.admin.settings.remove" /></th>
</tr>
<%
for (String username : StringUtils.stringToCollection(authorizedUsernames)) {
%>
<tr valign="top">
<td>
<%= username%>
</td>
<td>
<input type="checkbox" name="remove" value="<%=username%>"/>
</td>
</tr>
<%
}
if (authorizedUsernames != null) {
%>
<tr valign="top">
<td>
&nbsp;
</td>
<td>
<input type="submit" name="deleteAdmins" value="Remove"/>
</td>
</tr>
<%
}
%>
</table>
<% } %>
<input type="hidden" name="ldap" value="true"/>
<div align="right">
<br/>
<input type="submit" name="ldapFinished" value="<fmt:message key="global.continue" />" id="jive-setup-save" border="0" style="display:none;">
</div>
</form>
</div>
<%
if(hasAuthorizedName) {%>
<script type="text/javascript">
document.getElementById("jive-setup-save").style.display = "";
</script>
<% } %>
<% } %>
</body> </body>
</html> </html>
...@@ -54,6 +54,12 @@ ...@@ -54,6 +54,12 @@
</p> </p>
<% <%
String authorizedUsernames = JiveGlobals.getXMLProperty("admin.authorizedUsernames");
String authorizedJIDS = JiveGlobals.getXMLProperty("admin.authorizedJIDs");
boolean useAdmin = authorizedJIDS == null && authorizedUsernames == null;
String parameters = useAdmin ? "?username=admin" : "";
// Figure out the URL that the user can use to login to the admin console. // Figure out the URL that the user can use to login to the admin console.
String url; String url;
if (XMPPServer.getInstance().isStandAlone()) { if (XMPPServer.getInstance().isStandAlone()) {
...@@ -63,15 +69,15 @@ ...@@ -63,15 +69,15 @@
// Use secure login if we're currently secure (and the secure port isn't disabled) // Use secure login if we're currently secure (and the secure port isn't disabled)
// or if the user disabled the plain port. // or if the user disabled the plain port.
if ((request.isSecure() && securePort > 0) || plainPort < 0) { if ((request.isSecure() && securePort > 0) || plainPort < 0) {
url = "https://" + server + ":" + securePort + "/login.jsp?username=admin"; url = "https://" + server + ":" + securePort + "/login.jsp"+parameters;
} }
else { else {
url = "http://" + server + ":" + plainPort + "/login.jsp?username=admin"; url = "http://" + server + ":" + plainPort + "/login.jsp"+parameters;
} }
} }
else { else {
url = request.getRequestURL().toString(); url = request.getRequestURL().toString();
url = url.replace("setup/setup-finished.jsp", "login.jsp?username=admin"); url = url.replace("setup/setup-finished.jsp", "login.jsp"+parameters);
} }
%> %>
......
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