%@ page contentType="text/html; charset=UTF-8" %>
<%--
-
- Copyright (C) 2004-2008 Jive Software, 2017-2025 Ignite Realtime Foundation. All rights reserved.
-
- 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.
--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="admin" uri="admin" %>
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.openfire.*,
java.util.HashMap,
java.util.Map"
errorPage="error.jsp"
%>
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters
boolean update = request.getParameter("update") != null;
int kickPolicy = ParamUtils.getIntParameter(request,"kickPolicy",Integer.MAX_VALUE);
int kickValue = ParamUtils.getIntParameter(request,"kickValue",-2);
if (kickPolicy == -2) {
kickPolicy = webManager.getSessionManager().getConflictKickLimit();
}
// Update the session kick policy if requested
Map errors = new HashMap<>();
Cookie csrfCookie = CookieUtils.getCookie(request, "csrf");
String csrfParam = ParamUtils.getParameter(request, "csrf");
if (update) {
if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) {
update = false;
errors.put("csrf", "CSRF Failure!");
}
}
csrfParam = StringUtils.randomString(15);
CookieUtils.setCookie(request, response, "csrf", csrfParam, -1);
pageContext.setAttribute("csrf", csrfParam);
if (update) {
// Validate params
if (kickPolicy != 0 && kickPolicy != 1 && kickPolicy != SessionManager.NEVER_KICK) {
if (kickValue <= 1) {
errors.put("kickValue","");
}
}
// If no errors, continue:
if (errors.isEmpty()) {
if (kickPolicy != 0 && kickPolicy != 1 && kickPolicy != SessionManager.NEVER_KICK) {
webManager.getSessionManager().setConflictKickLimit(kickValue);
}
else {
webManager.getSessionManager().setConflictKickLimit(kickPolicy);
}
%>
<%
}
}
// Update variable values
kickPolicy = webManager.getSessionManager().getConflictKickLimit();
%>