001: /*
002: * Copyright 2002,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina.users;
018:
019: import java.util.Iterator;
020:
021: import org.apache.catalina.Group;
022: import org.apache.catalina.Role;
023: import org.apache.catalina.UserDatabase;
024:
025: /**
026: * <p>Convenience base class for {@link Group} implementations.</p>
027: *
028: * @author Craig R. McClanahan
029: * @version $Revision: 1.3 $ $Date: 2004/02/27 14:58:50 $
030: * @since 4.1
031: */
032:
033: public abstract class AbstractGroup implements Group {
034:
035: // ----------------------------------------------------- Instance Variables
036:
037: /**
038: * The description of this group.
039: */
040: protected String description = null;
041:
042: /**
043: * The group name of this group.
044: */
045: protected String groupname = null;
046:
047: // ------------------------------------------------------------- Properties
048:
049: /**
050: * Return the description of this group.
051: */
052: public String getDescription() {
053:
054: return (this .description);
055:
056: }
057:
058: /**
059: * Set the description of this group.
060: *
061: * @param description The new description
062: */
063: public void setDescription(String description) {
064:
065: this .description = description;
066:
067: }
068:
069: /**
070: * Return the group name of this group, which must be unique
071: * within the scope of a {@link UserDatabase}.
072: */
073: public String getGroupname() {
074:
075: return (this .groupname);
076:
077: }
078:
079: /**
080: * Set the group name of this group, which must be unique
081: * within the scope of a {@link UserDatabase}.
082: *
083: * @param groupname The new group name
084: */
085: public void setGroupname(String groupname) {
086:
087: this .groupname = groupname;
088:
089: }
090:
091: /**
092: * Return the set of {@link Role}s assigned specifically to this group.
093: */
094: public abstract Iterator getRoles();
095:
096: /**
097: * Return the {@link UserDatabase} within which this Group is defined.
098: */
099: public abstract UserDatabase getUserDatabase();
100:
101: /**
102: * Return the set of {@link User}s that are members of this group.
103: */
104: public abstract Iterator getUsers();
105:
106: // --------------------------------------------------------- Public Methods
107:
108: /**
109: * Add a new {@link Role} to those assigned specifically to this group.
110: *
111: * @param role The new role
112: */
113: public abstract void addRole(Role role);
114:
115: /**
116: * Is this group specifically assigned the specified {@link Role}?
117: *
118: * @param role The role to check
119: */
120: public abstract boolean isInRole(Role role);
121:
122: /**
123: * Remove a {@link Role} from those assigned to this group.
124: *
125: * @param role The old role
126: */
127: public abstract void removeRole(Role role);
128:
129: /**
130: * Remove all {@link Role}s from those assigned to this group.
131: */
132: public abstract void removeRoles();
133:
134: // ------------------------------------------------------ Principal Methods
135:
136: /**
137: * Make the principal name the same as the group name.
138: */
139: public String getName() {
140:
141: return (getGroupname());
142:
143: }
144:
145: }
|