server-props.jsp 17.7 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3
<%--
  -	$Revision$
  -	$Date$
4
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
6
  -
7 8 9 10 11 12 13 14 15 16 17
  - 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.
Matt Tucker's avatar
Matt Tucker committed
18 19
--%>

20 21
<%@ page import="org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.ParamUtils,
22 23
                 org.jivesoftware.openfire.ConnectionManager,
                 org.jivesoftware.openfire.XMPPServer,
24
                 org.jivesoftware.openfire.JMXManager,
Bill Lynch's avatar
Bill Lynch committed
25
                 java.net.InetAddress,
26
                 java.util.HashMap"
Matt Tucker's avatar
Matt Tucker committed
27
%>
28
<%@ page import="java.util.Map" %>
29

30 31
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
32 33 34

<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />

Bill Lynch's avatar
Bill Lynch committed
35
<%-- Define Administration Bean --%>
36 37
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"  />
<% webManager.init(request, response, session, application, out ); %>
Matt Tucker's avatar
Matt Tucker committed
38

39 40
<%
    // Get parameters
41 42 43 44 45 46 47 48
    String serverName = ParamUtils.getParameter(request, "serverName");
    int port = ParamUtils.getIntParameter(request, "port", -1);
    int sslPort = ParamUtils.getIntParameter(request, "sslPort", -1);
    int embeddedPort = ParamUtils.getIntParameter(request, "embeddedPort", -1);
    int embeddedSecurePort = ParamUtils.getIntParameter(request, "embeddedSecurePort", -1);
    boolean sslEnabled = ParamUtils.getBooleanParameter(request, "sslEnabled");
    int componentPort = ParamUtils.getIntParameter(request, "componentPort", -1);
    int serverPort = ParamUtils.getIntParameter(request, "serverPort", -1);
49 50 51
    boolean jmxEnabled = ParamUtils.getBooleanParameter(request, "jmxEnabled");
    boolean jmxSecure = ParamUtils.getBooleanParameter(request, "jmxSecure");
    int jmxPort = ParamUtils.getIntParameter(request, "jmxPort", -1);
52
    boolean save = request.getParameter("save") != null;
Bill Lynch's avatar
Bill Lynch committed
53
    boolean defaults = request.getParameter("defaults") != null;
54 55 56 57 58 59 60
    boolean cancel = request.getParameter("cancel") != null;

    if (cancel) {
        response.sendRedirect("index.jsp");
        return;
    }

Bill Lynch's avatar
Bill Lynch committed
61 62
    if (defaults) {
        serverName = InetAddress.getLocalHost().getHostName();
63 64 65 66
        port = ConnectionManager.DEFAULT_PORT;
        sslPort = ConnectionManager.DEFAULT_SSL_PORT;
        componentPort = ConnectionManager.DEFAULT_COMPONENT_PORT;
        serverPort = ConnectionManager.DEFAULT_SERVER_PORT;
Bill Lynch's avatar
Bill Lynch committed
67
        embeddedPort = 9090;
68
        embeddedSecurePort = 9091;
Bill Lynch's avatar
Bill Lynch committed
69
        sslEnabled = true;
70 71 72
        jmxEnabled = false;
        jmxSecure = true;
        jmxPort = JMXManager.DEFAULT_PORT;
Bill Lynch's avatar
Bill Lynch committed
73 74 75
        save = true;
    }

76
    XMPPServer server = webManager.getXMPPServer();
77
    ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
78
    Map<String, String> errors = new HashMap<String, String>();
79 80
    if (save) {
        if (serverName == null) {
81
            errors.put("serverName", "");
82
        }
Bill Lynch's avatar
Bill Lynch committed
83
        if (port < 1) {
84
            errors.put("port", "");
Bill Lynch's avatar
Bill Lynch committed
85
        }
86
        if (sslPort < 1 && sslEnabled) {
87
            errors.put("sslPort", "");
Bill Lynch's avatar
Bill Lynch committed
88
        }
89
        if (componentPort < 1) {
90
            errors.put("componentPort", "");
91 92
        }
        if (serverPort < 1) {
93
            errors.put("serverPort", "");
94
        }
95 96
        if (XMPPServer.getInstance().isStandAlone()) {
            if (embeddedPort < 1) {
97
                errors.put("embeddedPort", "");
98 99
            }
            if (embeddedSecurePort < 1) {
100
                errors.put("embeddedSecurePort", "");
101 102 103
            }
            if (embeddedPort > 0 && embeddedSecurePort > 0) {
                if (embeddedPort == embeddedSecurePort) {
104
                    errors.put("embeddedPortsEqual", "");
105 106
                }
            }
107
        } else {
108 109
            embeddedPort = -1;
            embeddedSecurePort = -1;
110
        }
Bill Lynch's avatar
Bill Lynch committed
111 112
        if (port > 0 && sslPort > 0) {
            if (port == sslPort) {
113
                errors.put("portsEqual", "");
Bill Lynch's avatar
Bill Lynch committed
114 115
            }
        }
116 117 118
        if (jmxPort < 1 && jmxEnabled) {
            errors.put("jmxPort", "");
        }
119
        if (errors.size() == 0) {
120
            boolean needRestart = false;
121 122
            if (!serverName.equals(server.getServerInfo().getXMPPDomain())) {
                server.getServerInfo().setXMPPDomain(serverName);
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
                needRestart = true;
            }
            connectionManager.setClientListenerPort(port);
            connectionManager.enableClientSSLListener(sslEnabled);
            connectionManager.setClientSSLListenerPort(sslPort);
            connectionManager.setComponentListenerPort(componentPort);
            connectionManager.setServerListenerPort(serverPort);
            if (!String.valueOf(embeddedPort).equals(JiveGlobals.getXMLProperty("adminConsole.port"))) {
                JiveGlobals.setXMLProperty("adminConsole.port", String.valueOf(embeddedPort));
                needRestart = true;
            }
            if (!String.valueOf(embeddedSecurePort).equals(JiveGlobals.getXMLProperty("adminConsole.securePort"))) {
                JiveGlobals.setXMLProperty("adminConsole.securePort", String.valueOf(embeddedSecurePort));
                needRestart = true;
            }
138 139 140 141
            JMXManager.setEnabled(jmxEnabled);
            JMXManager.setSecure(jmxSecure);
            JMXManager.setPort(jmxPort);

142 143
            // Log the event
            webManager.logEvent("edit server properties", "serverName = "+serverName+"\nport = "+port+"\nsslPort = "+sslPort+"\ncomponentPort = "+componentPort+"\nserverPort = "+serverPort+"\nembeddedPort = "+embeddedPort+"\nembeddedSecurePort = "+embeddedSecurePort);
144 145
            if (needRestart) {
                response.sendRedirect("server-props.jsp?success=true&restart=true");
146
            } else {
147 148
                response.sendRedirect("server-props.jsp?success=true");
            }
149 150
            return;
        }
151
    } else {
152
        serverName = server.getServerInfo().getXMPPDomain();
153 154 155 156 157
        sslEnabled = connectionManager.isClientSSLListenerEnabled();
        port = connectionManager.getClientListenerPort();
        sslPort = connectionManager.getClientSSLListenerPort();
        componentPort = connectionManager.getComponentListenerPort();
        serverPort = connectionManager.getServerListenerPort();
158 159 160 161 162 163 164 165
        try {
            embeddedPort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.port"));
        } catch (Exception ignored) {
        }
        try {
            embeddedSecurePort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.securePort"));
        } catch (Exception ignored) {
        }
166 167 168
        jmxEnabled = JMXManager.isEnabled();
        jmxSecure = JMXManager.isSecure();
        jmxPort = JMXManager.getPort();
169 170 171
    }
%>

172 173 174 175 176 177
<html>
    <head>
        <title><fmt:message key="server.props.title"/></title>
        <meta name="pageID" content="server-settings"/>
    </head>
    <body>
Matt Tucker's avatar
Matt Tucker committed
178

Bill Lynch's avatar
Bill Lynch committed
179 180 181 182 183 184
<style type="text/css">
.c1 {
    width : 30%;
}
</style>

Matt Tucker's avatar
Matt Tucker committed
185
<p>
186
<fmt:message key="server.props.info" />
Matt Tucker's avatar
Matt Tucker committed
187 188
</p>

Bill Lynch's avatar
Bill Lynch committed
189 190 191 192 193
<%  if ("true".equals(request.getParameter("success"))) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
194
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
195
        <td class="jive-icon-label">
196 197 198 199 200
        <%  if ("true".equals(request.getParameter("restart"))) { %>
            <fmt:message key="server.props.update" /> <b><fmt:message key="global.restart" /></b> <fmt:message key="server.props.update2" /> <a href="index.jsp"><fmt:message key="global.server_status" /></a>).
        <%  } else { %>
            <fmt:message key="server.props.update.norestart" />.
        <%  } %>
Bill Lynch's avatar
Bill Lynch committed
201 202 203 204 205 206 207 208
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

<form action="server-props.jsp" name="editform" method="post">
Matt Tucker's avatar
Matt Tucker committed
209

210 211 212 213 214
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
215
            <fmt:message key="server.props.property" />
216 217 218 219 220 221
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
222
            <fmt:message key="server.props.name" />
Matt Tucker's avatar
Matt Tucker committed
223
        </td>
224 225
        <td class="c2">
            <input type="text" name="serverName" value="<%= (serverName != null) ? serverName : "" %>"
226
             size="30" maxlength="150">
Bill Lynch's avatar
Bill Lynch committed
227 228 229
            <%  if (errors.containsKey("serverName")) { %>
                <br>
                <span class="jive-error-text">
230
                <fmt:message key="server.props.valid_hostname" />
Bill Lynch's avatar
Bill Lynch committed
231
                <a href="#" onclick="document.editform.serverName.value='<%= InetAddress.getLocalHost().getHostName() %>';"
232
                 ><fmt:message key="server.props.valid_hostname1" /></a>.
Bill Lynch's avatar
Bill Lynch committed
233 234 235 236
                </span>
            <%  } %>
        </td>
    </tr>
237 238 239 240 241 242 243 244 245 246 247
    <tr>
        <td class="c1">
             <fmt:message key="server.props.server_port" />
        </td>
        <td class="c2">
            <input type="text" name="serverPort" value="<%= (serverPort > 0 ? String.valueOf(serverPort) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("serverPort")) { %>
                <br>
                <span class="jive-error-text">
                <fmt:message key="server.props.valid_port" />
248
                <a href="#" onclick="document.editform.serverPort.value='<%=ConnectionManager.DEFAULT_SERVER_PORT%>';"
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
                 ><fmt:message key="server.props.valid_port1" /></a>.
                </span>
            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
             <fmt:message key="server.props.component_port" />
        </td>
        <td class="c2">
            <input type="text" name="componentPort" value="<%= (componentPort > 0 ? String.valueOf(componentPort) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("componentPort")) { %>
                <br>
                <span class="jive-error-text">
                <fmt:message key="server.props.valid_port" />
265
                <a href="#" onclick="document.editform.componentPort.value='<%=ConnectionManager.DEFAULT_COMPONENT_PORT%>';"
266 267 268 269 270
                 ><fmt:message key="server.props.valid_port1" /></a>.
                </span>
            <%  } %>
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
271 272
    <tr>
        <td class="c1">
273
             <fmt:message key="server.props.port" />
Bill Lynch's avatar
Bill Lynch committed
274 275 276 277 278 279 280
        </td>
        <td class="c2">
            <input type="text" name="port" value="<%= (port > 0 ? String.valueOf(port) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("port")) { %>
                <br>
                <span class="jive-error-text">
281
                <fmt:message key="server.props.valid_port" />
282
                <a href="#" onclick="document.editform.port.value='<%=ConnectionManager.DEFAULT_PORT%>';"
283
                 ><fmt:message key="server.props.valid_port1" /></a>.
Bill Lynch's avatar
Bill Lynch committed
284 285 286 287
                </span>
            <%  } else if (errors.containsKey("portsEqual")) { %>
                <br>
                <span class="jive-error-text">
288
                <fmt:message key="server.props.error_port" />
Bill Lynch's avatar
Bill Lynch committed
289 290
                </span>
            <%  } %>
Matt Tucker's avatar
Matt Tucker committed
291 292
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
293 294
    <tr>
        <td class="c1">
295
              <fmt:message key="server.props.ssl" />
Bill Lynch's avatar
Bill Lynch committed
296 297 298 299 300 301
        </td>
        <td class="c2">
            <table cellpadding="0" cellspacing="0" border="0">
            <tbody>
                <tr>
                    <td>
302
                        <input type="radio" name="sslEnabled" value="true" <%= (sslEnabled ? "checked" : "") %>
Bill Lynch's avatar
Bill Lynch committed
303 304
                         id="SSL01">
                    </td>
305
                    <td><label for="SSL01"><fmt:message key="server.props.enable" /></label></td>
Bill Lynch's avatar
Bill Lynch committed
306 307 308
                </tr>
                <tr>
                    <td>
309
                        <input type="radio" name="sslEnabled" value="false" <%= (!sslEnabled ? "checked" : "") %>
Bill Lynch's avatar
Bill Lynch committed
310 311
                         id="SSL02">
                    </td>
312
                    <td><label for="SSL02"><fmt:message key="server.props.disable" /></label></td>
Bill Lynch's avatar
Bill Lynch committed
313 314 315 316 317 318 319
                </tr>
            </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td class="c1">
320
             <fmt:message key="server.props.ssl_port" />
Bill Lynch's avatar
Bill Lynch committed
321 322 323 324 325 326 327
        </td>
        <td class="c2">
            <input type="text" name="sslPort" value="<%= (sslPort > 0 ? String.valueOf(sslPort) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("sslPort")) { %>
                <br>
                <span class="jive-error-text">
328
                <fmt:message key="server.props.ssl_valid" />
329
                <a href="#" onclick="document.editform.sslPort.value='<%=ConnectionManager.DEFAULT_SSL_PORT%>';"
330
                 ><fmt:message key="server.props.ssl_valid1" /></a>.
Bill Lynch's avatar
Bill Lynch committed
331 332 333 334
                </span>
            <%  } %>
        </td>
    </tr>
335
<% if (XMPPServer.getInstance().isStandAlone()){ %>
Bill Lynch's avatar
Bill Lynch committed
336 337
    <tr>
        <td class="c1">
338
            <fmt:message key="server.props.admin_port" />
Bill Lynch's avatar
Bill Lynch committed
339 340 341 342 343 344 345
        </td>
        <td class="c2">
            <input type="text" name="embeddedPort" value="<%= (embeddedPort > 0 ? String.valueOf(embeddedPort) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("embeddedPort")) { %>
                <br>
                <span class="jive-error-text">
346
                <fmt:message key="server.props.valid_port" />
Bill Lynch's avatar
Bill Lynch committed
347
                <a href="#" onclick="document.editform.embeddedPort.value='9090';"
348
                 ><fmt:message key="server.props.valid_port1" /></a>.
Bill Lynch's avatar
Bill Lynch committed
349
                </span>
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
            <%  } else if (errors.containsKey("embeddedPortsEqual")) { %>
                <br>
                <span class="jive-error-text">
                <fmt:message key="server.props.error_port" />
                </span>
            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
            <fmt:message key="server.props.admin_secure_port" />
        </td>
        <td class="c2">
            <input type="text" name="embeddedSecurePort" value="<%= (embeddedSecurePort > 0 ? String.valueOf(embeddedSecurePort) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("embeddedSecurePort")) { %>
                <br>
                <span class="jive-error-text">
                <fmt:message key="server.props.valid_port" />
                <a href="#" onclick="document.editform.embeddedSecurePort.value='9091';"
                 ><fmt:message key="server.props.valid_port1" /></a>.
                </span>
Bill Lynch's avatar
Bill Lynch committed
372
            <%  } %>
Matt Tucker's avatar
Matt Tucker committed
373 374
        </td>
    </tr>
375
<% } %>
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
    <tr>
        <td class="c1">
              <fmt:message key="server.props.jmx_enabled" />
        </td>
        <td class="c2">
            <table cellpadding="0" cellspacing="0" border="0">
            <tbody>
                <tr>
                    <td>
                        <input type="radio" name="jmxEnabled" value="true" <%= (jmxEnabled ? "checked" : "") %>
                         id="JMX01">
                    </td>
                    <td><label for="JMX01"><fmt:message key="server.props.enable" /></label></td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="jmxEnabled" value="false" <%= (!jmxEnabled ? "checked" : "") %>
                         id="JMX02">
                    </td>
                    <td><label for="JMX02"><fmt:message key="server.props.disable" /></label></td>
                </tr>
            </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td class="c1">
              <fmt:message key="server.props.jmx_secure" />
        </td>
        <td class="c2">
            <table cellpadding="0" cellspacing="0" border="0">
            <tbody>
                <tr>
                    <td>
                        <input type="radio" name="jmxSecure" value="true" <%= (jmxSecure ? "checked" : "") %>
                         id="JMX03">
                    </td>
                    <td><label for="JMX03"><fmt:message key="server.props.enable" /></label></td>
                </tr>
                <tr>
                    <td>
                        <input type="radio" name="jmxSecure" value="false" <%= (!jmxSecure ? "checked" : "") %>
                         id="JMX04">
                    </td>
                    <td><label for="JMX04"><fmt:message key="server.props.disable" /></label></td>
                </tr>
            </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td class="c1">
             <fmt:message key="server.props.jmx_port" />
        </td>
        <td class="c2">
            <input type="text" name="jmxPort" value="<%= (jmxPort > 0 ? String.valueOf(jmxPort) : "") %>"
             size="5" maxlength="5">
            <%  if (errors.containsKey("jmxPort")) { %>
                <br>
                <span class="jive-error-text">
                <fmt:message key="server.props.jmx_valid" />
                <a href="#" onclick="document.editform.jmxPort.value='<%=java.rmi.registry.Registry.REGISTRY_PORT%>';"
                 ><fmt:message key="server.props.jmx_valid1" /></a>.
                </span>
            <%  } %>
        </td>
    </tr>
443 444 445 446
</tbody>
<tfoot>
    <tr>
        <td colspan="2">
447 448 449
            <input type="submit" name="save" value="<fmt:message key="global.save_properties" />">
            <input type="submit" name="defaults" value="<fmt:message key="global.restore_defaults" />">
            <input type="submit" name="cancel" value="<fmt:message key="global.cancel" />">
Matt Tucker's avatar
Matt Tucker committed
450 451
        </td>
    </tr>
452 453 454 455 456
</tfoot>
</table>
</div>

</form>
Matt Tucker's avatar
Matt Tucker committed
457

458 459
    </body>
</html>