<%@ page contentType="text/html; charset=UTF-8" %> <%-- - - Copyright (C) 2004-2008 Jive Software, 2020-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. --%> <%@ page import="java.net.URLEncoder, java.nio.charset.StandardCharsets, java.util.*, org.jivesoftware.openfire.muc.MUCRoom, org.jivesoftware.openfire.muc.spi.FMUCHandler, org.jivesoftware.openfire.muc.spi.FMUCMode, org.jivesoftware.util.CookieUtils, org.jivesoftware.util.ParamUtils, org.jivesoftware.util.StringUtils, org.slf4j.LoggerFactory, org.xmpp.packet.JID" errorPage="error.jsp" %> <%@ 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" %> <%@ taglib uri="admin" prefix="admin" %> <% webManager.init(request, response, session, application, out); %> <% // Get parameters final JID roomJID = new JID(ParamUtils.getParameter(request,"roomJID")); final String roomName = roomJID.getNode(); final String outboundJoinPeerString = ParamUtils.getParameter(request, "roomconfig_fmuc_outbound_jid", true); final boolean fmucEnabled = ParamUtils.getBooleanParameter(request, "fmuc-enabled"); String stopSessionString = ParamUtils.getParameter(request,"stopSession", true); JID stopSession = stopSessionString != null && !stopSessionString.isEmpty() ? new JID(stopSessionString) : null; Cookie csrfCookie = CookieUtils.getCookie(request, "csrf"); String csrfParam = ParamUtils.getParameter(request, "csrf"); boolean save = ParamUtils.getBooleanParameter(request,"save"); Map errors = new HashMap<>(); if (save || stopSession != null) { if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) { save = false; stopSession = null; errors.put("csrf", "CSRF Failure!"); } } csrfParam = StringUtils.randomString(15); CookieUtils.setCookie(request, response, "csrf", csrfParam, -1); pageContext.setAttribute("csrf", csrfParam); // Load the room object MUCRoom room = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomName); if (room == null) { // The requested room name does not exist so return to the list of the existing rooms response.sendRedirect("muc-room-summary.jsp?roomJID="+URLEncoder.encode(roomJID.toBareJID(), StandardCharsets.UTF_8)); return; } final FMUCHandler fmucHandler = room.getFmucHandler(); if (stopSession != null) { boolean stoppedSomething = false; final FMUCHandler.OutboundJoin outboundJoin = fmucHandler.getOutboundJoin(); if ( outboundJoin != null && outboundJoin.getPeer().equals( stopSession )) { fmucHandler.stopOutbound(); stoppedSomething = true; webManager.logEvent("closed FMUC outbound join to " + stopSession, null); } final FMUCHandler.OutboundJoinProgress outboundJoinProgress = fmucHandler.getOutboundJoinProgress(); if ( outboundJoinProgress != null && outboundJoinProgress.getPeer().equals(stopSession )) { fmucHandler.abortOutboundJoinProgress(); stoppedSomething = true; webManager.logEvent("closed FMUC outbound join attempt (in progress) to " + stopSession, null); } final JID finalStopSession = stopSession; if (fmucHandler.getInboundJoins().stream().anyMatch(j -> j.getPeer().equals(finalStopSession))) { fmucHandler.stopInbound(stopSession); stoppedSomething = true; webManager.logEvent("closed FMUC inbound join from " + stopSession, null); } webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).syncChatRoom(room); if (stoppedSomething) { response.sendRedirect("muc-room-federation.jsp?closeSuccess=true&roomJID=" + URLEncoder.encode(room.getJID().toBareJID(), StandardCharsets.UTF_8)); } else { response.sendRedirect("muc-room-federation.jsp?closeError=true&roomJID=" + URLEncoder.encode(room.getJID().toBareJID(), StandardCharsets.UTF_8)); } return; } if (save) { // Validate input JID outboundJoinPeer = null; if (outboundJoinPeerString != null && !outboundJoinPeerString.isEmpty()) { try { outboundJoinPeer = new JID( outboundJoinPeerString ); if ( outboundJoinPeer.getNode() == null ) { errors.put("outboundJoinPeer", "no_node"); } if ( outboundJoinPeer.getResource() != null ) { errors.put("outboundJoinPeer", "no_bare_jid"); } } catch (IllegalArgumentException e) { errors.put("outboundJoinPeer", "invalid_jid"); outboundJoinPeer = null; } } // Apply changes (if there are no errors) if ( errors.isEmpty() ) { try { room.setFmucEnabled(fmucEnabled); room.setFmucOutboundNode(outboundJoinPeer); room.setFmucOutboundMode(FMUCMode.MasterMaster); // We currently do not support another mode than master-master. room.getFmucHandler().applyConfigurationChanges(); room.saveToDB(); webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).syncChatRoom(room); } catch ( Exception e ) { LoggerFactory.getLogger("muc-room-federation.jsp").warn("An exception occurred while trying to apply an FMUC config change to room {}", roomJID, e ); errors.put( "fmuchandler", e.getMessage() ); } // Log the event webManager.logEvent("Updated FMUC settings for MUC room "+roomName, "FMUC enabled = " + room.isFmucEnabled() + ",\noutbound peer = "+(room.getFmucOutboundNode() == null ? "(none)" :room.getFmucOutboundNode())+",\noutbound mode = "+(room.getFmucOutboundMode() == null ? "(none)" :room.getFmucOutboundMode())); response.sendRedirect("muc-room-federation.jsp?success=true&roomJID="+URLEncoder.encode(room.getJID().toBareJID(), StandardCharsets.UTF_8)); return; } } pageContext.setAttribute( "killSwitchEnabled", !FMUCHandler.FMUC_ENABLED.getValue() ); pageContext.setAttribute( "errors", errors ); pageContext.setAttribute( "room", room ); pageContext.setAttribute( "roomJIDBare", roomJID.toBareJID() ); pageContext.setAttribute( "fmucOutboundJID", room.getFmucOutboundNode() == null ? "" : room.getFmucOutboundNode().toString()); %> <fmt:message key="muc.room.federation.title"/>

Successfully closed a session. Unable to close session. : ()
/ /

:
">

Currently, federation with these MUCs has been established.

Remote MUC address Federation direction Occupants on node Close
(Currently, there is no ongoing federation)
Outbound, federation being established... ">
Outbound (mode: )   ">
     
Inbound   ">