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
25 * MJI model class for java.security.AllPermission library abstraction
27 public final class AllPermission extends Permission {
29 private static final long serialVersionUID = -2916474571451318075L;
31 public AllPermission() {
32 super("<all permissions>");
35 public boolean implies(Permission p) {
39 public boolean equals(Object obj) {
40 return (obj instanceof AllPermission);
43 public int hashCode() {
47 public String getActions() {
48 return "<all actions>";
51 public PermissionCollection newPermissionCollection() {
52 return new AllPermissionCollection();
58 final class AllPermissionCollection
59 extends PermissionCollection
60 implements java.io.Serializable
63 // use serialVersionUID from JDK 1.2.2 for interoperability
64 private static final long serialVersionUID = -4023755556366636806L;
66 private boolean all_allowed; // true if any all permissions have been added
68 public AllPermissionCollection() {
72 public void add(Permission permission) {
73 if (! (permission instanceof AllPermission))
74 throw new IllegalArgumentException("invalid permission: "+
77 throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection");
79 all_allowed = true; // No sync; staleness OK
82 public boolean implies(Permission permission) {
83 return all_allowed; // No sync; staleness OK
86 public Enumeration<Permission> elements() {
87 return new Enumeration<Permission>() {
88 private boolean hasMore = all_allowed;
90 public boolean hasMoreElements() {
94 public Permission nextElement() {
96 return SecurityConstants.ALL_PERMISSION;