equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 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. |
338 } |
338 } |
339 |
339 |
340 // Policy for the test... |
340 // Policy for the test... |
341 public static class SimplePolicy extends Policy { |
341 public static class SimplePolicy extends Policy { |
342 |
342 |
|
343 static final Policy DEFAULT_POLICY = Policy.getPolicy(); |
|
344 |
343 final Permissions permissions; |
345 final Permissions permissions; |
344 final Permissions allPermissions; |
346 final Permissions allPermissions; |
345 final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale |
347 final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale |
346 public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) { |
348 public SimplePolicy(TestCase test, ThreadLocal<AtomicBoolean> allowAll) { |
347 this.allowAll = allowAll; |
349 this.allowAll = allowAll; |
358 } |
360 } |
359 |
361 |
360 @Override |
362 @Override |
361 public boolean implies(ProtectionDomain domain, Permission permission) { |
363 public boolean implies(ProtectionDomain domain, Permission permission) { |
362 if (allowAll.get().get()) return allPermissions.implies(permission); |
364 if (allowAll.get().get()) return allPermissions.implies(permission); |
363 return permissions.implies(permission); |
365 return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission); |
364 } |
366 } |
365 |
367 |
366 @Override |
368 @Override |
367 public PermissionCollection getPermissions(CodeSource codesource) { |
369 public PermissionCollection getPermissions(CodeSource codesource) { |
368 return new PermissionsBuilder().addAll(allowAll.get().get() |
370 return new PermissionsBuilder().addAll(allowAll.get().get() |