%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution.
--%>
<%@ 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.util.*,
java.util.Iterator,
org.jivesoftware.openfire.*,
java.util.*,
org.jivesoftware.openfire.component.ExternalComponentManager,
org.jivesoftware.openfire.component.ExternalComponentConfiguration"
errorPage="error.jsp"
%>
<% // Get parameters
boolean update = request.getParameter("update") != null;
boolean permissionUpdate = request.getParameter("permissionUpdate") != null;
boolean componentEnabled = ParamUtils.getBooleanParameter(request,"componentEnabled");
int port = ParamUtils.getIntParameter(request,"port", 0);
String defaultSecret = ParamUtils.getParameter(request,"defaultSecret");
String permissionFilter = ParamUtils.getParameter(request,"permissionFilter");
String configToDelete = ParamUtils.getParameter(request,"deleteConf");
boolean componentAllowed = request.getParameter("componentAllowed") != null;
boolean componentBlocked = request.getParameter("componentBlocked") != null;
String subdomain = ParamUtils.getParameter(request,"subdomain");
String secret = ParamUtils.getParameter(request,"secret");
boolean updateSucess = false;
boolean allowSuccess = false;
boolean blockSuccess = false;
boolean deleteSuccess = false;
String serverName = XMPPServer.getInstance().getServerInfo().getName();
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
// Update the session kick policy if requested
Map errors = new HashMap();
if (update) {
// Validate params
if (componentEnabled) {
if (defaultSecret == null || defaultSecret.trim().length() == 0) {
errors.put("defaultSecret","");
}
if (port <= 0) {
errors.put("port","");
}
}
// If no errors, continue:
if (errors.isEmpty()) {
if (!componentEnabled) {
connectionManager.enableComponentListener(false);
}
else {
connectionManager.enableComponentListener(true);
connectionManager.setComponentListenerPort(port);
ExternalComponentManager.setDefaultSecret(defaultSecret);
}
updateSucess = true;
}
}
if (permissionUpdate) {
ExternalComponentManager.setPermissionPolicy(permissionFilter);
updateSucess = true;
}
if (configToDelete != null && configToDelete.trim().length() != 0) {
ExternalComponentManager.deleteConfiguration(configToDelete);
deleteSuccess = true;
}
if (componentAllowed) {
// Validate params
if (subdomain == null || subdomain.trim().length() == 0) {
errors.put("subdomain","");
}
if (secret == null || secret.trim().length() == 0) {
errors.put("secret","");
}
// If no errors, continue:
if (errors.isEmpty()) {
// Remove the hostname if the user is not sending just the subdomain
subdomain = subdomain.replace("." + serverName, "");
ExternalComponentConfiguration configuration = new ExternalComponentConfiguration(subdomain);
configuration.setSecret(secret);
configuration.setPermission(ExternalComponentConfiguration.Permission.allowed);
ExternalComponentManager.allowAccess(configuration);
allowSuccess = true;
}
}
if (componentBlocked) {
// Validate params
if (subdomain == null || subdomain.trim().length() == 0) {
errors.put("subdomain","");
}
// If no errors, continue:
if (errors.isEmpty()) {
// Remove the hostname if the user is not sending just the subdomain
subdomain = subdomain.replace("." + serverName, "");
ExternalComponentManager.blockAccess(subdomain);
blockSuccess = true;
}
}
// Set page vars
if (errors.size() == 0) {
componentEnabled = connectionManager.isComponentListenerEnabled();
port = connectionManager.getComponentListenerPort();
defaultSecret = ExternalComponentManager.getDefaultSecret();
permissionFilter = ExternalComponentManager.getPermissionPolicy().toString();
subdomain = "";
secret = "";
}
else {
if (port == 0) {
port = connectionManager.getComponentListenerPort();
}
if (defaultSecret == null) {
defaultSecret = ExternalComponentManager.getDefaultSecret();
}
if (permissionFilter == null) {
permissionFilter = ExternalComponentManager.getPermissionPolicy().toString();
}
if (subdomain == null) {
subdomain = "";
}
if (secret == null) {
secret = "";
}
}
%>
" %>" />
" %>" />
<% if (!errors.isEmpty()) { %>
 |
<% if (errors.get("port") != null) { %>
<% } else if (errors.get("defaultSecret") != null) { %>
<% } else if (errors.get("subdomain") != null) { %>
<% } else if (errors.get("secret") != null) { %>
<% } %>
|
<% } else if (updateSucess || allowSuccess || blockSuccess || deleteSuccess) { %>
 |
<% if (updateSucess) { %>
<% } else if (allowSuccess) { %>
<% } else if (blockSuccess) { %>
<% } else if (deleteSuccess) { %>
<%
}
%>
|
<% } %>
<% if (componentEnabled) { %>
| |
|
|
|
<% Collection configs = ExternalComponentManager.getAllowedComponents();
if (configs.isEmpty()) { %>
|
<% }
else {
int count = 1;
for (Iterator it=configs.iterator(); it.hasNext(); count++) {
ExternalComponentConfiguration configuration = it.next();
%>
">
|
<%= count %>
|
<%= configuration.getSubdomain() %>
|
<%= configuration.getSecret() %>
|
')) { location.replace('external-components-settings.jsp?deleteConf=<%= configuration.getSubdomain() %>'); } "
title=""
>
|
<% }
}
%>
| |
|
|
<% Collection blockedComponents = ExternalComponentManager.getBlockedComponents();
if (blockedComponents.isEmpty()) { %>
|
<% }
else {
int count = 1;
for (Iterator it=blockedComponents.iterator(); it.hasNext(); count++) {
ExternalComponentConfiguration configuration = it.next();
%>
">
|
<%= count %>
|
<%= configuration.getSubdomain() %>
|
')) { location.replace('external-components-settings.jsp?deleteConf=<%= configuration.getSubdomain() %>'); } "
title=""
>
|
<% }
}
%>
<% } %>