Skip to content

Commit 45dfc2c

Browse files
committed
8353642: Deprecate URL::getPermission method and networking permission classes for removal
Reviewed-by: djelinski, iris, mullan, michaelm
1 parent 8d7866e commit 45dfc2c

11 files changed

Lines changed: 37 additions & 16 deletions

File tree

‎src/java.base/share/classes/java/net/HttpURLConnection.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -606,7 +606,13 @@ public long getHeaderFieldDate(String name, long defaultValue) {
606606
* @return a {@code SocketPermission} object representing the
607607
* permission necessary to connect to the destination
608608
* host and port.
609+
*
610+
* @deprecated
611+
* Permissions can no longer be used for controlling access to resources
612+
* as the Security Manager is no longer supported.
609613
*/
614+
@Deprecated(since = "25", forRemoval = true)
615+
@SuppressWarnings("removal")
610616
public Permission getPermission() throws IOException {
611617
int port = url.getPort();
612618
port = port < 0 ? 80 : port;

‎src/java.base/share/classes/java/net/NetPermission.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
4040
* to signify a wildcard match. For example: "foo.*" and "*" signify a wildcard
4141
* match, while "*foo" and "a*b" do not.
4242
*
43-
* @apiNote
43+
* @deprecated
4444
* This permission cannot be used for controlling access to resources
4545
* as the Security Manager is no longer supported.
4646
*
@@ -56,6 +56,7 @@
5656
* @since 1.2
5757
*/
5858

59+
@Deprecated(since = "25", forRemoval = true)
5960
public final class NetPermission extends BasicPermission {
6061
@java.io.Serial
6162
private static final long serialVersionUID = -8343910153355041693L;

‎src/java.base/share/classes/java/net/URLConnection.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -822,7 +822,12 @@ public Object getContent(Class<?>[] classes) throws IOException {
822822
* @throws IOException if the computation of the permission
823823
* requires network or file I/O and an exception occurs while
824824
* computing it.
825+
*
826+
* @deprecated
827+
* Permissions can no longer be used for controlling access to resources
828+
* as the Security Manager is no longer supported.
825829
*/
830+
@Deprecated(since = "25", forRemoval = true)
826831
public Permission getPermission() throws IOException {
827832
return SecurityConstants.ALL_PERMISSION;
828833
}

‎src/java.base/share/classes/java/net/URLPermission.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
* with initial letter of each word capitalized). Either list can contain a wild-card '*'
144144
* character which signifies all request methods or headers respectively.
145145
*
146-
* @apiNote
146+
* @deprecated
147147
* This permission cannot be used for controlling access to resources
148148
* as the Security Manager is no longer supported.
149149
*
@@ -154,6 +154,7 @@
154154
* RFC 2732: Format for Literal IPv6 Addresses in URL's
155155
* @since 1.8
156156
*/
157+
@Deprecated(since = "25", forRemoval = true)
157158
public final class URLPermission extends Permission {
158159

159160
@java.io.Serial

‎src/java.base/share/classes/sun/net/www/protocol/file/FileURLConnection.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ public synchronized InputStream getInputStream()
210210
/* since getOutputStream isn't supported, only read permission is
211211
* relevant
212212
*/
213+
@Override
214+
@Deprecated(since = "25", forRemoval = true)
213215
@SuppressWarnings("removal")
214216
public Permission getPermission() throws IOException {
215217
if (permission == null) {

‎src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -569,6 +569,8 @@ String guessContentTypeFromFilename(String fname) {
569569
* @return The {@code Permission} object.
570570
*/
571571
@Override
572+
@Deprecated(since = "25", forRemoval = true)
573+
@SuppressWarnings("removal")
572574
public Permission getPermission() {
573575
if (permission == null) {
574576
int urlport = url.getPort();

‎src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -355,6 +355,9 @@ public long getHeaderFieldDate(String name, long defaultValue) {
355355
return delegate.getHeaderFieldDate(name, defaultValue);
356356
}
357357

358+
@Override
359+
@Deprecated(since = "25", forRemoval = true)
360+
@SuppressWarnings("removal")
358361
public Permission getPermission() throws IOException {
359362
return delegate.getPermission();
360363
}

‎src/java.base/share/classes/sun/net/www/protocol/jar/JarURLConnection.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -77,6 +77,9 @@ public JarEntry getJarEntry() throws IOException {
7777
return jarEntry;
7878
}
7979

80+
@Override
81+
@Deprecated(since = "25", forRemoval = true)
82+
@SuppressWarnings("removal")
8083
public Permission getPermission() throws IOException {
8184
return jarFileURLConnection.getPermission();
8285
}

‎src/java.base/share/classes/sun/nio/ch/UnixDomainSockets.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
2828
import java.io.FileDescriptor;
2929
import java.io.IOException;
3030
import java.net.BindException;
31-
import java.net.NetPermission;
3231
import java.net.SocketAddress;
3332
import java.net.UnixDomainSocketAddress;
3433
import java.nio.channels.UnsupportedAddressTypeException;
@@ -52,9 +51,6 @@ private static class UnnamedHolder {
5251

5352
private static final String tempDir = UnixDomainSocketsUtil.getTempDir();
5453

55-
private static final NetPermission accessUnixDomainSocket =
56-
new NetPermission("accessUnixDomainSocket");
57-
5854
static boolean isSupported() {
5955
return supported;
6056
}

‎src/java.base/windows/classes/sun/net/www/protocol/file/UNCFileURLConnection.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@ final class UNCFileURLConnection extends FileURLConnection {
4242

4343
@Override
4444
@SuppressWarnings("removal")
45+
@Deprecated(since = "25", forRemoval = true)
4546
public Permission getPermission() {
4647
Permission perm = permission;
4748
if (perm == null) {

0 commit comments

Comments
 (0)