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