001: /**
002: * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, version 2.1, dated February 1999.
003: *
004: * This program is free software; you can redistribute it and/or modify
005: * it under the terms of the latest version of the GNU Lesser General
006: * Public License as published by the Free Software Foundation;
007: *
008: * This program is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: * GNU Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public License
014: * along with this program (LICENSE.txt); if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
016: */package org.jamwiki.model;
017:
018: import org.acegisecurity.GrantedAuthorityImpl;
019: import org.jamwiki.utils.WikiLogger;
020:
021: /**
022: * Provides an object representing a Wiki role and implementing the Acegi
023: * <code>GrantedAuthority</code> interface.
024: */
025: public class Role extends GrantedAuthorityImpl {
026:
027: private static final WikiLogger logger = WikiLogger
028: .getLogger(Role.class.getName());
029: private String description = null;
030:
031: /**
032: * ROLE_ADMIN gives permission to perform wiki maintenance tasks not
033: * available to normal users. It does not allow the ability to change
034: * system settings.
035: */
036: public static final Role ROLE_ADMIN = new Role("ROLE_ADMIN");
037: /**
038: * ROLE_ANONYMOUS is not stored in the database but is instead
039: * automatically assigned to all non-logged in users.
040: */
041: public static final Role ROLE_ANONYMOUS = new Role("ROLE_ANONYMOUS");
042: public static final Role ROLE_EDIT_EXISTING = new Role(
043: "ROLE_EDIT_EXISTING");
044: public static final Role ROLE_EDIT_NEW = new Role("ROLE_EDIT_NEW");
045: /**
046: * ROLE_EMBEDDED is meant for use with installations that perform
047: * authentication and user management in an external system, such as LDAP.
048: * This role is not created during JAMWiki setup, and is not available
049: * from the Special:Roles interface; instead it should be assigned by the
050: * LDAP or other system that performs user authentication.
051: */
052: public static final Role ROLE_EMBEDDED = new Role("ROLE_EMBEDDED");
053: public static final Role ROLE_MOVE = new Role("ROLE_MOVE");
054: /**
055: * ROLE_NO_ACCOUNT is meant for use with installations that do not allow
056: * user account management from within JAMWiki. This role is not created
057: * during JAMWiki setup, and is not available from the Special:Roles
058: * interface; instead it should be assigned by the LDAP or other system
059: * that allows account management.
060: */
061: public static final Role ROLE_NO_ACCOUNT = new Role(
062: "ROLE_NO_ACCOUNT");
063: /** ROLE_SYSADMIN provides the ability to change system settings. */
064: public static final Role ROLE_SYSADMIN = new Role("ROLE_SYSADMIN");
065: public static final Role ROLE_TRANSLATE = new Role("ROLE_TRANSLATE");
066: public static final Role ROLE_UPLOAD = new Role("ROLE_UPLOAD");
067: /**
068: * ROLE_USER is not stored in the database but is instead automatically
069: * assigned to all logged in users.
070: */
071: public static final Role ROLE_USER = new Role("ROLE_USER");
072: public static final Role ROLE_VIEW = new Role("ROLE_VIEW");
073:
074: /**
075: *
076: */
077: public Role(String role) {
078: super ((role == null) ? null : role.toUpperCase());
079: }
080:
081: /**
082: *
083: */
084: public String getDescription() {
085: return this .description;
086: }
087:
088: /**
089: *
090: */
091: public void setDescription(String description) {
092: this .description = description;
093: }
094:
095: /**
096: * Two roles are equal if the role names are the same.
097: */
098: public boolean equals(Role role) {
099: if (this .getAuthority() == null && role != null
100: && role.getAuthority() == null) {
101: return true;
102: }
103: return (this.getAuthority() != null && role != null && this
104: .getAuthority().equals(role.getAuthority()));
105: }
106: }
|