clearspace-integration.jspf 7.16 KB
Newer Older
1 2 3 4 5 6 7 8 9
<%@ page import="org.jivesoftware.util.LocaleUtils"%>
<%@ page import="org.jivesoftware.util.ParamUtils"%>
<%@ page import="java.util.*" %>
<%@ page import="org.jivesoftware.openfire.clearspace.ClearspaceManager" %>
<%@ page import="org.jivesoftware.util.JiveGlobals" %>

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%
10
    String uri;
11 12 13 14 15 16 17 18 19 20
    String sharedSecret;

    // Get parameters
    boolean save = request.getParameter("save") != null;
    boolean test = request.getParameter("test") != null;

    ClearspaceManager manager = ClearspaceManager.getInstance();
    Map<String, String> errors = new HashMap<String, String>();

    if (save || test) {
21 22 23
        uri = ParamUtils.getParameter(request, "uri");
        if (uri == null) {
            errors.put("uri", LocaleUtils.getLocalizedString("setup.clearspace.service.uri_error"));
24 25
        }
        sharedSecret = ParamUtils.getParameter(request, "sharedSecret");
26 27 28
        if (sharedSecret == null || sharedSecret.length() == 0) {
            errors.put("secret", LocaleUtils.getLocalizedString("setup.clearspace.service.secret_error"));
        }
29 30 31 32

        if (errors.isEmpty()) {
            // Store settings in a map and keep it in the session
            Map<String, String> settings = new HashMap<String, String>();
33
            settings.put("clearspace.uri", uri);
34 35 36 37 38
            settings.put("clearspace.sharedSecret", sharedSecret);
            session.setAttribute("clearspaceSettings", settings);

            if (save) {
                // Save settings and redirect
39
                manager.setConnectionURI(uri);
40 41 42 43 44 45 46 47 48 49 50
                manager.setSharedSecret(sharedSecret);

                // Enable the Clearspace user, auth, group, and vcard providers.
                JiveGlobals.setXMLProperty("provider.user.className",
                        "org.jivesoftware.openfire.clearspace.ClearspaceUserProvider");
                JiveGlobals.setXMLProperty("provider.auth.className",
                        "org.jivesoftware.openfire.clearspace.ClearspaceAuthProvider");
                JiveGlobals.setXMLProperty("provider.group.className",
                        "org.jivesoftware.openfire.clearspace.ClearspaceGroupProvider");
                JiveGlobals.setXMLProperty("provider.vcard.className",
                        "org.jivesoftware.openfire.clearspace.ClearspaceVCardProvider");
51 52 53 54
                JiveGlobals.setXMLProperty("provider.lockout.className",
                        "org.jivesoftware.openfire.clearspace.ClearspaceLockOutProvider");
                JiveGlobals.setXMLProperty("provider.securityAudit.className",
                        "org.jivesoftware.openfire.clearspace.ClearspaceSecurityAuditProvider");
55 56 57 58 59 60 61 62

                // Redirect to next step.
                response.sendRedirect(nextPage);
                return;
            }
        }
    } else {
        // See if there are already values for the variables defined.
63
        uri = manager.getConnectionURI();
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 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
        sharedSecret = manager.getSharedSecret();
    }
%>
<html>
<head>
    <title><fmt:message key="setup.clearspace.title" /></title>
    <% for (Map.Entry<String, String> entry : meta.entrySet()) { %>
    <meta name="<%= entry.getKey()%>" content="<%= entry.getValue()%>"/>
    <% } %>
</head>
<body>
    <% if (test && errors.isEmpty()) { %>

        <a href="<%= testPage%>" id="lbmessage" title="<fmt:message key="global.test" />" style="display:none;"></a>
        <script type="text/javascript">
            function loadMsg() {
                var lb = new lightbox(document.getElementById('lbmessage'));
                lb.activate();
            }
            setTimeout('loadMsg()', 250);
        </script>

    <% } %>

    <% if (initialSetup) { %>
    <h1><fmt:message key="setup.clearspace.profile" />: <span><fmt:message key="setup.clearspace.service.integration" /></span></h1>
    <% } %>

    <div id="jive-contentBox_stepbar">
        <span class="jive-stepbar_step"><strong><fmt:message key="setup.clearspace.service.connection_settings" /></strong></span>
    </div>

    <div class="jive-contentBox jive-contentBox_for-stepbar">
    <h2><span><fmt:message key="setup.clearspace.service.connection_settings" /></span></h2>

    <p><fmt:message key="setup.clearspace.service.description" /></p>

    <%  if (errors.size() > 0) { %>

    <div class="error">
        <% for (String error:errors.values()) { %>
            <%= error%><br/>
        <% } %>
    </div>

    <%  } %>

    <form action="<%= currentPage%>" method="post">
		<!-- BEGIN jive-contentBox_bluebox -->
		<div class="jive-contentBox_bluebox">
			<table border="0" cellpadding="0" cellspacing="2" width="100%">
			<tr>
			    <td colspan="4"><strong><fmt:message key="setup.clearspace.service" /></strong></td>
			</tr>
            <tr>
119
			    <td align="right" width="1%" nowrap="nowrap"><fmt:message key="setup.clearspace.service.uri" />:</td>
120 121 122 123
                <td width="1%">
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td width="1%" nowrap="nowrap">
124
                            <input type="text" name="uri" id="jiveCLEARSPACEuri" size="40" maxlength="255" value="<%= uri!=null?uri:"" %>">
125 126
                        </td>
                        <td width="99%">
127
                            <span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.clearspace.service.uri_help" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', 8000);"></span>
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
                        </td>
                    </tr>
                    </table>
                </td>
			</tr>
			<tr>
                <td align="right" width="1%" nowrap="nowrap"><fmt:message key="setup.clearspace.service.secret" />:</td>
                <td colspan="3">
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td width="1%" nowrap="nowrap">
                            <input type="password" name="sharedSecret" id="jiveCLEARSPACEsecret" size="22" maxlength="30" value="<%= sharedSecret!=null?sharedSecret:""%>">
                        </td>
                        <td width="99%">
                            <span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.clearspace.service.secret_help" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span>
                        </td>
                    </tr>
                    </table>
                </td>
			</tr>
			</table>
149
        </div>
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
		<!-- END jive-contentBox_bluebox -->

        <!-- BEGIN jive-buttons -->
		<div class="jive-buttons">

			<!-- BEGIN right-aligned buttons -->
			<div align="right">

                <input type="Submit" name="test" value="<fmt:message key="setup.clearspace.test" />" id="jive-setup-test" border="0">

                <input type="Submit" name="save" value="<fmt:message key="setup.clearspace.continue" />" id="jive-setup-save" border="0">
			</div>
			<!-- END right-aligned buttons -->

		</div>
		<!-- END jive-buttons -->

	</form>
    </div>
    <!-- END jive-contentBox -->

</body>
</html>