server-props.jsp 11.1 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4
<%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
5 6 7 8 9
  -
  - 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.
Matt Tucker's avatar
Matt Tucker committed
10 11 12 13
--%>

<%@ page import="org.jivesoftware.util.*,
                 org.jivesoftware.messenger.XMPPServerInfo,
14
                 org.jivesoftware.messenger.ServerPort,
15 16
                 org.jivesoftware.admin.AdminPageBean,
                 java.util.*,
Bill Lynch's avatar
Bill Lynch committed
17 18
                 org.jivesoftware.messenger.XMPPServer,
                 java.net.InetAddress,
19
                 org.jivesoftware.util.JiveGlobals,
20 21
                 org.jivesoftware.messenger.net.SSLSocketAcceptThread,
                 org.jivesoftware.messenger.net.SocketAcceptThread"
Matt Tucker's avatar
Matt Tucker committed
22
%>
23

24 25
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
26 27 28

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

Bill Lynch's avatar
Bill Lynch committed
29
<%-- Define Administration Bean --%>
Matt Tucker's avatar
Matt Tucker committed
30 31 32
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager"  />
<% admin.init(request, response, session, application, out ); %>

33 34 35
<%
    // Get parameters
    String serverName = ParamUtils.getParameter(request,"serverName");
Bill Lynch's avatar
Bill Lynch committed
36 37 38
    int port = ParamUtils.getIntParameter(request,"port",-1);
    int sslPort = ParamUtils.getIntParameter(request,"sslPort",-1);
    int embeddedPort = ParamUtils.getIntParameter(request,"embeddedPort",-1);
39
    int embeddedSecurePort = ParamUtils.getIntParameter(request,"embeddedSecurePort",-1);
Bill Lynch's avatar
Bill Lynch committed
40
    boolean sslEnabled = ParamUtils.getBooleanParameter(request,"sslEnabled");
41
    boolean save = request.getParameter("save") != null;
Bill Lynch's avatar
Bill Lynch committed
42
    boolean defaults = request.getParameter("defaults") != null;
43 44 45 46 47 48 49
    boolean cancel = request.getParameter("cancel") != null;

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

Bill Lynch's avatar
Bill Lynch committed
50 51 52 53 54
    if (defaults) {
        serverName = InetAddress.getLocalHost().getHostName();
        port = 5222;
        sslPort = 5223;
        embeddedPort = 9090;
55
        embeddedSecurePort = 9091;
Bill Lynch's avatar
Bill Lynch committed
56 57 58 59
        sslEnabled = true;
        save = true;
    }

60 61 62 63 64 65
    XMPPServer server = admin.getXMPPServer();
    Map errors = new HashMap();
    if (save) {
        if (serverName == null) {
            errors.put("serverName","");
        }
Bill Lynch's avatar
Bill Lynch committed
66 67 68
        if (port < 1) {
            errors.put("port","");
        }
69
        if (sslPort < 1 && sslEnabled) {
Bill Lynch's avatar
Bill Lynch committed
70 71 72 73 74
            errors.put("sslPort","");
        }
        if (embeddedPort < 1) {
            errors.put("embeddedPort","");
        }
75 76 77
        if (embeddedSecurePort < 1) {
            errors.put("embeddedSecurePort","");
        }
Bill Lynch's avatar
Bill Lynch committed
78 79 80 81 82
        if (port > 0 && sslPort > 0) {
            if (port == sslPort) {
                errors.put("portsEqual","");
            }
        }
83 84 85 86 87
        if (embeddedPort > 0 && embeddedSecurePort > 0) {
            if (embeddedPort == embeddedSecurePort) {
                errors.put("embeddedPortsEqual","");
            }
        }
88 89
        if (errors.size() == 0) {
            server.getServerInfo().setName(serverName);
Bill Lynch's avatar
Bill Lynch committed
90 91 92
            JiveGlobals.setProperty("xmpp.socket.plain.port", String.valueOf(port));
            JiveGlobals.setProperty("xmpp.socket.ssl.active", String.valueOf(sslEnabled));
            JiveGlobals.setProperty("xmpp.socket.ssl.port", String.valueOf(sslPort));
93 94
            JiveGlobals.setXMLProperty("adminConsole.port", String.valueOf(embeddedPort));
            JiveGlobals.setXMLProperty("adminConsole.securePort", String.valueOf(embeddedSecurePort));
Bill Lynch's avatar
Bill Lynch committed
95
            response.sendRedirect("server-props.jsp?success=true");
96 97 98
            return;
        }
    }
99
    else {
100
        serverName = server.getServerInfo().getName();
Bill Lynch's avatar
Bill Lynch committed
101
        sslEnabled = "true".equals(JiveGlobals.getProperty("xmpp.socket.ssl.active"));
102 103 104 105
        try { port = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.plain.port", String.valueOf(SocketAcceptThread.DEFAULT_PORT))); } catch (Exception ignored) {}
        try { sslPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.ssl.port", String.valueOf(SSLSocketAcceptThread.DEFAULT_PORT))); } catch (Exception ignored) {}
        try { embeddedPort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.port")); } catch (Exception ignored) {}
        try { embeddedSecurePort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.securePort")); } catch (Exception ignored) {}
106 107 108
    }
%>

109
<%  // Title of this page and breadcrumbs
110
    String title = LocaleUtils.getLocalizedString("server.props.title");
111
    pageinfo.setTitle(title);
112 113 114
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("index.properties"), "index.jsp"));
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "server-props.jsp"));
Bill Lynch's avatar
Bill Lynch committed
115
    pageinfo.setPageID("server-settings");
116
%>
Bill Lynch's avatar
Bill Lynch committed
117
<jsp:include page="top.jsp" flush="true" />
118
<jsp:include page="title.jsp" flush="true" />
Matt Tucker's avatar
Matt Tucker committed
119

Bill Lynch's avatar
Bill Lynch committed
120 121 122 123 124 125
<style type="text/css">
.c1 {
    width : 30%;
}
</style>

Matt Tucker's avatar
Matt Tucker committed
126
<p>
127
<fmt:message key="server.props.info" />
Matt Tucker's avatar
Matt Tucker committed
128 129
</p>

Bill Lynch's avatar
Bill Lynch committed
130 131 132 133 134 135 136
<%  if ("true".equals(request.getParameter("success"))) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
137
        <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>).
Bill Lynch's avatar
Bill Lynch committed
138 139 140 141 142 143 144 145
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

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

147 148 149 150 151
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
152
            <fmt:message key="server.props.property" />
153 154 155 156 157 158
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
159
            <fmt:message key="server.props.name" />
Matt Tucker's avatar
Matt Tucker committed
160
        </td>
161 162 163
        <td class="c2">
            <input type="text" name="serverName" value="<%= (serverName != null) ? serverName : "" %>"
             size="30" maxlength="40">
Bill Lynch's avatar
Bill Lynch committed
164 165 166
            <%  if (errors.containsKey("serverName")) { %>
                <br>
                <span class="jive-error-text">
167
                <fmt:message key="server.props.valid_hostname" />
Bill Lynch's avatar
Bill Lynch committed
168
                <a href="#" onclick="document.editform.serverName.value='<%= InetAddress.getLocalHost().getHostName() %>';"
169
                 ><fmt:message key="server.props.valid_hostname1" /></a>.
Bill Lynch's avatar
Bill Lynch committed
170 171 172 173 174 175
                </span>
            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
176
             <fmt:message key="server.props.port" />
Bill Lynch's avatar
Bill Lynch committed
177 178 179 180 181 182 183
        </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">
184
                <fmt:message key="server.props.valid_port" />
Bill Lynch's avatar
Bill Lynch committed
185
                <a href="#" onclick="document.editform.port.value='5222';"
186
                 ><fmt:message key="server.props.valid_port1" /></a>.
Bill Lynch's avatar
Bill Lynch committed
187 188 189 190
                </span>
            <%  } else if (errors.containsKey("portsEqual")) { %>
                <br>
                <span class="jive-error-text">
191
                <fmt:message key="server.props.error_port" />
Bill Lynch's avatar
Bill Lynch committed
192 193
                </span>
            <%  } %>
Matt Tucker's avatar
Matt Tucker committed
194 195
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
196 197
    <tr>
        <td class="c1">
198
              <fmt:message key="server.props.ssl" />
Bill Lynch's avatar
Bill Lynch committed
199 200 201 202 203 204
        </td>
        <td class="c2">
            <table cellpadding="0" cellspacing="0" border="0">
            <tbody>
                <tr>
                    <td>
205
                        <input type="radio" name="sslEnabled" value="true" <%= (sslEnabled ? "checked" : "") %>
Bill Lynch's avatar
Bill Lynch committed
206 207
                         id="SSL01">
                    </td>
208
                    <td><label for="SSL01"><fmt:message key="server.props.enable" /></label></td>
Bill Lynch's avatar
Bill Lynch committed
209 210 211
                </tr>
                <tr>
                    <td>
212
                        <input type="radio" name="sslEnabled" value="false" <%= (!sslEnabled ? "checked" : "") %>
Bill Lynch's avatar
Bill Lynch committed
213 214
                         id="SSL02">
                    </td>
215
                    <td><label for="SSL02"><fmt:message key="server.props.disable" /></label></td>
Bill Lynch's avatar
Bill Lynch committed
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
                </tr>
            </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td class="c1">
             SSL Port:
        </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">
231
                <fmt:message key="server.props.ssl_valid" />
Bill Lynch's avatar
Bill Lynch committed
232
                <a href="#" onclick="document.editform.sslPort.value='5223';"
233
                 ><fmt:message key="server.props.ssl_valid1" /></a>.
Bill Lynch's avatar
Bill Lynch committed
234 235 236 237 238 239
                </span>
            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
240
            <fmt:message key="server.props.admin_port" />
Bill Lynch's avatar
Bill Lynch committed
241 242 243 244 245 246 247
        </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">
248
                <fmt:message key="server.props.valid_port" />
Bill Lynch's avatar
Bill Lynch committed
249
                <a href="#" onclick="document.editform.embeddedPort.value='9090';"
250
                 ><fmt:message key="server.props.valid_port1" /></a>.
Bill Lynch's avatar
Bill Lynch committed
251
                </span>
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
            <%  } 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
274
            <%  } %>
Matt Tucker's avatar
Matt Tucker committed
275 276
        </td>
    </tr>
277 278 279 280
</tbody>
<tfoot>
    <tr>
        <td colspan="2">
281 282 283
            <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
284 285
        </td>
    </tr>
286 287 288 289 290
</tfoot>
</table>
</div>

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

Bill Lynch's avatar
Bill Lynch committed
292
<jsp:include page="bottom.jsp" flush="true" />