01: /*
02: * Copyright 2002,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.catalina.users;
18:
19: import org.apache.catalina.UserDatabase;
20:
21: /**
22: * <p>Concrete implementation of {@link Role} for the
23: * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p>
24: *
25: * @author Craig R. McClanahan
26: * @version $Revision: 1.3 $ $Date: 2004/02/27 14:58:50 $
27: * @since 4.1
28: */
29:
30: public class MemoryRole extends AbstractRole {
31:
32: // ----------------------------------------------------------- Constructors
33:
34: /**
35: * Package-private constructor used by the factory method in
36: * {@link MemoryUserDatabase}.
37: *
38: * @param database The {@link MemoryUserDatabase} that owns this role
39: * @param rolename Role name of this role
40: * @param description Description of this role
41: */
42: MemoryRole(MemoryUserDatabase database, String rolename,
43: String description) {
44:
45: super ();
46: this .database = database;
47: setRolename(rolename);
48: setDescription(description);
49:
50: }
51:
52: // ----------------------------------------------------- Instance Variables
53:
54: /**
55: * The {@link MemoryUserDatabase} that owns this role.
56: */
57: protected MemoryUserDatabase database = null;
58:
59: // ------------------------------------------------------------- Properties
60:
61: /**
62: * Return the {@link UserDatabase} within which this role is defined.
63: */
64: public UserDatabase getUserDatabase() {
65:
66: return (this .database);
67:
68: }
69:
70: // --------------------------------------------------------- Public Methods
71:
72: /**
73: * <p>Return a String representation of this role in XML format.</p>
74: */
75: public String toString() {
76:
77: StringBuffer sb = new StringBuffer("<role rolename=\"");
78: sb.append(rolename);
79: sb.append("\"");
80: if (description != null) {
81: sb.append(" description=\"");
82: sb.append(description);
83: sb.append("\"");
84: }
85: sb.append("/>");
86: return (sb.toString());
87:
88: }
89:
90: }
|