<%@ page contentType="text/html; charset=UTF-8" %> <%-- - - Copyright (C) 2005-2008 Jive Software, 2016-2022 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. --%> <%@ page import="org.jivesoftware.util.ParamUtils" %> <%@ page import="org.jivesoftware.util.CookieUtils" %> <%@ page import="org.jivesoftware.util.StringUtils" %> <%@ page import="org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy" %> <%@ page import="java.util.HashMap" %> <%@ page import="java.util.Map" %> <%@ page import="org.jivesoftware.openfire.XMPPServer" %> <%@ page import="org.jivesoftware.util.JiveGlobals" %> <%@ taglib uri="admin" prefix="admin" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <% webManager.init( request, response, session, application, out ); %> <% Map errors = new HashMap<>(); FileTransferProxy transferProxy = XMPPServer.getInstance().getFileTransferProxy(); boolean isUpdated = request.getParameter( "update" ) != null; boolean isProxyEnabled = ParamUtils.getBooleanParameter( request, "proxyEnabled" ); String hardcodedAddress = ParamUtils.getParameter( request, "hardcodedAddress" ); int port = ParamUtils.getIntParameter( request, "port", 0 ); Cookie csrfCookie = CookieUtils.getCookie( request, "csrf" ); String csrfParam = ParamUtils.getParameter( request, "csrf" ); if ( isUpdated ) { if ( csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals( csrfParam ) ) { isUpdated = false; errors.put( "csrf", "CSRF Failure!" ); } } csrfParam = StringUtils.randomString( 15 ); CookieUtils.setCookie( request, response, "csrf", csrfParam, -1 ); pageContext.setAttribute( "csrf", csrfParam ); if ( isUpdated ) { if ( hardcodedAddress != null && !hardcodedAddress.matches( "^[A-Za-z0-9-.]+$" ) ) { errors.put( "address", "" ); } if ( port <= 0 ) { errors.put( "port", "" ); } if ( errors.isEmpty() ) { JiveGlobals.setProperty( "xmpp.proxy.externalip", hardcodedAddress ); if ( isProxyEnabled ) { transferProxy.setProxyPort( port ); } transferProxy.enableFileTransferProxy( isProxyEnabled ); // Log the event webManager.logEvent( "edited file transfer proxy settings", "port = " + port + "\nhardcodedAddress = " + hardcodedAddress + "\nenabled = " + isProxyEnabled ); } } if ( errors.isEmpty() ) { port = transferProxy.getProxyPort(); } else { isUpdated = false; if ( port == 0 ) { port = transferProxy.getProxyPort(); } } pageContext.setAttribute( "errors", errors ); pageContext.setAttribute( "isUpdated", isUpdated ); pageContext.setAttribute( "port", port ); pageContext.setAttribute( "hardcodedAddress", JiveGlobals.getProperty( "xmpp.proxy.externalip" ) ); pageContext.setAttribute( "fileTransferProxy", XMPPServer.getInstance().getFileTransferProxy() ); %> <fmt:message key="filetransferproxy.settings.title"/>

: ()

">