ldap-group.jspf 10.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
<%@ page import="org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.ParamUtils" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%@ page import="org.jivesoftware.openfire.ldap.LdapManager" %>

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

<%
    // Get parameters

    String serverType = ParamUtils.getParameter(request, "serverType");
    // Server type should never be null, but if it is, assume "other"
    if (serverType == null) {
        serverType = "other";
    }

    LdapManager manager = LdapManager.getInstance();

    // Determine the right default values based on the the server type.
    String defaultGroupNameField = JiveGlobals.getXMLProperty("ldap.groupNameField");
    String defaultGroupMemberField = JiveGlobals.getXMLProperty("ldap.groupMemberField");
    String defaultGroupDescriptionField = JiveGlobals.getXMLProperty("ldap.groupDescriptionField");
    String posixModeString = JiveGlobals.getXMLProperty("ldap.posixMode");
    boolean defaultPosixMode = Boolean.parseBoolean(posixModeString);
    String defaultGroupSearchFilter = JiveGlobals.getXMLProperty("ldap.groupSearchFilter");

    if (serverType.equals("activedirectory")) {
        if (defaultGroupNameField == null) {
            defaultGroupNameField = "cn";
        }
        if (defaultGroupMemberField == null) {
            defaultGroupMemberField = "member";
        }
        if (defaultGroupDescriptionField == null) {
            defaultGroupDescriptionField = "description";
        }
        if (posixModeString == null) {
            defaultPosixMode = false;
        }
        if (defaultGroupSearchFilter == null) {
            defaultGroupSearchFilter = "(objectClass=group)";
        }
    } else {
        if (defaultGroupNameField == null) {
            defaultGroupNameField = "cn";
        }
        if (defaultGroupMemberField == null) {
            defaultGroupMemberField = "member";
        }
        if (defaultGroupDescriptionField == null) {
            defaultGroupDescriptionField = "description";
        }
        if (posixModeString == null) {
            defaultPosixMode = false;
        }
    }

    String groupNameField = ParamUtils.getParameter(request, "groupNameField");
    if (groupNameField == null) {
        groupNameField = defaultGroupNameField;
    }
    String groupMemberField = ParamUtils.getParameter(request, "groupMemberField");
    if (groupMemberField == null) {
        groupMemberField = defaultGroupMemberField;
    }
    String groupDescriptionField = ParamUtils.getParameter(request, "groupDescriptionField");
    if (groupDescriptionField == null) {
        groupDescriptionField = defaultGroupDescriptionField;
    }
    String posixModeParam = ParamUtils.getParameter(request, "posixMode");
    boolean posixMode;
    if (posixModeParam == null) {
        posixMode = defaultPosixMode;
    } else {
        posixMode = Boolean.parseBoolean(posixModeParam);
    }
    String groupSearchFilter = ParamUtils.getParameter(request, "groupSearchFilter");
    if (groupSearchFilter == null) {
        groupSearchFilter = defaultGroupSearchFilter;
    }

    boolean save = request.getParameter("save") != null;
    boolean doTest = request.getParameter("test") != null;
    if (save || doTest) {
        // Save information in the session so we can use it in testing pages during setup
        Map<String, String> settings = new HashMap<String, String>();
        settings.put("ldap.groupNameField", groupNameField);
        settings.put("ldap.groupMemberField", groupMemberField);
        settings.put("ldap.groupDescriptionField", groupDescriptionField);
        settings.put("ldap.posixMode", Boolean.toString(posixMode));
        settings.put("ldap.groupSearchFilter", groupSearchFilter);
        session.setAttribute("ldapGroupSettings", settings);

        if (save) {
            if (groupNameField != null) {
                manager.setGroupNameField(groupNameField);
            }
            if (groupMemberField != null) {
                manager.setGroupMemberField(groupMemberField);
            }
            if (groupDescriptionField != null) {
                manager.setGroupDescriptionField(groupDescriptionField);
            }
            manager.setPosixMode(posixMode);
            if (groupSearchFilter != null) {
                manager.setGroupSearchFilter(groupSearchFilter);
            }

            // Enable the LDAP auth provider. The LDAP user provider will be enabled on the next step.
            JiveGlobals.setXMLProperty("provider.group.className",
                    "org.jivesoftware.openfire.ldap.LdapGroupProvider");

            // Redirect
            response.sendRedirect(nextPage);
            return;
        }
    }
%>
<html>
<head>
    <title><fmt:message key="setup.ldap.title" /></title>
    <% for (Map.Entry<String, String> entry : meta.entrySet()) { %>
    <meta name="<%= entry.getKey()%>" content="<%= entry.getValue()%>"/>
    <% } %>
</head>

<body>
    <% if (doTest) {
        StringBuilder sb = new StringBuilder();
        sb.append(testPage);
        sb.append("?serverType=").append(serverType);
    %>
        <a href="<%= sb.toString()%>" 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.ldap.profile" />: <span><fmt:message key="setup.ldap.group_mapping" /></span></h1>
    <% } %>

	<!-- BEGIN jive-contentBox_stepbar -->
	<div id="jive-contentBox_stepbar">
		<span class="jive-stepbar_step"><em>1. <fmt:message key="setup.ldap.connection_settings" /></em></span>
		<span class="jive-stepbar_step"><em>2. <fmt:message key="setup.ldap.user_mapping" /></em></span>
		<span class="jive-stepbar_step"><strong>3. <fmt:message key="setup.ldap.group_mapping" /></strong></span>
	</div>
	<!-- END jive-contentBox-stepbar -->

	<!-- BEGIN jive-contentBox -->
	<div class="jive-contentBox jive-contentBox_for-stepbar">

	<h2><fmt:message key="setup.ldap.step_three" />: <span><fmt:message key="setup.ldap.group_mapping" /></span></h2>
	<p><fmt:message key="setup.ldap.group.description" /></p>

	<form action="" method="get">
		<!-- BEGIN jive-contentBox_bluebox -->
		<div class="jive-contentBox_bluebox">

			<table border="0" cellpadding="0" cellspacing="2">
			<tr>
			<td colspan="2"><strong><fmt:message key="setup.ldap.group_mapping" /></strong></td>
			</tr>
			<tr>
			<td align="right"><fmt:message key="setup.ldap.group.name_field" />:</td>
			<td><input type="text" name="groupNameField" id="jiveLDAPgroupname" size="22" maxlength="50" value="<%= groupNameField!=null?groupNameField:""%>"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.group.name_field_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span></td>
			</tr>
			<tr>
			<td align="right"><fmt:message key="setup.ldap.group.member_field" />:</td>
			<td><input type="text" name="groupMemberField" id="jiveLDAPgroupmember" size="22" maxlength="50" value="<%= groupMemberField!=null?groupMemberField:""%>"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.group.member_field_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span></td>
			</tr>
			<tr>
			<td align="right"><fmt:message key="setup.ldap.group.description_field" />:</td>
			<td><input type="text" name="groupDescriptionField" id="jiveLDAPgroupdesc" size="22" maxlength="50" value="<%= groupDescriptionField!=null?groupDescriptionField:""%>"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.group.description_field_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span></td>
			</tr>
			</table>

			<!-- BEGIN jiveAdvancedButton -->
			<div class="jiveAdvancedButton jiveAdvancedButtonTopPad">
				<a href="#" onclick="togglePanel(jiveAdvanced); return false;" id="jiveAdvancedLink"><fmt:message key="setup.ldap.advanced" /></a>
			</div>
			<!-- END jiveAdvancedButton -->

			<!-- BEGIN jiveAdvancedPanelu (advanced user mapping settings) -->
				<div class="jiveadvancedPanelu" id="jiveAdvanced" style="display: none;">
					<div>
						<table border="0" cellpadding="0" cellspacing="2">
						<tr>
						<td align="right"><fmt:message key="setup.ldap.group.posix" />:</td>
						<td><span style="float: left;">
							<input type="radio" name="posixMode" value="true" style="float: none;" id="posix1" <% if(posixMode) {%>checked<% } %>><label for="posix1"> <fmt:message key="global.yes" />  </label>
							<input type="radio" name="posixMode" value="false" style="float: none;" id="posix2" <% if(!posixMode) {%>checked<% } %>><label for="posix2"> <fmt:message key="global.no" />  </label>
							</span>
							<span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.group.posix_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span></td>
						</tr>
						<tr>
						<td align="right"><fmt:message key="setup.ldap.group.filter" /></td>
						<td><input type="text" name="groupSearchFilter" value="<%= groupSearchFilter!=null?groupSearchFilter:""%>" id="jiveLDAPgroupsearchfilter" size="22" maxlength="250"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.group.filter_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span></td>
						</tr>
						</table>
					</div>
				</div>
			<!-- END jiveAdvancedPanelu (advanced user mapping settings) -->

		</div>
		<!-- 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.ldap.test" />" id="jive-setup-test" border="0">

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

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

	</form>

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



</body>
</html>