ssl-settings.jsp 28.8 KB
Newer Older
Bill Lynch's avatar
Bill Lynch committed
1
<%--
Matt Tucker's avatar
Matt Tucker committed
2 3
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
4 5 6 7 8
  -
  - 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
9 10
--%>

11 12 13 14 15 16 17
<%@ page import="org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.ParamUtils,
                 org.jivesoftware.wildfire.ClientSession,
                 org.jivesoftware.wildfire.Connection,
                 org.jivesoftware.wildfire.ConnectionManager,
                 org.jivesoftware.wildfire.XMPPServer,
                 org.jivesoftware.wildfire.net.SSLConfig"
Bill Lynch's avatar
Bill Lynch committed
18
    errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
19
%>
20
<%@ page import="org.jivesoftware.wildfire.net.TLSStreamHandler"%>
21 22 23 24 25 26 27 28 29
<%@ page import="java.io.ByteArrayInputStream"%>
<%@ page import="java.security.KeyStore"%>
<%@ page import="java.security.cert.Certificate"%>
<%@ page import="java.security.cert.CertificateFactory"%>
<%@ page import="java.security.cert.X509Certificate"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Map"%>
Bill Lynch's avatar
Bill Lynch committed
30

31
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
32
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Bill Lynch's avatar
Bill Lynch committed
33 34
<%  try { %>

Matt Tucker's avatar
Matt Tucker committed
35
<%  // Get parameters:
Bill Lynch's avatar
Bill Lynch committed
36 37 38 39
    String type = ParamUtils.getParameter(request, "type");
    String cert = ParamUtils.getParameter(request, "cert");
    String alias = ParamUtils.getParameter(request, "alias");
    boolean install = request.getParameter("install") != null;
Bill Lynch's avatar
Bill Lynch committed
40
    boolean uninstall = ParamUtils.getBooleanParameter(request,"uninstall");
Bill Lynch's avatar
Bill Lynch committed
41

42 43
    boolean update = request.getParameter("update") != null;
    boolean success = ParamUtils.getBooleanParameter(request, "success");
44
    // Client configuration parameters
45 46 47
    String clientSecurityRequired = ParamUtils.getParameter(request,"clientSecurityRequired");
    String ssl = ParamUtils.getParameter(request, "ssl");
    String tls = ParamUtils.getParameter(request, "tls");
48 49 50 51
    // Server configuration parameters
    String serverSecurityRequired = ParamUtils.getParameter(request,"serverSecurityRequired");
    String dialback = ParamUtils.getParameter(request, "dialback");
    String server_tls = ParamUtils.getParameter(request, "server_tls");
52

Matt Tucker's avatar
Matt Tucker committed
53 54 55
    KeyStore keyStore = SSLConfig.getKeyStore();
    KeyStore trustStore = SSLConfig.getTrustStore();

56
    Map<String, Object> errors = new HashMap<String, Object>();
57 58 59 60 61 62
    if (update) {
        if ("req".equals(clientSecurityRequired)) {
            // User selected that security is required

            // Enable 5222 port and make TLS required
            XMPPServer.getInstance().getConnectionManager().enableClientListener(true);
63
            ClientSession.setTLSPolicy(Connection.TLSPolicy.required);
64 65 66 67 68 69 70 71
            // Enable 5223 port (old SSL port)
            XMPPServer.getInstance().getConnectionManager().enableClientSSLListener(true);
        }
        else if ("notreq".equals(clientSecurityRequired)) {
            // User selected that security is NOT required

            // Enable 5222 port and make TLS optional
            XMPPServer.getInstance().getConnectionManager().enableClientListener(true);
72
            ClientSession.setTLSPolicy(Connection.TLSPolicy.optional);
73 74 75 76 77 78 79 80 81 82 83 84
            // Enable 5223 port (old SSL port)
            XMPPServer.getInstance().getConnectionManager().enableClientSSLListener(true);
        }
        else if ("custom".equals(clientSecurityRequired)) {
            // User selected custom client authentication

            // Enable or disable 5223 port (old SSL port)
            XMPPServer.getInstance().getConnectionManager().enableClientSSLListener("available".equals(ssl));

            // Enable port 5222 and configure TLS policy
            XMPPServer.getInstance().getConnectionManager().enableClientListener(true);
            if ("notavailable".equals(tls)) {
85
                ClientSession.setTLSPolicy(Connection.TLSPolicy.disabled);
86 87
            }
            else if ("optional".equals(tls)) {
88
                ClientSession.setTLSPolicy(Connection.TLSPolicy.optional);
89 90
            }
            else {
91
                ClientSession.setTLSPolicy(Connection.TLSPolicy.required);
92 93
            }
        }
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134

        if ("req".equals(serverSecurityRequired)) {
            // User selected that security for s2s is required

            // Enable TLS and disable server dialback
            XMPPServer.getInstance().getConnectionManager().enableServerListener(true);
            JiveGlobals.setProperty("xmpp.server.tls.enabled", "true");
            JiveGlobals.setProperty("xmpp.server.dialback.enabled", "false");
        }
        else if ("notreq".equals(serverSecurityRequired)) {
            // User selected that security for s2s is NOT required

            // Enable TLS and enable server dialback
            XMPPServer.getInstance().getConnectionManager().enableServerListener(true);
            JiveGlobals.setProperty("xmpp.server.tls.enabled", "true");
            JiveGlobals.setProperty("xmpp.server.dialback.enabled", "true");
        }
        else if ("custom".equals(serverSecurityRequired)) {
            // User selected custom server authentication

            boolean dialbackEnabled = "available".equals(dialback);
            boolean tlsEnabled = "optional".equals(server_tls);

            if (dialbackEnabled || tlsEnabled) {
                XMPPServer.getInstance().getConnectionManager().enableServerListener(true);

                // Enable or disable server dialback
                JiveGlobals.setProperty("xmpp.server.dialback.enabled", dialbackEnabled ? "true" : "false");

                // Enable or disable TLS for s2s connections
                JiveGlobals.setProperty("xmpp.server.tls.enabled", tlsEnabled ? "true" : "false");
            }
            else {
                XMPPServer.getInstance().getConnectionManager().enableServerListener(false);
                // Disable server dialback
                JiveGlobals.setProperty("xmpp.server.dialback.enabled", "false");

                // Disable TLS for s2s connections
                JiveGlobals.setProperty("xmpp.server.tls.enabled", "false");
            }
        }
135 136 137 138 139 140
        success = true;
    }

    // Set page vars
    ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
    if (connectionManager.isClientListenerEnabled() && connectionManager.isClientSSLListenerEnabled()) {
141
        if (Connection.TLSPolicy.required.equals(ClientSession.getTLSPolicy())) {
142 143 144 145
            clientSecurityRequired = "req";
            ssl = "available";
            tls = "required";
        }
146
        else if (Connection.TLSPolicy.optional.equals(ClientSession.getTLSPolicy())) {
147 148 149 150 151 152 153 154 155 156 157 158 159
            clientSecurityRequired = "notreq";
            ssl = "available";
            tls = "optional";
        }
        else {
            clientSecurityRequired = "custom";
            ssl = "available";
            tls = "notavailable";
        }
    }
    else {
        clientSecurityRequired = "custom";
        ssl = connectionManager.isClientSSLListenerEnabled() ? "available" : "notavailable";
160
        tls = Connection.TLSPolicy.disabled.equals(ClientSession.getTLSPolicy()) ? "notavailable" : ClientSession.getTLSPolicy().toString();
161 162
    }

163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
    boolean tlsEnabled = JiveGlobals.getBooleanProperty("xmpp.server.tls.enabled", true);
    boolean dialbackEnabled = JiveGlobals.getBooleanProperty("xmpp.server.dialback.enabled", true);
    if (tlsEnabled) {
        if (dialbackEnabled) {
            serverSecurityRequired = "notreq";
            dialback = "available";
            server_tls = "optional";
        }
        else {
            serverSecurityRequired = "req";
            dialback = "notavailable";
            server_tls = "optional";
        }
    }
    else {
        serverSecurityRequired = "custom";
        dialback = dialbackEnabled ? "available" : "notavailable";
        server_tls = "notavailable";
    }

Bill Lynch's avatar
Bill Lynch committed
183 184
    if (install) {
        if (cert == null){
Matt Tucker's avatar
Matt Tucker committed
185 186
            errors.put("cert","");
        }
Bill Lynch's avatar
Bill Lynch committed
187
        if (alias == null) {
Matt Tucker's avatar
Matt Tucker committed
188 189
            errors.put("alias","");
        }
Bill Lynch's avatar
Bill Lynch committed
190 191 192 193 194 195 196 197 198 199 200 201 202
        if (errors.size() == 0) {
            try {
                CertificateFactory cf = CertificateFactory.getInstance("X.509");
                Certificate certificate = cf.generateCertificate(new ByteArrayInputStream(cert.getBytes()));
                if ("client".equals(type)){
                    trustStore.setCertificateEntry(alias,certificate);
                }
                else {
                    keyStore.setCertificateEntry(alias,certificate);
                }
                SSLConfig.saveStores();
                response.sendRedirect("ssl-settings.jsp?success=true");
                return;
Matt Tucker's avatar
Matt Tucker committed
203
            }
Bill Lynch's avatar
Bill Lynch committed
204 205
            catch (Exception e) {
                errors.put("general","");
Matt Tucker's avatar
Matt Tucker committed
206 207 208
            }
        }
    }
Bill Lynch's avatar
Bill Lynch committed
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
    if (uninstall) {
        if (type != null && alias != null) {
            try {
                if ("client".equals(type)){
                    SSLConfig.getTrustStore().deleteEntry(alias);
                }
                else if ("server".equals(type)) {
                    SSLConfig.getKeyStore().deleteEntry(alias);
                }
                SSLConfig.saveStores();
                response.sendRedirect("ssl-settings.jsp?deletesuccess=true");
                return;
            }
            catch (Exception e) {
                e.printStackTrace();
                errors.put("delete", e);
            }
        }
    }
Bill Lynch's avatar
Bill Lynch committed
228
%>
Matt Tucker's avatar
Matt Tucker committed
229

230 231 232 233 234
<html>
    <head>
        <title><fmt:message key="ssl.settings.title"/></title>
        <meta name="pageID" content="server-ssl"/>
        <meta name="helpPage" content="manage_security_certificates.html"/>
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
        <script language="JavaScript" type="text/javascript">
            <!-- // code for window popups
            function showOrHide(whichLayer, mode)
            {

                if (mode == "show") {
                    mode = "";
                }
                else {
                    mode = "none";
                }

                if (document.getElementById)
                {
                    // this is the way the standards work
                    var style2 = document.getElementById(whichLayer).style;
                    style2.display = mode;
                }
                else if (document.all)
                {
                    // this is the way old msie versions work
                    var style2 = document.all[whichLayer].style;
                    style2.display = mode;
                }
                else if (document.layers)
                {
                    // this is the way nn4 works
                    var style2 = document.layers[whichLayer].style;
                    style2.display = mode;
                }
            }

            function togglePublicKey(pkLayer, indexLayer)
            {
                if (document.getElementById)
                {
                    // this is the way the standards work
                    var style2 = document.getElementById(pkLayer).style;
                    var certs = document.getElementById(indexLayer);
                    certs.rowSpan = style2.display? 2:1;
                    style2.display = style2.display? "":"none";
                }
                else if (document.all)
                {
                    // this is the way old msie versions work
                    var style2 = document.all[pkLayer].style;
                    var certs = document.all[indexLayer];
                    certs.rowSpan = style2.display? 2:1;
                    style2.display = style2.display? "":"none";
                }
                else if (document.layers)
                {
                    // this is the way nn4 works
                    var style2 = document.layers[pkLayer].style;
                    var certs = document.layers[indexLayer];
                    certs.rowSpan = style2.display? 2:1;
                    style2.display = style2.display? "":"none";
                }
            }
            //-->
        </script>
296 297
    </head>
    <body>
Matt Tucker's avatar
Matt Tucker committed
298

299
<%  if (success) { %>
Matt Tucker's avatar
Matt Tucker committed
300

Bill Lynch's avatar
Bill Lynch committed
301 302 303
    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
304
        <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
305
        <td class="jive-icon-label">
306
        <fmt:message key="ssl.settings.update" />
Bill Lynch's avatar
Bill Lynch committed
307 308 309 310
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
311

Bill Lynch's avatar
Bill Lynch committed
312 313 314 315 316
<%  } else if (ParamUtils.getBooleanParameter(request,"deletesuccess")) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
317
        <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
318
        <td class="jive-icon-label">
319
        <fmt:message key="ssl.settings.uninstalled" />
Bill Lynch's avatar
Bill Lynch committed
320 321 322 323 324 325 326 327 328 329 330 331
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } else if (errors.containsKey("delete")) {
        Exception e = (Exception)errors.get("delete");
%>

    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
332
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
333
        <td class="jive-icon-label">
334
        <fmt:message key="ssl.settings.error" />
Bill Lynch's avatar
Bill Lynch committed
335
        <%  if (e != null && e.getMessage() != null) { %>
336
            <fmt:message key="ssl.settings.error_messenge" />: <%= e.getMessage() %>
Bill Lynch's avatar
Bill Lynch committed
337 338 339 340 341 342
        <%  } %>
        </td></tr>
    </tbody>
    </table>
    </div><br>

Bill Lynch's avatar
Bill Lynch committed
343 344 345 346 347
<%  } else if (errors.size() > 0) { %>

    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
348
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
349
        <td class="jive-icon-label">
350
        <fmt:message key="ssl.settings.error_certificate" />
Bill Lynch's avatar
Bill Lynch committed
351 352 353 354
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
355

Bill Lynch's avatar
Bill Lynch committed
356
<%  } %>
Derek DeMoro's avatar
Derek DeMoro committed
357

Bill Lynch's avatar
Bill Lynch committed
358
<p>
359
<fmt:message key="ssl.settings.client.info" />
Bill Lynch's avatar
Bill Lynch committed
360 361
</p>

362 363 364 365 366
<form action="ssl-settings.jsp" method="post">

<fieldset>
    <legend><fmt:message key="ssl.settings.client.legend" /></legend>
    <div>
367
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
368 369 370 371
    <tbody>
        <tr valign="middle">
            <tr valign="middle">
                <td width="1%" nowrap>
372 373
                    <input type="radio" name="clientSecurityRequired" value="notreq" id="rb02" onclick="showOrHide('custom', 'hide')"
                     <%= ("notreq".equals(clientSecurityRequired) ? "checked" : "") %>>
374 375
                </td>
                <td width="99%">
376 377
                    <label for="rb02">
                    <b><fmt:message key="ssl.settings.client.label_notrequired" /></b> - <fmt:message key="ssl.settings.client.label_notrequired_info" />
378 379 380 381 382
                    </label>
                </td>
            </tr>
            <tr valign="middle">
                <td width="1%" nowrap>
383 384
                    <input type="radio" name="clientSecurityRequired" value="req" id="rb01" onclick="showOrHide('custom', 'hide')"
                 <%= ("req".equals(clientSecurityRequired) ? "checked" : "") %>>
385 386
                </td>
                <td width="99%">
387 388
                    <label for="rb01">
                    <b><fmt:message key="ssl.settings.client.label_required" /></b> - <fmt:message key="ssl.settings.client.label_required_info" />
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 443
                    </label>
                </td>
            </tr>
            <tr valign="middle">
                <td width="1%" nowrap>
                    <input type="radio" name="clientSecurityRequired" value="custom" id="rb03" onclick="showOrHide('custom', 'show')"
                     <%= ("custom".equals(clientSecurityRequired) ? "checked" : "") %>>
                </td>
                <td width="99%">
                    <label for="rb03">
                    <b><fmt:message key="ssl.settings.client.label_custom" /></b> - <fmt:message key="ssl.settings.client.label_custom_info" />
                    </label>
                </td>
            </tr>
            <tr valign="top" id="custom" <% if (!"custom".equals(clientSecurityRequired)) out.write("style=\"display:none\""); %>>
                <td width="1%" nowrap>
                    &nbsp;
                </td>
                <td width="99%">
                    <table cellpadding="3" cellspacing="0" border="0" width="100%">
                    <tr valign="top">
                        <td width="1%" nowrap>
                            <fmt:message key="ssl.settings.client.customSSL" />
                        </td>
                        <td width="99%">
                            <input type="radio" name="ssl" value="notavailable" id="rb04" <%= ("notavailable".equals(ssl) ? "checked" : "") %>
                                   onclick="this.form.clientSecurityRequired[2].checked=true;">&nbsp;<label for="rb04"><fmt:message key="ssl.settings.notavailable" /></label>&nbsp;&nbsp;
                            <input type="radio" name="ssl" value="available" id="rb05" <%= ("available".equals(ssl) ? "checked" : "") %>
                                   onclick="this.form.clientSecurityRequired[2].checked=true;">&nbsp;<label for="rb05"><fmt:message key="ssl.settings.available" /></label>
                        </td>
                    </tr>
                    <tr valign="top">
                        <td width="1%" nowrap>
                            <fmt:message key="ssl.settings.client.customTLS" />
                        </td>
                        <td width="99%">
                            <input type="radio" name="tls" value="notavailable" id="rb06" <%= ("notavailable".equals(tls) ? "checked" : "") %>
                                   onclick="this.form.clientSecurityRequired[2].checked=true;">&nbsp;<label for="rb06"><fmt:message key="ssl.settings.notavailable" /></label>&nbsp;&nbsp;
                            <input type="radio" name="tls" value="optional" id="rb07" <%= ("optional".equals(tls) ? "checked" : "") %>
                                   onclick="this.form.clientSecurityRequired[2].checked=true;">&nbsp;<label for="rb07"><fmt:message key="ssl.settings.optional" /></label>&nbsp;&nbsp;
                            <input type="radio" name="tls" value="required" id="rb08" <%= ("required".equals(tls) ? "checked" : "") %>
                                   onclick="this.form.clientSecurityRequired[2].checked=true;">&nbsp;<label for="rb08"><fmt:message key="ssl.settings.required" /></label>
                        </td>
                    </tr>
                    </table>
                </td>
            </tr>
        </tr>
    </tbody>
    </table>
    </div>
</fieldset>
<br>

<input type="submit" name="update" value="<fmt:message key="global.save_settings" />">
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528

</form>

<br>

<form action="ssl-settings.jsp" method="post">

<fieldset>
    <legend><fmt:message key="ssl.settings.server.legend" /></legend>
    <div>
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
    <tbody>
        <tr valign="middle">
            <tr valign="middle">
                <td width="1%" nowrap>
                    <input type="radio" name="serverSecurityRequired" value="notreq" id="rb09" onclick="showOrHide('server_custom', 'hide')"
                     <%= ("notreq".equals(serverSecurityRequired) ? "checked" : "") %>>
                </td>
                <td width="99%">
                    <label for="rb09">
                    <b><fmt:message key="ssl.settings.server.label_notrequired" /></b> - <fmt:message key="ssl.settings.server.label_notrequired_info" />
                    </label>
                </td>
            </tr>
            <tr valign="middle">
                <td width="1%" nowrap>
                    <input type="radio" name="serverSecurityRequired" value="req" id="rb10" onclick="showOrHide('server_custom', 'hide')"
                 <%= ("req".equals(serverSecurityRequired) ? "checked" : "") %>>
                </td>
                <td width="99%">
                    <label for="rb10">
                    <b><fmt:message key="ssl.settings.server.label_required" /></b> - <fmt:message key="ssl.settings.server.label_required_info" />
                    </label>
                </td>
            </tr>
            <tr valign="middle">
                <td width="1%" nowrap>
                    <input type="radio" name="serverSecurityRequired" value="custom" id="rb11" onclick="showOrHide('server_custom', 'show')"
                     <%= ("custom".equals(serverSecurityRequired) ? "checked" : "") %>>
                </td>
                <td width="99%">
                    <label for="rb11">
                    <b><fmt:message key="ssl.settings.server.label_custom" /></b> - <fmt:message key="ssl.settings.server.label_custom_info" />
                    </label>
                </td>
            </tr>
            <tr valign="top" id="server_custom" <% if (!"custom".equals(serverSecurityRequired)) out.write("style=\"display:none\""); %>>
                <td width="1%" nowrap>
                    &nbsp;
                </td>
                <td width="99%">
                    <table cellpadding="3" cellspacing="0" border="0" width="100%">
                    <tr valign="top">
                        <td width="1%" nowrap>
                            <fmt:message key="ssl.settings.server.dialback" />
                        </td>
                        <td width="99%">
                            <input type="radio" name="dialback" value="notavailable" id="rb12" <%= ("notavailable".equals(dialback) ? "checked" : "") %>
                                   onclick="this.form.serverSecurityRequired[2].checked=true;">&nbsp;<label for="rb12"><fmt:message key="ssl.settings.notavailable" /></label>&nbsp;&nbsp;
                            <input type="radio" name="dialback" value="available" id="rb13" <%= ("available".equals(dialback) ? "checked" : "") %>
                                   onclick="this.form.serverSecurityRequired[2].checked=true;">&nbsp;<label for="rb13"><fmt:message key="ssl.settings.available" /></label>
                        </td>
                    </tr>
                    <tr valign="top">
                        <td width="1%" nowrap>
                            <fmt:message key="ssl.settings.server.customTLS" />
                        </td>
                        <td width="99%">
                            <input type="radio" name="server_tls" value="notavailable" id="rb14" <%= ("notavailable".equals(server_tls) ? "checked" : "") %>
                                   onclick="this.form.serverSecurityRequired[2].checked=true;">&nbsp;<label for="rb14"><fmt:message key="ssl.settings.notavailable" /></label>&nbsp;&nbsp;
                            <input type="radio" name="server_tls" value="optional" id="rb15" <%= ("optional".equals(server_tls) ? "checked" : "") %>
                                   onclick="this.form.serverSecurityRequired[2].checked=true;">&nbsp;<label for="rb15"><fmt:message key="ssl.settings.optional" /></label>&nbsp;&nbsp;
                        </td>
                    </tr>
                    </table>
                </td>
            </tr>
        </tr>
    </tbody>
    </table>
    </div>
</fieldset>
<br>

<input type="submit" name="update" value="<fmt:message key="global.save_settings" />">
529 530 531 532 533

</form>

<br><br>

534
<p><b><fmt:message key="ssl.settings.certificate" /></b></p>
Bill Lynch's avatar
Bill Lynch committed
535

536 537 538 539 540
<p>
<fmt:message key="ssl.settings.info" />
</p>

<table class="jive-table" cellpadding="0" cellspacing="0" border="0" width="100%">
Bill Lynch's avatar
Bill Lynch committed
541 542
<thead>
    <tr>
Bill Lynch's avatar
Bill Lynch committed
543
        <th width="1%">&nbsp;</th>
Bill Lynch's avatar
Bill Lynch committed
544
        <th>
545
            <fmt:message key="ssl.settings.alias" />
Bill Lynch's avatar
Bill Lynch committed
546 547
        </th>
        <th>
548 549 550 551
            <fmt:message key="ssl.settings.expiration" />
        </th>
        <th>
            <fmt:message key="ssl.settings.self-signed" />
Bill Lynch's avatar
Bill Lynch committed
552
        </th>
553 554 555
        <th>
            <fmt:message key="ssl.settings.publickey" />
        </th>
Bill Lynch's avatar
Bill Lynch committed
556
        <th width="1%">
557
            <fmt:message key="ssl.settings.uninstall" />
Bill Lynch's avatar
Bill Lynch committed
558 559 560 561 562 563 564 565 566
        </th>
    </tr>
</thead>
<tbody>

<%  int i=0;
    for (Enumeration aliases=keyStore.aliases(); aliases.hasMoreElements();) {
        i++;
        String a = (String)aliases.nextElement();
567
        X509Certificate c = (X509Certificate) keyStore.getCertificate(a);
568 569 570 571 572 573 574
        StringBuffer identities = new StringBuffer();
        for (String identity : TLSStreamHandler.getPeerIdentities(c)) {
            identities.append(identity).append(", ");
        }
        if (identities.length() > 0) {
            identities.setLength(identities.length() - 2);
        }
Matt Tucker's avatar
Matt Tucker committed
575
%>
Bill Lynch's avatar
Bill Lynch committed
576
    <tr valign="top">
577
        <td id="rs<%=i%>" width="1" rowspan="1"><%= (i) %>.</td>
578
        <td>
579
            <%= identities.toString() %> (<%= a %>)
580 581 582 583 584 585 586 587 588 589
        </td>
        <td>
            <% boolean expired = c.getNotAfter().before(new Date());
               if (expired) { %>
                <font color="red">
            <% } %>
            <%= JiveGlobals.formatDateTime(c.getNotAfter()) %>
            <% if (expired) { %>
                </font>
            <% } %>
Bill Lynch's avatar
Bill Lynch committed
590
        </td>
591 592 593 594 595 596
        <td width="1">
            <% if (c.getSubjectDN().equals(c.getIssuerDN())) { %>
                <fmt:message key="global.yes" />
            <% } else { %>
                <fmt:message key="global.no" />
            <% } %>
Bill Lynch's avatar
Bill Lynch committed
597
        </td>
598 599 600
        <td width="2%">
            <a href="javascript:togglePublicKey('pk<%=i%>', 'rs<%=i%>');" title="<fmt:message key="ssl.settings.publickey.title" />"><fmt:message key="ssl.settings.publickey.label" /></a>
        </td>
Bill Lynch's avatar
Bill Lynch committed
601
        <td width="1" align="center">
Bill Lynch's avatar
Bill Lynch committed
602
            <a href="ssl-settings.jsp?alias=<%= a %>&type=server&uninstall=true"
603 604
             title="<fmt:message key="ssl.settings.click_uninstall" />"
             onclick="return confirm('<fmt:message key="ssl.settings.confirm_uninstall" />');"
605
             ><img src="images/delete-16x16.gif" width="16" height="16" border="0" alt=""></a>
Bill Lynch's avatar
Bill Lynch committed
606 607
        </td>
    </tr>
608
    <tr id="pk<%=i%>" style="display:none">
Bill Lynch's avatar
Bill Lynch committed
609 610
        <td colspan="3">
            <span class="jive-description">
611
            <fmt:message key="ssl.settings.key" />
Matt Tucker's avatar
Matt Tucker committed
612
            </span>
Bill Lynch's avatar
Bill Lynch committed
613 614 615 616
<textarea cols="40" rows="3" style="width:100%;font-size:8pt;" wrap="virtual">
<%= c.getPublicKey() %></textarea>
        </td>
    </tr>
Matt Tucker's avatar
Matt Tucker committed
617

Bill Lynch's avatar
Bill Lynch committed
618
<%  } %>
Matt Tucker's avatar
Matt Tucker committed
619

Bill Lynch's avatar
Bill Lynch committed
620 621 622 623 624
<%  if (i==0) { %>

    <tr>
        <td colspan="4">
            <p>
625
            <fmt:message key="ssl.settings.no_installed" />
Bill Lynch's avatar
Bill Lynch committed
626 627 628 629 630 631
            </p>
        </td>
    </tr>

<%  } %>

Bill Lynch's avatar
Bill Lynch committed
632 633
</tbody>
</table>
Matt Tucker's avatar
Matt Tucker committed
634

Bill Lynch's avatar
Bill Lynch committed
635
<br><br>
Matt Tucker's avatar
Matt Tucker committed
636

Bill Lynch's avatar
Bill Lynch committed
637 638 639
<form action="ssl-settings.jsp" method="post">

<fieldset>
640
    <legend><fmt:message key="ssl.settings.install_certificate" /></legend>
Bill Lynch's avatar
Bill Lynch committed
641 642
    <div>
    <p>
643
      <fmt:message key="ssl.settings.install_certificate_info" />
Bill Lynch's avatar
Bill Lynch committed
644 645 646 647 648 649 650
    </p>
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
    <tbody>
        <%  if (errors.containsKey("alias")) { %>
            <tr><td>&nbsp;</td>
                <td>
                    <span class="jive-error-text">
651
                    <fmt:message key="ssl.settings.enter_alias" />
Bill Lynch's avatar
Bill Lynch committed
652 653 654 655 656 657 658
                    </span>
                </td>
            </tr>
        <%  } else if (errors.containsKey("cert")) { %>
            <tr><td>&nbsp;</td>
                <td>
                    <span class="jive-error-text">
659
                    <fmt:message key="ssl.settings.enter_certificate" />
Bill Lynch's avatar
Bill Lynch committed
660 661 662 663 664 665 666 667 668
                    </span>
                </td>
            </tr>
        <%  } else if (errors.containsKey("general")) {
                String error = (String)errors.get("general");
        %>
            <tr><td>&nbsp;</td>
                <td>
                    <span class="jive-error-text">
669
                    <fmt:message key="ssl.settings.error_installing" />
Bill Lynch's avatar
Bill Lynch committed
670
                    <%  if (error != null && !"".equals(error.trim())) { %>
671
                        <fmt:message key="ssl.settings.error_reported" />: <%= error %>.
Bill Lynch's avatar
Bill Lynch committed
672 673 674 675
                    <%  } %>
                    </span>
                </td>
            </tr>
Matt Tucker's avatar
Matt Tucker committed
676
        <%  } %>
Bill Lynch's avatar
Bill Lynch committed
677
        <tr>
678
            <td nowrap><fmt:message key="ssl.settings.type" />:</td>
Bill Lynch's avatar
Bill Lynch committed
679 680
            <td>
                <select name="type" size="1">
681 682
                    <option value="server"><fmt:message key="ssl.settings.server" /></option>
                    <option value="client"><fmt:message key="ssl.settings.client" /></option>
Bill Lynch's avatar
Bill Lynch committed
683 684 685 686
                </select>
            </td>
        </tr>
        <tr>
687
            <td nowrap><fmt:message key="ssl.settings.alias" />:</td>
Bill Lynch's avatar
Bill Lynch committed
688 689 690 691 692
            <td>
                <input name="alias" type="text" size="50" maxlength="255" value="<%= (alias != null ? alias : "") %>">
            </td>
        </tr>
        <tr valign="top">
693
            <td nowrap><fmt:message key="ssl.settings.a_certificate" />:</td>
Bill Lynch's avatar
Bill Lynch committed
694 695
            <td>
                <span class="jive-description">
696
                <fmt:message key="ssl.settings.paste_certificate" /><br>
Bill Lynch's avatar
Bill Lynch committed
697 698 699 700 701 702 703
                </span>
                <textarea name="cert" cols="55" rows="7" wrap="virtual" style="font-size:8pt;"></textarea>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <br>
704
                <input type="submit" name="install" value="<fmt:message key="ssl.settings.add_certificate" />">
Bill Lynch's avatar
Bill Lynch committed
705 706 707 708 709 710
            </td>
        </tr>
    </tbody>
    </table>
    </div>
</fieldset>
Matt Tucker's avatar
Matt Tucker committed
711 712

</form>
Bill Lynch's avatar
Bill Lynch committed
713

714 715
    </body>
</html>
Bill Lynch's avatar
Bill Lynch committed
716

717
<%  } catch (Throwable t) { t.printStackTrace(); } %>