%--
- $RCSfile$
- $Revision: $
- $Date: $
-
- Copyright (C) 2005-2008 Jive Software. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%@ page import="org.jivesoftware.openfire.ConnectionManager,
org.jivesoftware.openfire.SessionManager,
org.jivesoftware.openfire.XMPPServer,
org.jivesoftware.openfire.multiplex.ConnectionMultiplexerManager,
org.jivesoftware.openfire.session.ConnectionMultiplexerSession,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.StringUtils"
errorPage="error.jsp"
%>
<%@ page import="java.util.Collection"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Map" %>
<% webManager.init(request, response, session, application, out); %>
<% // Get parameters
boolean update = request.getParameter("update") != null;
boolean managerEnabled = ParamUtils.getBooleanParameter(request,"managerEnabled");
int port = ParamUtils.getIntParameter(request,"port", 0);
String defaultSecret = ParamUtils.getParameter(request,"defaultSecret");
boolean updateSucess = false;
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
// Update the session kick policy if requested
Map errors = new HashMap();
if (update) {
// Validate params
if (managerEnabled) {
if (defaultSecret == null || defaultSecret.trim().length() == 0) {
errors.put("defaultSecret","");
}
if (port <= 0) {
errors.put("port","");
}
}
// If no errors, continue:
if (errors.isEmpty()) {
if (!managerEnabled) {
connectionManager.enableConnectionManagerListener(false);
// Log the event
webManager.logEvent("disabled connection manager settings", null);
}
else {
connectionManager.enableConnectionManagerListener(true);
connectionManager.setConnectionManagerListenerPort(port);
// Get hash value of existing default secret
String existingHashDefaultSecret = "";
if (ConnectionMultiplexerManager.getDefaultSecret() != null) {
existingHashDefaultSecret = StringUtils.hash(ConnectionMultiplexerManager.getDefaultSecret());
}
// Check if the new default secret was changed. If it wasn't changed, then it is the original hashed
// default secret
// NOTE: if the new PLAIN default secret equals the previous HASHED default secret this fails,
// but is unlikely.
if (!existingHashDefaultSecret.equals(defaultSecret)) {
// Hash the new default secret since it was changed
String newHashDefaultSecret = "";
if (defaultSecret != null) {
newHashDefaultSecret = StringUtils.hash(defaultSecret);
}
// Change default secret if hash values are different
if (!existingHashDefaultSecret.equals(newHashDefaultSecret)) {
ConnectionMultiplexerManager.setDefaultSecret(defaultSecret);
}
}
// Log the event
webManager.logEvent("enabled connection manager settings", "port = "+port);
}
updateSucess = true;
}
}
// Set page vars
if (errors.size() == 0) {
managerEnabled = connectionManager.isConnectionManagerListenerEnabled();
port = connectionManager.getConnectionManagerListenerPort();
defaultSecret = ConnectionMultiplexerManager.getDefaultSecret();
}
else {
if (port == 0) {
port = connectionManager.getConnectionManagerListenerPort();
}
if (defaultSecret == null) {
defaultSecret = ConnectionMultiplexerManager.getDefaultSecret();
}
}
%>
" %>" />
" %>" />
<% if (!errors.isEmpty()) { %>
 |
<% if (errors.get("port") != null) { %>
<% } else if (errors.get("defaultSecret") != null) { %>
<% } %>
|
<% } else if (updateSucess) { %>
<% } %>
<% if (managerEnabled) { %>
|
|
|
<%
ConnectionMultiplexerManager multiplexerManager = ConnectionMultiplexerManager.getInstance();
SessionManager sessionManager = SessionManager.getInstance();
Collection connectionManagers = multiplexerManager.getMultiplexers();
if (connectionManagers.isEmpty()) {
%>
|
<% } else {
for (String managerName : connectionManagers) {
List sessions = sessionManager.getConnectionMultiplexerSessions(managerName);
if (sessions.isEmpty()) {
continue;
}
String hostAddress = sessions.get(0).getHostAddress();
String hostName = sessions.get(0).getHostName();
%>
<%= managerName%> |
<%= hostAddress %> / <%= hostName %> |
<%= multiplexerManager.getNumConnectedClients(managerName)%> |
<%
}
}
%>
<% } %>