Commit e6e13842 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added new property "roomCreationRestricted".


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@437 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7b822ec1
......@@ -12,6 +12,7 @@
package org.jivesoftware.messenger.muc;
import java.util.List;
import java.util.Collection;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.user.UserNotFoundException;
......@@ -42,12 +43,12 @@ public interface MultiUserChatServer {
void setServiceName(String name);
/**
* Returns the list of JIDs that are system administrators of the MUC service. A sysadmin has
* Returns the collection of JIDs that are system administrators of the MUC service. A sysadmin has
* the same permissions as a room owner.
*
* @return a list of bare JIDs.
*/
List getSysadmins();
Collection<String> getSysadmins();
/**
* Adds a new system administrator of the MUC service. A sysadmin has the same permissions as
......@@ -65,12 +66,28 @@ public interface MultiUserChatServer {
void removeSysadmin(String userJID);
/**
* Returns the list of JIDs that are allowed to create MUC rooms. An empty list means that
* Returns false if anyone can create rooms or true if only the returned JIDs in
* <code>getUsersAllowedToCreate</code> are allowed to create rooms.
*
* @return true if only some JIDs are allowed to create rooms.
*/
boolean isRoomCreationRestricted();
/**
* Sets if anyone can create rooms or if only the returned JIDs in
* <code>getUsersAllowedToCreate</code> are allowed to create rooms.
*
* @param roomCreationRestricted whether anyone can create rooms or not.
*/
void setRoomCreationRestricted(boolean roomCreationRestricted);
/**
* Returns the collection of JIDs that are allowed to create MUC rooms. An empty list means that
* anyone can create a room.
*
* @return a list of bare JIDs.
*/
List getUsersAllowedToCreate();
Collection<String> getUsersAllowedToCreate();
/**
* Adds a new user to the list of JIDs that are allowed to create MUC rooms.
......
......@@ -132,17 +132,24 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
*/
private Timer timer = new Timer();
/**
* Returns the permission policy for creating rooms. A true value means that not anyone can
* create a room, only the JIDs listed in <code>allowedToCreate</code> are allowed to create
* rooms.
*/
private boolean roomCreationRestricted = false;
/**
* Bare jids of users that are allowed to create MUC rooms. An empty list means that anyone can
* create a room.
*/
private List allowedToCreate = new LinkedList();
private Collection<String> allowedToCreate = new LinkedList<String>();
/**
* Bare jids of users that are system administrators of the MUC service. A sysadmin has the same
* permissions as a room owner.
*/
private List sysadmins = new LinkedList();
private Collection<String> sysadmins = new LinkedList<String>();
/**
* Queue that holds the messages to log for the rooms that need to log their conversations.
......@@ -265,7 +272,7 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
// Check whether the room was just created or loaded from the database
if (!room.isPersistent()) {
// Room creation is always allowed for sysadmin
if (allowedToCreate.size() > 0 &&
if (isRoomCreationRestricted() &&
!sysadmins.contains(userjid.toBareStringPrep())) {
// The room creation is only allowed for certain JIDs
if (!allowedToCreate.contains(userjid.toBareStringPrep())) {
......@@ -415,11 +422,11 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
JiveGlobals.setProperty("xmpp.muc.service", name);
}
public List getUsersAllowedToCreate() {
public Collection<String> getUsersAllowedToCreate() {
return allowedToCreate;
}
public List getSysadmins() {
public Collection<String> getSysadmins() {
return sysadmins;
}
......@@ -439,6 +446,15 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
JiveGlobals.setProperty("xmpp.muc.sysadmin.jid", fromArray(jids));
}
public boolean isRoomCreationRestricted() {
return roomCreationRestricted;
}
public void setRoomCreationRestricted(boolean roomCreationRestricted) {
this.roomCreationRestricted = roomCreationRestricted;
JiveGlobals.setProperty("xmpp.muc.create.anyone", Boolean.toString(roomCreationRestricted));
}
public void addUserAllowedToCreate(String userJID) {
// Update the list of allowed JIDs to create MUC rooms. Since we are updating the instance
// variable there is no need to restart the service
......@@ -474,6 +490,8 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
sysadmins.add(jids[i].trim().toLowerCase());
}
}
roomCreationRestricted =
Boolean.parseBoolean(JiveGlobals.getProperty("xmpp.muc.create.anyone", "false"));
// Load the list of JIDs that are allowed to create a MUC room
property = JiveGlobals.getProperty("xmpp.muc.create.jid");
if (property != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment