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