8353642: Deprecate URL::getPermission method and networking permission classes for removal

Reviewed-by: djelinski, iris, mullan, michaelm
This commit is contained in:
Daniel Fuchs 2025-05-12 16:49:42 +00:00
parent 8d7866ef5f
commit 45dfc2c6d6
11 changed files with 37 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2025, 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
@ -606,7 +606,13 @@ public abstract class HttpURLConnection extends URLConnection {
* @return a {@code SocketPermission} object representing the
* permission necessary to connect to the destination
* host and port.
*
* @deprecated
* Permissions can no longer be used for controlling access to resources
* as the Security Manager is no longer supported.
*/
@Deprecated(since = "25", forRemoval = true)
@SuppressWarnings("removal")
public Permission getPermission() throws IOException {
int port = url.getPort();
port = port < 0 ? 80 : port;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
@ -40,7 +40,7 @@ import java.security.*;
* to signify a wildcard match. For example: "foo.*" and "*" signify a wildcard
* match, while "*foo" and "a*b" do not.
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -56,6 +56,7 @@ import java.security.*;
* @since 1.2
*/
@Deprecated(since = "25", forRemoval = true)
public final class NetPermission extends BasicPermission {
@java.io.Serial
private static final long serialVersionUID = -8343910153355041693L;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2025, 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
@ -822,7 +822,12 @@ public abstract class URLConnection {
* @throws IOException if the computation of the permission
* requires network or file I/O and an exception occurs while
* computing it.
*
* @deprecated
* Permissions can no longer be used for controlling access to resources
* as the Security Manager is no longer supported.
*/
@Deprecated(since = "25", forRemoval = true)
public Permission getPermission() throws IOException {
return SecurityConstants.ALL_PERMISSION;
}

View File

@ -143,7 +143,7 @@ import java.util.Objects;
* with initial letter of each word capitalized). Either list can contain a wild-card '*'
* character which signifies all request methods or headers respectively.
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -154,6 +154,7 @@ import java.util.Objects;
* RFC 2732: Format for Literal IPv6 Addresses in URL's
* @since 1.8
*/
@Deprecated(since = "25", forRemoval = true)
public final class URLPermission extends Permission {
@java.io.Serial

View File

@ -210,6 +210,8 @@ public class FileURLConnection extends URLConnection {
/* since getOutputStream isn't supported, only read permission is
* relevant
*/
@Override
@Deprecated(since = "25", forRemoval = true)
@SuppressWarnings("removal")
public Permission getPermission() throws IOException {
if (permission == null) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2025, 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
@ -569,6 +569,8 @@ public class FtpURLConnection extends URLConnection {
* @return The {@code Permission} object.
*/
@Override
@Deprecated(since = "25", forRemoval = true)
@SuppressWarnings("removal")
public Permission getPermission() {
if (permission == null) {
int urlport = url.getPort();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2025, 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
@ -355,6 +355,9 @@ public class HttpsURLConnectionImpl
return delegate.getHeaderFieldDate(name, defaultValue);
}
@Override
@Deprecated(since = "25", forRemoval = true)
@SuppressWarnings("removal")
public Permission getPermission() throws IOException {
return delegate.getPermission();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
@ -77,6 +77,9 @@ public class JarURLConnection extends java.net.JarURLConnection {
return jarEntry;
}
@Override
@Deprecated(since = "25", forRemoval = true)
@SuppressWarnings("removal")
public Permission getPermission() throws IOException {
return jarFileURLConnection.getPermission();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2025, 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,7 +28,6 @@ package sun.nio.ch;
import java.io.FileDescriptor;
import java.io.IOException;
import java.net.BindException;
import java.net.NetPermission;
import java.net.SocketAddress;
import java.net.UnixDomainSocketAddress;
import java.nio.channels.UnsupportedAddressTypeException;
@ -52,9 +51,6 @@ class UnixDomainSockets {
private static final String tempDir = UnixDomainSocketsUtil.getTempDir();
private static final NetPermission accessUnixDomainSocket =
new NetPermission("accessUnixDomainSocket");
static boolean isSupported() {
return supported;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, 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
@ -42,6 +42,7 @@ final class UNCFileURLConnection extends FileURLConnection {
@Override
@SuppressWarnings("removal")
@Deprecated(since = "25", forRemoval = true)
public Permission getPermission() {
Permission perm = permission;
if (perm == null) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, 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,7 +32,7 @@ import java.security.BasicPermission;
* defined in the jdk.net package. These permissions contain a target
* name, but no actions list. Callers either possess the permission or not.
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -41,6 +41,7 @@ import java.security.BasicPermission;
* @since 1.8
*/
@Deprecated(since = "25", forRemoval = true)
public final class NetworkPermission extends BasicPermission {
private static final long serialVersionUID = -2012939586906722291L;