001 /**
002 *
003 * Copyright 2003-2004 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * 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 //
019 // This source code implements specifications defined by the Java
020 // Community Process. In order to remain compliant with the specification
021 // DO NOT add / change / or delete method signatures!
022 //
023
024 package javax.security.jacc;
025
026 import java.io.Serializable;
027 import java.security.Permission;
028
029 /**
030 *
031 * @version $Rev: 54183 $ $Date: 2004-10-09 15:04:29 -0700 (Sat, 09 Oct 2004) $
032 */
033 public final class WebRoleRefPermission extends Permission implements Serializable {
034 private transient int cachedHashCode = 0;
035 private String actions;
036
037 public WebRoleRefPermission(String name, String role) {
038 super(name);
039
040 actions = role;
041 }
042
043 public boolean equals(Object o) {
044 if (o == null || !(o instanceof WebRoleRefPermission)) return false;
045
046 WebRoleRefPermission other = (WebRoleRefPermission)o;
047 return getName().equals(other.getName()) && actions.equals(other.actions);
048 }
049
050 public String getActions() {
051 return actions;
052 }
053
054 public int hashCode() {
055 if (cachedHashCode == 0) {
056 cachedHashCode = getName().hashCode() ^ actions.hashCode();
057 }
058 return cachedHashCode;
059 }
060
061 public boolean implies(Permission permission) {
062 return equals(permission);
063 }
064 }
065