2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
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.
18 package java.security;
20 import java.util.Enumeration;
21 import sun.security.util.SecurityConstants;
23 // TODO: Fix for Groovy's model-checking
24 // TODO: This model class is a placeholder for future implementation
26 * MJI model class for java.security.AllPermission library abstraction
28 public final class AllPermission extends Permission {
30 private static final long serialVersionUID = -2916474571451318075L;
32 public AllPermission() {
33 super("<all permissions>");
36 public boolean implies(Permission p) {
40 public boolean equals(Object obj) {
41 return (obj instanceof AllPermission);
44 public int hashCode() {
48 public String getActions() {
49 return "<all actions>";
52 public PermissionCollection newPermissionCollection() {
53 return new AllPermissionCollection();
59 final class AllPermissionCollection
60 extends PermissionCollection
61 implements java.io.Serializable
64 // use serialVersionUID from JDK 1.2.2 for interoperability
65 private static final long serialVersionUID = -4023755556366636806L;
67 private boolean all_allowed; // true if any all permissions have been added
69 public AllPermissionCollection() {
73 public void add(Permission permission) {
74 if (! (permission instanceof AllPermission))
75 throw new IllegalArgumentException("invalid permission: "+
78 throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection");
80 all_allowed = true; // No sync; staleness OK
83 public boolean implies(Permission permission) {
84 return all_allowed; // No sync; staleness OK
87 public Enumeration<Permission> elements() {
88 return new Enumeration<Permission>() {
89 private boolean hasMore = all_allowed;
91 public boolean hasMoreElements() {
95 public Permission nextElement() {
97 return SecurityConstants.ALL_PERMISSION;