mirror of
https://github.com/darlinghq/darling-openjdk.git
synced 2024-12-11 22:33:36 +00:00
8185139: [Graal] Tests which set too restrictive security manager fail with Graal
Tests should also check default policy Reviewed-by: mchung, dfuchs, alanb, mullan
This commit is contained in:
parent
a7a94701fe
commit
c956e7ca8d
@ -27,48 +27,8 @@
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java 8185139 generic-all
|
||||
java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java 8185139 generic-all
|
||||
java/lang/invoke/InvokeDynamicPrintArgs.java 8185139 generic-all
|
||||
java/lang/invoke/MethodHandleConstants.java 8185139 generic-all
|
||||
java/lang/ProcessBuilder/Basic.java#id0 8185139 generic-all
|
||||
java/lang/ProcessBuilder/Basic.java#id1 8185139 generic-all
|
||||
java/lang/ProcessBuilder/SecurityManagerClinit.java 8185139 generic-all
|
||||
java/lang/ProcessHandle/PermissionTest.java 8185139 generic-all
|
||||
java/lang/reflect/Proxy/nonPublicProxy/NonPublicProxyClass.java 8185139 generic-all
|
||||
java/lang/StackWalker/CallerSensitiveMethod/Main.java 8185139 generic-all
|
||||
java/lang/StackWalker/GetCallerClassTest.java 8185139 generic-all
|
||||
java/lang/String/concat/WithSecurityManager.java 8185139 generic-all
|
||||
java/lang/System/Logger/custom/CustomLoggerTest.java 8185139 generic-all
|
||||
java/lang/System/Logger/default/DefaultLoggerTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/BaseLoggerFinderTest/BaseLoggerFinderTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/DefaultLoggerFinderTest/DefaultLoggerFinderTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/internal/BaseLoggerBridgeTest/BaseLoggerBridgeTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/internal/BasePlatformLoggerTest/BasePlatformLoggerTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/internal/LoggerBridgeTest/LoggerBridgeTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/internal/PlatformLoggerBridgeTest/PlatformLoggerBridgeTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/jdk/DefaultLoggerBridgeTest/DefaultLoggerBridgeTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java 8185139 generic-all
|
||||
java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java 8185139 generic-all
|
||||
java/util/concurrent/atomic/AtomicUpdaters.java 8185139 generic-all
|
||||
java/util/concurrent/Executors/PrivilegedCallables.java 8185139 generic-all
|
||||
java/util/logging/FileHandlerPath.java 8185139 generic-all
|
||||
java/util/logging/FileHandlerPatternExceptions.java 8185139 generic-all
|
||||
java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java 8185139 generic-all
|
||||
java/util/logging/LogManagerAppContextDeadlock.java 8185139 generic-all
|
||||
java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexResetUpdate.java 8185139 generic-all
|
||||
java/util/logging/LogManager/Configuration/updateConfiguration/HandlersOnComplexUpdate.java 8185139 generic-all
|
||||
java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigurationTest.java 8185139 generic-all
|
||||
java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigWithInputStreamTest.java 8185139 generic-all
|
||||
java/util/logging/LogManager/RootLogger/setLevel/TestRootLoggerLevel.java 8185139 generic-all
|
||||
java/util/logging/RootLogger/RootLevelInConfigFile.java 8185139 generic-all
|
||||
java/util/logging/TestAppletLoggerContext.java 8185139 generic-all
|
||||
java/util/logging/TestConfigurationListeners.java 8185139 generic-all
|
||||
java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java 8185139 generic-all
|
||||
java/util/logging/FileHandlerLongLimit.java 8185139 generic-all
|
||||
java/lang/String/concat/WithSecurityManager.java 8207267 generic-all
|
||||
java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java 8207267 generic-all
|
||||
|
||||
java/util/concurrent/tck/JSR166TestCase.java 8187486 generic-all
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -166,6 +166,7 @@ public class ClassDeclaredFieldsTest {
|
||||
// Policy for the test...
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale
|
||||
@ -187,7 +188,7 @@ public class ClassDeclaredFieldsTest {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get().get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -385,6 +385,8 @@ public class FieldSetAccessibleTest {
|
||||
// Policy for the test...
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowAll;
|
||||
@ -420,6 +422,7 @@ public class FieldSetAccessibleTest {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (DEFAULT_POLICY.implies(domain, permission)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2602,6 +2602,8 @@ public class Basic {
|
||||
// A Policy class designed to make permissions fiddling very easy.
|
||||
//----------------------------------------------------------------
|
||||
private static class Policy extends java.security.Policy {
|
||||
static final java.security.Policy DEFAULT_POLICY = java.security.Policy.getPolicy();
|
||||
|
||||
private Permissions perms;
|
||||
|
||||
public void setPermissions(Permission...permissions) {
|
||||
@ -2621,7 +2623,7 @@ public class Basic {
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain pd, Permission p) {
|
||||
return perms.implies(p);
|
||||
return perms.implies(p) || DEFAULT_POLICY.implies(pd, p);
|
||||
}
|
||||
|
||||
public void refresh() {}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc. All Rights Reserved.
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,17 +36,19 @@ import java.io.*;
|
||||
import java.security.*;
|
||||
|
||||
public class SecurityManagerClinit {
|
||||
private static class Policy extends java.security.Policy {
|
||||
private static class SimplePolicy extends Policy {
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
private Permissions perms;
|
||||
|
||||
public Policy(Permission... permissions) {
|
||||
public SimplePolicy(Permission... permissions) {
|
||||
perms = new Permissions();
|
||||
for (Permission permission : permissions)
|
||||
perms.add(permission);
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain pd, Permission p) {
|
||||
return perms.implies(p);
|
||||
return perms.implies(p) || DEFAULT_POLICY.implies(pd, p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,8 +57,8 @@ public class SecurityManagerClinit {
|
||||
System.getProperty("java.home") +
|
||||
File.separator + "bin" + File.separator + "java";
|
||||
|
||||
final Policy policy =
|
||||
new Policy
|
||||
final SimplePolicy policy =
|
||||
new SimplePolicy
|
||||
(new FilePermission("<<ALL FILES>>", "execute"),
|
||||
new RuntimePermission("setSecurityManager"));
|
||||
Policy.setPolicy(policy);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -178,6 +178,9 @@ public class PermissionTest {
|
||||
}
|
||||
|
||||
class TestPolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
private final PermissionCollection permissions = new Permissions();
|
||||
|
||||
public TestPolicy() {
|
||||
@ -222,6 +225,6 @@ class TestPolicy extends Policy {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||
return permissions.implies(perm);
|
||||
return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -704,6 +704,8 @@ public class CustomLoggerTest {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
static final RuntimePermission LOGGERFINDER_PERMISSION =
|
||||
new RuntimePermission("loggerFinder");
|
||||
final Permissions permissions;
|
||||
@ -736,7 +738,7 @@ public class CustomLoggerTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return permissions().implies(permission);
|
||||
return permissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -884,6 +884,9 @@ public class DefaultLoggerTest {
|
||||
}
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
static final RuntimePermission LOGGERFINDER_PERMISSION =
|
||||
new RuntimePermission("loggerFinder");
|
||||
final Permissions permissions;
|
||||
@ -908,7 +911,7 @@ public class DefaultLoggerTest {
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get().get()) return allPermissions.implies(permission);
|
||||
if (allowControl.get().get()) return controlPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -652,6 +652,8 @@ public class BaseLoggerFinderTest {
|
||||
final static RuntimePermission CONTROL = LOGGERFINDER_PERMISSION;
|
||||
final static RuntimePermission ACCESS = new RuntimePermission("accessClassInPackage.jdk.internal.logger");
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final ThreadLocal<AtomicBoolean> allowControl;
|
||||
final ThreadLocal<AtomicBoolean> allowAccess;
|
||||
@ -678,7 +680,7 @@ public class BaseLoggerFinderTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions().implies(permission);
|
||||
return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -842,6 +842,8 @@ public class DefaultLoggerFinderTest {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions withControlPermissions;
|
||||
final Permissions allPermissions;
|
||||
@ -865,7 +867,7 @@ public class DefaultLoggerFinderTest {
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get().get()) return allPermissions.implies(permission);
|
||||
if (allowControl.get().get()) return withControlPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -981,6 +981,8 @@ public class BaseLoggerBridgeTest {
|
||||
final static RuntimePermission ACCESS_LOGGER = new RuntimePermission("accessClassInPackage.jdk.internal.logger");
|
||||
final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging");
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowControl;
|
||||
@ -1019,7 +1021,7 @@ public class BaseLoggerBridgeTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions().implies(permission);
|
||||
return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -663,6 +663,8 @@ public class BasePlatformLoggerTest {
|
||||
final static RuntimePermission CONTROL = LOGGERFINDER_PERMISSION;
|
||||
final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging");
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowControl;
|
||||
@ -700,7 +702,7 @@ public class BasePlatformLoggerTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions().implies(permission);
|
||||
return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1026,6 +1026,8 @@ public class LoggerBridgeTest {
|
||||
final static RuntimePermission ACCESS_LOGGER = new RuntimePermission("accessClassInPackage.jdk.internal.logger");
|
||||
final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging");
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowControl;
|
||||
@ -1064,7 +1066,7 @@ public class LoggerBridgeTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions().implies(permission);
|
||||
return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -805,6 +805,8 @@ public class PlatformLoggerBridgeTest {
|
||||
final static RuntimePermission ACCESS_LOGGER = new RuntimePermission("accessClassInPackage.jdk.internal.logger");
|
||||
final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging");
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowControl;
|
||||
@ -843,7 +845,7 @@ public class PlatformLoggerBridgeTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions().implies(permission);
|
||||
return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -801,6 +801,8 @@ public class DefaultLoggerBridgeTest {
|
||||
final static RuntimePermission ACCESS_LOGGER = new RuntimePermission("accessClassInPackage.jdk.internal.logger");
|
||||
final static RuntimePermission ACCESS_LOGGING = new RuntimePermission("accessClassInPackage.sun.util.logging");
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowControl;
|
||||
@ -839,7 +841,7 @@ public class DefaultLoggerBridgeTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions().implies(permission);
|
||||
return getPermissions().implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -499,6 +499,8 @@ public class DefaultPlatformLoggerTest {
|
||||
public static final RuntimePermission LOGGERFINDER_PERMISSION =
|
||||
new RuntimePermission("loggerFinder");
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions withControlPermissions;
|
||||
final Permissions allPermissions;
|
||||
@ -522,7 +524,7 @@ public class DefaultPlatformLoggerTest {
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get().get()) return allPermissions.implies(permission);
|
||||
if (allowControl.get().get()) return withControlPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -234,6 +234,8 @@ public class InvokeDynamicPrintArgs {
|
||||
}
|
||||
|
||||
static class TestPolicy extends Policy {
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final PermissionCollection permissions = new Permissions();
|
||||
TestPolicy() {
|
||||
permissions.add(new java.io.FilePermission("<<ALL FILES>>", "read"));
|
||||
@ -247,7 +249,7 @@ public class InvokeDynamicPrintArgs {
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||
return permissions.implies(perm);
|
||||
return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -169,6 +169,8 @@ public class MethodHandleConstants {
|
||||
}
|
||||
|
||||
static class TestPolicy extends Policy {
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final PermissionCollection permissions = new Permissions();
|
||||
TestPolicy() {
|
||||
permissions.add(new java.io.FilePermission("<<ALL FILES>>", "read"));
|
||||
@ -182,7 +184,7 @@ public class MethodHandleConstants {
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||
return permissions.implies(perm);
|
||||
return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,6 +28,7 @@ import java.lang.*;
|
||||
|
||||
public class DynamicPolicy extends Policy{
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy(); // do this early before setPolicy is called
|
||||
static int refresher = 0;
|
||||
|
||||
|
||||
@ -48,7 +49,7 @@ public class DynamicPolicy extends Policy{
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain pd, Permission p) {
|
||||
return getPermissions(pd).implies(p);
|
||||
return getPermissions(pd).implies(p) || DEFAULT_POLICY.implies(pd, p);
|
||||
}
|
||||
|
||||
public PermissionCollection getPermissions(ProtectionDomain pd) {
|
||||
|
@ -70,6 +70,8 @@ public class PrivilegedCallables {
|
||||
// A Policy class designed to make permissions fiddling very easy.
|
||||
//----------------------------------------------------------------
|
||||
static class Policy extends java.security.Policy {
|
||||
static final java.security.Policy DEFAULT_POLICY = java.security.Policy.getPolicy();
|
||||
|
||||
private Permissions perms;
|
||||
|
||||
public void setPermissions(Permission...permissions) {
|
||||
@ -89,7 +91,7 @@ public class PrivilegedCallables {
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain pd, Permission p) {
|
||||
return perms.implies(p);
|
||||
return perms.implies(p) || DEFAULT_POLICY.implies(pd, p);
|
||||
}
|
||||
|
||||
public void refresh() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -471,6 +471,8 @@ public class FileHandlerLongLimit {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final AtomicBoolean allowAll;
|
||||
@ -490,7 +492,7 @@ public class FileHandlerLongLimit {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -270,6 +270,8 @@ public class FileHandlerPath {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final AtomicBoolean allowAll;
|
||||
@ -297,7 +299,7 @@ public class FileHandlerPath {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -294,6 +294,8 @@ public class FileHandlerPatternExceptions {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final AtomicBoolean allowAll;
|
||||
@ -313,7 +315,7 @@ public class FileHandlerPatternExceptions {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -480,6 +480,8 @@ public class ParentLoggerWithHandlerGC {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final AtomicBoolean allowAll;
|
||||
@ -499,7 +501,7 @@ public class ParentLoggerWithHandlerGC {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -522,6 +522,8 @@ public class HandlersOnComplexResetUpdate {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale
|
||||
@ -541,7 +543,7 @@ public class HandlersOnComplexResetUpdate {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get().get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -521,6 +521,8 @@ public class HandlersOnComplexUpdate {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale
|
||||
@ -540,7 +542,7 @@ public class HandlersOnComplexUpdate {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get().get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -652,6 +652,8 @@ public class SimpleUpdateConfigurationTest {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions basic;
|
||||
final Permissions control;
|
||||
final Permissions all;
|
||||
@ -690,7 +692,7 @@ public class SimpleUpdateConfigurationTest {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return getPermissions(domain).implies(permission);
|
||||
return getPermissions(domain).implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
public PermissionCollection permissions() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -119,6 +119,9 @@ public class TestRootLoggerLevel {
|
||||
}
|
||||
|
||||
private static final class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
private final Permissions perms;
|
||||
|
||||
private static final Permissions permissions(Permission... perms) {
|
||||
@ -141,7 +144,7 @@ public class TestRootLoggerLevel {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return perms.implies(permission);
|
||||
return perms.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -340,6 +340,8 @@ public class LogManagerAppContextDeadlock {
|
||||
// Policy for the test...
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
final Permissions allPermissions;
|
||||
final ThreadLocal<AtomicBoolean> allowAll; // actually: this should be in a thread locale
|
||||
@ -360,7 +362,7 @@ public class LogManagerAppContextDeadlock {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
if (allowAll.get().get()) return allPermissions.implies(permission);
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -176,6 +176,8 @@ public class RootLevelInConfigFile {
|
||||
|
||||
static final class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final PermissionCollection perms = new Permissions();
|
||||
public SimplePolicy(String configFile) {
|
||||
perms.add(new LoggingPermission("control", null));
|
||||
@ -187,7 +189,7 @@ public class RootLevelInConfigFile {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return perms.implies(permission);
|
||||
return perms.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -72,6 +72,9 @@ public class TestAppletLoggerContext {
|
||||
|
||||
// Avoids the hassle of dealing with files and system props...
|
||||
static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
private final Permissions perms;
|
||||
public SimplePolicy(Permission... permissions) {
|
||||
perms = new Permissions();
|
||||
@ -89,7 +92,7 @@ public class TestAppletLoggerContext {
|
||||
}
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain pd, Permission p) {
|
||||
return perms.implies(p);
|
||||
return perms.implies(p) || DEFAULT_POLICY.implies(pd, p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -458,6 +458,8 @@ public class TestConfigurationListeners {
|
||||
|
||||
public static class SimplePolicy extends Policy {
|
||||
|
||||
static final Policy DEFAULT_POLICY = Policy.getPolicy();
|
||||
|
||||
final Permissions permissions;
|
||||
public SimplePolicy(TestCase test) {
|
||||
permissions = new Permissions();
|
||||
@ -472,7 +474,7 @@ public class TestConfigurationListeners {
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return permissions.implies(permission);
|
||||
return permissions.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user