Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 14 commits into from
Closed
@@ -767,7 +767,7 @@ define SetupRunJtregTestBody
-vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) \
-vmoption:-Djava.io.tmpdir="$$($1_TEST_TMP_DIR)"

$1_JTREG_BASIC_OPTIONS += -automatic -ignore:quiet
$1_JTREG_BASIC_OPTIONS += -automatic -ignore:quiet -Djavatest.security.noSecurityManager=true

# Make it possible to specify the JIB_DATA_DIR for tests using the
# JIB Artifact resolver
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -406,7 +406,7 @@ public void run() {
if (pDialogState) {
printJob.print(aset);
}
} catch (java.security.AccessControlException ace) {
} catch (@SuppressWarnings("removal") java.security.AccessControlException ace) {
String errmsg = "Applet access control exception; to allow "
+ "access to printer, set\n"
+ "permission for \"queuePrintJob\" in "
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@@ -32,6 +32,7 @@
* Creates this platform's default SelectorProvider
*/

@SuppressWarnings("removal")
public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE;
static {
@@ -39,6 +39,7 @@

public final class CgroupUtil {

@SuppressWarnings("removal")
public static Stream<String> readFilePrivileged(Path path) throws IOException {
try {
PrivilegedExceptionAction<Stream<String>> pea = () -> Files.lines(path);
@@ -64,7 +65,7 @@ static void unwrapIOExceptionAndRethrow(PrivilegedActionException pae) throws IO
static String readStringValue(CgroupSubsystemController controller, String param) throws IOException {
PrivilegedExceptionAction<BufferedReader> pea = () ->
Files.newBufferedReader(Paths.get(controller.path(), param));
try (BufferedReader bufferedReader =
try (@SuppressWarnings("removal") BufferedReader bufferedReader =
AccessController.doPrivileged(pea)) {
String line = bufferedReader.readLine();
return line;
@@ -76,6 +77,7 @@ static String readStringValue(CgroupSubsystemController controller, String param
}
}

@SuppressWarnings("removal")
public static List<String> readAllLinesPrivileged(Path path) throws IOException {
try {
PrivilegedExceptionAction<List<String>> pea = () -> Files.readAllLines(path);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@@ -32,6 +32,7 @@
* Creates this platform's default SelectorProvider
*/

@SuppressWarnings("removal")
public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE;
static {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@@ -73,6 +73,7 @@ public Object newInstance(Object ctrParamObj)
}


@SuppressWarnings("removal")
public AppleProvider() {
/* We are the Apple provider */
super("Apple", PROVIDER_VER, info);
@@ -110,6 +110,7 @@
}

private static void permissionCheck() {
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager();

if (sec != null) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@@ -106,6 +106,7 @@ private static NetworkInterface chooseDefaultInterface() {

boolean ip4 = false, ip6 = false, isNonLinkLocal = false;
PrivilegedAction<Enumeration<InetAddress>> pa = ni::getInetAddresses;
@SuppressWarnings("removal")
Enumeration<InetAddress> addrs = AccessController.doPrivileged(pa);
while (addrs.hasMoreElements()) {
InetAddress addr = addrs.nextElement();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@@ -32,6 +32,7 @@
* Creates this platform's default SelectorProvider
*/

@SuppressWarnings("removal")
public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE;
static {
@@ -66,6 +66,7 @@

private static final boolean VALUE = getValue();

@SuppressWarnings("removal")
private static boolean getValue() {
return AccessController.doPrivileged(
(PrivilegedAction<Boolean>)
@@ -683,6 +683,7 @@ public void engineStore(OutputStream stream, char[] password)
* @exception CertificateException if any of the certificates in the
* keystore could not be loaded
*/
@SuppressWarnings("removal")
public void engineLoad(InputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException
{
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@@ -73,6 +73,7 @@ AlgorithmParameters getParameters() {
return params;
}

@SuppressWarnings("removal")
final Key getKey(Cipher c, int maxLength)
throws IOException, ClassNotFoundException, IllegalBlockSizeException,
BadPaddingException {
@@ -112,6 +113,7 @@ final Key getKey(Cipher c, int maxLength)
private static final ObjectInputFilter OWN_FILTER;

static {
@SuppressWarnings("removal")
String prop = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> {
String tmp = System.getProperty(KEY_SERIAL_FILTER);
@@ -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
@@ -117,6 +117,7 @@ private void psA(String type, String algo, String cn,
attrs));
}

@SuppressWarnings("removal")
public SunJCE() {
/* We are the "SunJCE" provider */
super("SunJCE", PROVIDER_VER, info);
@@ -770,6 +770,7 @@ public URI toURI() {
* method denies read access to the file
*/
public boolean canRead() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -798,6 +799,7 @@ public boolean canRead() {
* method denies write access to the file
*/
public boolean canWrite() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
@@ -821,6 +823,7 @@ public boolean canWrite() {
* method denies read access to the file or directory
*/
public boolean exists() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -851,6 +854,7 @@ public boolean exists() {
* method denies read access to the file
*/
public boolean isDirectory() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -883,6 +887,7 @@ public boolean isDirectory() {
* method denies read access to the file
*/
public boolean isFile() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -912,6 +917,7 @@ public boolean isFile() {
* @since 1.2
*/
public boolean isHidden() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -955,6 +961,7 @@ public boolean isHidden() {
* method denies read access to the file
*/
public long lastModified() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -986,6 +993,7 @@ public long lastModified() {
* method denies read access to the file
*/
public long length() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -1026,6 +1034,7 @@ public long length() {
* @since 1.2
*/
public boolean createNewFile() throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) security.checkWrite(path);
if (isInvalid()) {
@@ -1053,6 +1062,7 @@ public boolean createNewFile() throws IOException {
* delete access to the file
*/
public boolean delete() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkDelete(path);
@@ -1091,6 +1101,7 @@ public boolean delete() {
* @since 1.2
*/
public void deleteOnExit() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkDelete(path);
@@ -1154,6 +1165,7 @@ public void deleteOnExit() {
* the directory
*/
private final String[] normalizedList() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -1356,6 +1368,7 @@ public void deleteOnExit() {
* method does not permit the named directory to be created
*/
public boolean mkdir() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
@@ -1438,6 +1451,7 @@ public boolean renameTo(File dest) {
if (dest == null) {
throw new NullPointerException();
}
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
@@ -1477,6 +1491,7 @@ public boolean renameTo(File dest) {
*/
public boolean setLastModified(long time) {
if (time < 0) throw new IllegalArgumentException("Negative time");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
@@ -1507,6 +1522,7 @@ public boolean setLastModified(long time) {
* @since 1.2
*/
public boolean setReadOnly() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
@@ -1550,6 +1566,7 @@ public boolean setReadOnly() {
* @since 1.6
*/
public boolean setWritable(boolean writable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
@@ -1628,6 +1645,7 @@ public boolean setWritable(boolean writable) {
* @since 1.6
*/
public boolean setReadable(boolean readable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
@@ -1709,6 +1727,7 @@ public boolean setReadable(boolean readable) {
* @since 1.6
*/
public boolean setExecutable(boolean executable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
@@ -1772,6 +1791,7 @@ public boolean setExecutable(boolean executable) {
* @since 1.6
*/
public boolean canExecute() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkExec(path);
@@ -1854,6 +1874,7 @@ public boolean canExecute() {
* @see FileStore#getTotalSpace
*/
public long getTotalSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
@@ -1897,6 +1918,7 @@ public long getTotalSpace() {
* @see FileStore#getUnallocatedSpace
*/
public long getFreeSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
@@ -1943,6 +1965,7 @@ public long getFreeSpace() {
* @see FileStore#getUsableSpace
*/
public long getUsableSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
@@ -1977,6 +2000,7 @@ private static int shortenSubName(int subNameLength, int excess,
}
return subNameLength;
}
@SuppressWarnings("removal")
static File generateFile(String prefix, String suffix, File dir)
throws IOException
{
@@ -2125,6 +2149,7 @@ public static File createTempFile(String prefix, String suffix,

File tmpdir = (directory != null) ? directory
: TempDirectory.location();
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
File f;
do {