equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
164 } |
164 } |
165 |
165 |
166 // Policy for the test... |
166 // Policy for the test... |
167 public static class SimplePolicy extends Policy { |
167 public static class SimplePolicy extends Policy { |
168 |
168 |
|
169 static final Policy DEFAULT_POLICY = Policy.getPolicy(); |
169 final Permissions permissions; |
170 final Permissions permissions; |
170 final Permissions allPermissions; |
171 final Permissions allPermissions; |
171 final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale |
172 final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale |
172 public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) { |
173 public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) { |
173 this.allowAll = allowAll; |
174 this.allowAll = allowAll; |
185 } |
186 } |
186 |
187 |
187 @Override |
188 @Override |
188 public boolean implies(ProtectionDomain domain, Permission permission) { |
189 public boolean implies(ProtectionDomain domain, Permission permission) { |
189 if (allowAll.get().get()) return allPermissions.implies(permission); |
190 if (allowAll.get().get()) return allPermissions.implies(permission); |
190 return permissions.implies(permission); |
191 return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); |
191 } |
192 } |
192 |
193 |
193 @Override |
194 @Override |
194 public PermissionCollection getPermissions(CodeSource codesource) { |
195 public PermissionCollection getPermissions(CodeSource codesource) { |
195 return new PermissionsBuilder().addAll(allowAll.get().get() |
196 return new PermissionsBuilder().addAll(allowAll.get().get() |