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());
%>
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
|
|
">
|
| |
|
|
|