8266459: Implement JEP 411: Deprecate the Security Manager for Removal

Co-authored-by: Sean Mullan <mullan@openjdk.org>
Co-authored-by: Lance Andersen <lancea@openjdk.org>
Co-authored-by: Weijun Wang <weijun@openjdk.org>
Reviewed-by: erikj, darcy, chegar, naoto, joehw, alanb, mchung, kcr, prr, lancea
This commit is contained in:
Weijun Wang 2021-06-02 11:57:31 +00:00
parent 19450b9951
commit 6765f90250
826 changed files with 2734 additions and 757 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -83,8 +83,14 @@ import sun.security.util.SecurityConstants;
* @see java.security.ProtectionDomain
* @see java.security.Permission
* @see java.security.Security security properties
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is deprecated
* and subject to removal in a future release. Consequently, this class
* is also deprecated and subject to removal. There is no replacement for
* the Security Manager or this class.
*/
@Deprecated(since="17", forRemoval=true)
public abstract class Policy {
/**
@ -133,6 +139,7 @@ public abstract class Policy {
}
private static void checkPermission(String type) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new SecurityPermission("createPolicy." + type));
@ -159,6 +166,7 @@ public abstract class Policy {
*/
public static Policy getPolicy()
{
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(SecurityConstants.GET_POLICY_PERMISSION);
@ -194,6 +202,7 @@ public abstract class Policy {
* an intrinsic lock on the Policy.class.
*/
private static Policy loadPolicyProvider() {
@SuppressWarnings("removal")
String policyProvider =
AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
@ -222,6 +231,7 @@ public abstract class Policy {
Policy polFile = new sun.security.provider.PolicyFile();
policyInfo = new PolicyInfo(polFile, false);
@SuppressWarnings("removal")
Policy pol = AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Policy run() {
@ -271,6 +281,7 @@ public abstract class Policy {
*/
public static void setPolicy(Policy p)
{
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(
new SecurityPermission("setPolicy"));
@ -310,6 +321,7 @@ public abstract class Policy {
* implementations will continue to function.
*/
@SuppressWarnings("removal")
ProtectionDomain policyDomain =
AccessController.doPrivileged(new PrivilegedAction<>() {
public ProtectionDomain run() {
@ -394,6 +406,7 @@ public abstract class Policy {
* @see Provider
* @since 1.6
*/
@SuppressWarnings("removal")
public static Policy getInstance(String type, Policy.Parameters params)
throws NoSuchAlgorithmException {
Objects.requireNonNull(type, "null type name");
@ -455,6 +468,7 @@ public abstract class Policy {
* @see Provider
* @since 1.6
*/
@SuppressWarnings("removal")
public static Policy getInstance(String type,
Policy.Parameters params,
String provider)
@ -518,6 +532,7 @@ public abstract class Policy {
* @see Provider
* @since 1.6
*/
@SuppressWarnings("removal")
public static Policy getInstance(String type,
Policy.Parameters params,
Provider provider)
@ -769,12 +784,13 @@ public abstract class Policy {
*/
private static class PolicyDelegate extends Policy {
@SuppressWarnings("removal")
private PolicySpi spi;
private Provider p;
private String type;
private Policy.Parameters params;
private PolicyDelegate(PolicySpi spi, Provider p,
private PolicyDelegate(@SuppressWarnings("removal") PolicySpi spi, Provider p,
String type, Policy.Parameters params) {
this.spi = spi;
this.p = p;
@ -810,7 +826,13 @@ public abstract class Policy {
* This represents a marker interface for Policy parameters.
*
* @since 1.6
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is
* deprecated and subject to removal in a future release.
* Consequently, this class is also deprecated and subject to removal.
* There is no replacement for the Security Manager or this class.
*/
@Deprecated(since="17", forRemoval=true)
public static interface Parameters { }
/**