%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.om.security.SecurityObject |
|
|
1 | package org.apache.turbine.om.security; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import java.util.Collections; |
|
20 | import java.util.HashMap; |
|
21 | import java.util.Map; |
|
22 | ||
23 | import org.apache.torque.om.BaseObject; |
|
24 | ||
25 | /** |
|
26 | * This class represents a generic object used in the Access Control Lists. |
|
27 | * |
|
28 | * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a> |
|
29 | * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a> |
|
30 | * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a> |
|
31 | * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a> |
|
32 | * @version $Id: SecurityObject.java 264148 2005-08-29 14:21:04Z henning $ |
|
33 | */ |
|
34 | public abstract class SecurityObject extends BaseObject implements Comparable |
|
35 | { |
|
36 | /** The name of this object. */ |
|
37 | private String name; |
|
38 | ||
39 | /** The id of this object */ |
|
40 | private int id; |
|
41 | ||
42 | /** The attributes of this object. */ |
|
43 | private Map attributes; |
|
44 | ||
45 | /** |
|
46 | * Constructs a new SecurityObject |
|
47 | */ |
|
48 | public SecurityObject() |
|
49 | { |
|
50 | 0 | this(""); |
51 | 0 | } |
52 | ||
53 | /** |
|
54 | * Constructs a new SecurityObject with the specified name. |
|
55 | * |
|
56 | * @param name The name of the new object. |
|
57 | */ |
|
58 | public SecurityObject(String name) |
|
59 | 0 | { |
60 | 0 | setName(name); |
61 | 0 | setId(0); |
62 | 0 | setAttributes(Collections.synchronizedMap(new HashMap())); |
63 | 0 | } |
64 | ||
65 | /** |
|
66 | * Returns a Map containing this object's attributes. |
|
67 | * |
|
68 | * @return the object's attributes. |
|
69 | */ |
|
70 | public Map getAttributes() |
|
71 | { |
|
72 | 0 | return attributes; |
73 | } |
|
74 | ||
75 | /** |
|
76 | * Replaces this object's attributes with the specified Map. |
|
77 | * |
|
78 | * @param attributes The new attributes of the object. |
|
79 | */ |
|
80 | public void setAttributes(Map attributes) |
|
81 | { |
|
82 | 0 | this.attributes = attributes; |
83 | 0 | } |
84 | ||
85 | /** |
|
86 | * Retrieves the value of specific attribute of this object. |
|
87 | * |
|
88 | * @param name the name of the attribute |
|
89 | * @return the value of the attribute |
|
90 | */ |
|
91 | public Object getAttribute(String name) |
|
92 | { |
|
93 | 0 | return attributes.get(name); |
94 | } |
|
95 | ||
96 | /** |
|
97 | * Sets the value of specific attribute of this object. |
|
98 | * |
|
99 | * @param name the name of the attribute |
|
100 | * @param value the value of the attribute |
|
101 | */ |
|
102 | public void setAttribute(String name, Object value) |
|
103 | { |
|
104 | 0 | attributes.put(name, value); |
105 | 0 | } |
106 | ||
107 | /** |
|
108 | * Returns the name of this object. |
|
109 | * |
|
110 | * @return The name of the object. |
|
111 | */ |
|
112 | public String getName() |
|
113 | { |
|
114 | 0 | return name; |
115 | } |
|
116 | ||
117 | /** |
|
118 | * Sets the name of this object. |
|
119 | * |
|
120 | * @param name The name of the object. |
|
121 | */ |
|
122 | public void setName(String name) |
|
123 | { |
|
124 | 0 | this.name = name; |
125 | 0 | } |
126 | ||
127 | /** |
|
128 | * Unused. There is an ID column in the |
|
129 | * database scheme but it doesn't seem |
|
130 | * to be used. |
|
131 | * |
|
132 | * @return 0 |
|
133 | */ |
|
134 | public int getId() |
|
135 | { |
|
136 | 0 | return id; |
137 | } |
|
138 | ||
139 | /** |
|
140 | * Unused. There is an ID column in the |
|
141 | * database scheme but it doesn't seem |
|
142 | * to be used. |
|
143 | * |
|
144 | * @return null |
|
145 | */ |
|
146 | public Integer getIdAsObj() |
|
147 | { |
|
148 | 0 | return new Integer(id); |
149 | } |
|
150 | ||
151 | /** |
|
152 | * Unused. There is an ID column in the |
|
153 | * database scheme but it doesn't seem |
|
154 | * to be used. |
|
155 | * |
|
156 | * @param id The id of the User. |
|
157 | */ |
|
158 | public void setId(int id) |
|
159 | { |
|
160 | 0 | this.id = id; |
161 | 0 | } |
162 | ||
163 | /** |
|
164 | * Used for ordering SecurityObjects. |
|
165 | * |
|
166 | * @param obj The Object to compare to. |
|
167 | * @return -1 if the name of the other object is lexically greater than this |
|
168 | * group, 1 if it is lexically lesser, 0 if they are equal. |
|
169 | */ |
|
170 | public int compareTo(Object obj) |
|
171 | { |
|
172 | 0 | if (this.getClass() != obj.getClass()) |
173 | { |
|
174 | 0 | throw new ClassCastException(); |
175 | } |
|
176 | 0 | String name1 = ((SecurityObject) obj).getName(); |
177 | 0 | String name2 = this.getName(); |
178 | ||
179 | 0 | return name2.compareTo(name1); |
180 | } |
|
181 | ||
182 | /** |
|
183 | * Returns a textual representation of this object, consisted by |
|
184 | * it's name and attributes. |
|
185 | * |
|
186 | * @return a textual representation of this group. |
|
187 | */ |
|
188 | public String toString() |
|
189 | { |
|
190 | 0 | return (getName() + ':' + getAttributes().toString()); |
191 | } |
|
192 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |