1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * 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
19
20
21
22
23
24 package javax.security.jacc;
25
26 import java.io.Serializable;
27 import java.security.Permission;
28
29 /**
30 *
31 * @version $Rev: 54183 $ $Date: 2004-10-09 15:04:29 -0700 (Sat, 09 Oct 2004) $
32 */
33 public final class WebRoleRefPermission extends Permission implements Serializable {
34 private transient int cachedHashCode = 0;
35 private String actions;
36
37 public WebRoleRefPermission(String name, String role) {
38 super(name);
39
40 actions = role;
41 }
42
43 public boolean equals(Object o) {
44 if (o == null || !(o instanceof WebRoleRefPermission)) return false;
45
46 WebRoleRefPermission other = (WebRoleRefPermission)o;
47 return getName().equals(other.getName()) && actions.equals(other.actions);
48 }
49
50 public String getActions() {
51 return actions;
52 }
53
54 public int hashCode() {
55 if (cachedHashCode == 0) {
56 cachedHashCode = getName().hashCode() ^ actions.hashCode();
57 }
58 return cachedHashCode;
59 }
60
61 public boolean implies(Permission permission) {
62 return equals(permission);
63 }
64 }
65