All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.org.retep.xmpp.util.Role Maven / Gradle / Ivy

The newest version!
/*
 * 

Copyright (c) 1998-2009, Peter T Mount
* All rights reserved.

* *

* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. *

* *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *

* *

* You should have received a copy of the GNU General Public License along * with this program. If not, see . *

* *

* GNU GENERAL PUBLIC LICENSE - CLASSPATH EXCEPTION *

* *

* Linking this library statically or dynamically with other modules * is making a combined work based on this library. Thus, the terms * and conditions of the GNU General Public License cover the whole * combination. *

* *

* As a special exception, the copyright holders of this library give * you permission to link this library with independent modules to * produce an executable, regardless of the license terms of these * independent modules, and to copy and distribute the resulting * executable under terms of your choice, provided that you also meet, * for each linked independent module, the terms and conditions of the * license of that module. *

* *

* An independent module is a module which is either not derived from or based * on this library, or a module who's classes extend those within this library * as part of the implementation of the library. *

* *

* If you modify this library, you may extend this exception to your version * of the library, but you are not obligated to do so. If you do not wish to * do so, delete this exception statement from your version. *

*/ package uk.org.retep.xmpp.util; /** *

XEP-45 5.1 Roles

* *

* In XEP-0045 5.1.1 Privileges * we have specific roles defined and implemented by {@link Role}. * For the most part, roles exist in a hierarchy. For instance, a participant * can do anything a visitor can do, and a moderator can do anything a * participant can do. Each role has privileges not possessed by the next-lowest * role; these privileges are specified in the following table as defaults * (an implementation MAY provide configuration options that override these * defaults). *

* * * * * * * * * * * * * * * * *
PrivilegeNoneVisitorParticipantModerator
Present in RoomNoYesYesYes
Receive MessagesNoYesYesYes
Receive Occupant PresenceNoYesYesYes
Presence Broadcasted to RoomNoYes*YesYes
Change Availability StatusNoYesYesYes
Change Room NicknameNoYes*YesYes
Send Private MessagesNoYes*YesYes
Invite Other UsersNoYes*Yes*Yes
Send Messages to AllNoNo**YesYes
Modify SubjectNoNo*Yes*Yes
Kick Participants and VisitorsNoNoNoYes
Grant VoiceNoNoNoYes
Revoke VoiceNoNoNoYes***
* *

* Default; configuration settings MAY modify this privilege.

*

** An implementation MAY grant voice by default to visitors in unmoderated rooms.

*

*** A moderator MUST NOT be able to revoke voice privileges from an admin or owner.

* * @author peter */ public enum Role { NONE( null ), VISITOR( "visitor" ) { @Override public boolean isPresentInRoom() { return true; } @Override public boolean isReceiveMessages() { return true; } @Override public boolean isReceiveOccupantPresence() { return true; } @Override public boolean isPresenceBroadcastToRoom() { return true; } @Override public boolean isChangeAvailabilityStatus() { return true; } @Override public boolean isChangeRoomNickName() { return true; } @Override public boolean isSendPrivateMessages() { return true; } @Override public boolean isInviteOtherUsers() { return true; } }, PARTICIPANT( "participant" ) { @Override public boolean isPresentInRoom() { return true; } @Override public boolean isReceiveMessages() { return true; } @Override public boolean isReceiveOccupantPresence() { return true; } @Override public boolean isPresenceBroadcastToRoom() { return true; } @Override public boolean isChangeAvailabilityStatus() { return true; } @Override public boolean isChangeRoomNickName() { return true; } @Override public boolean isSendPrivateMessages() { return true; } @Override public boolean isInviteOtherUsers() { return true; } @Override public boolean isSendMessagesToAll() { return true; } @Override public boolean isModifySubject() { return true; } }, MODERATOR( "moderator" ) { @Override public boolean isPresentInRoom() { return true; } @Override public boolean isReceiveMessages() { return true; } @Override public boolean isReceiveOccupantPresence() { return true; } @Override public boolean isPresenceBroadcastToRoom() { return true; } @Override public boolean isChangeAvailabilityStatus() { return true; } @Override public boolean isChangeRoomNickName() { return true; } @Override public boolean isSendPrivateMessages() { return true; } @Override public boolean isInviteOtherUsers() { return true; } @Override public boolean isSendMessagesToAll() { return true; } @Override public boolean isModifySubject() { return true; } @Override public boolean isKickParticipantsAndVisitors() { return true; } @Override public boolean isGrantVoice() { return true; } @Override public boolean isRevokeVoice() { return true; } @Override public Role grantVoice( final Role oldRole ) { if( oldRole == VISITOR ) { return PARTICIPANT; } else { return oldRole; } } @Override public Role revokeVoice( Role oldRole ) { if( oldRole == PARTICIPANT ) { return VISITOR; } else { return oldRole; } } }; private final String role; private Role( final String role ) { this.role = role; } /** * The String representation of this role * @return */ public String getRole() { return role; } /** * Can be present in a room * @return */ public boolean isPresentInRoom() { return false; } /** * Can receive messages * @return */ public boolean isReceiveMessages() { return false; } /** * Can receive presence message of other occupants * @return */ public boolean isReceiveOccupantPresence() { return false; } /** * Will presence be broadcast to other occupants on entry * @return */ public boolean isPresenceBroadcastToRoom() { return false; } /** * Can change availability status * @return */ public boolean isChangeAvailabilityStatus() { return false; } /** * Can change nickname * @return */ public boolean isChangeRoomNickName() { return false; } /** * Can send private messages * @return */ public boolean isSendPrivateMessages() { return false; } /** * Can invite other users * @return */ public boolean isInviteOtherUsers() { return false; } /** * Can send messages to all occupants * @return */ public boolean isSendMessagesToAll() { return false; } /** * Can modify room subject * @return */ public boolean isModifySubject() { return false; } /** * Can kick users with {@link #PARTICIPANT} or {@link #VISITOR} roles * @return */ public boolean isKickParticipantsAndVisitors() { return false; } /** * Can grant voice of a {@link #VISITOR} raising them to {@link #PARTICIPANT} * @return */ public boolean isGrantVoice() { return false; } /** * Grant voice from one role to another if this Role permits this action. * @param oldRole The current Role * @return the new Role or the same if not possible from this role */ public Role grantVoice( final Role oldRole ) { return oldRole; } /** * Can revoke voice of a {@link #PARTICIPANT} raising them to {@link #VISITOR} * @return */ public boolean isRevokeVoice() { return false; } /** * Revoke voice from one role to another if this Role permits this action. * *

* Important This method only accounts for the Role * transition. It does not handle the rule: * A moderator MUST NOT be able to revoke voice privileges from an admin * or owner. * That rule is implemented by the code using this method. *

* * @param oldRole The current Role * @return the new Role or the same if not possible from this role */ public Role revokeVoice( final Role oldRole ) { return oldRole; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy