8344216: Remove calls to SecurityManager and and doPrivileged in java.net.Authenticator, java.net.CookieHandler, and java.net.ResponseCache after JEP 486 integration

Reviewed-by: dfuchs
This commit is contained in:
Eirik Bjørsnøs 2024-11-15 19:21:30 +00:00
parent f62e05ee96
commit 73fd8919f5
4 changed files with 1 additions and 86 deletions

View File

@ -112,14 +112,6 @@ class Authenticator {
* any previously set authenticator is removed.
*/
public static synchronized void setDefault(Authenticator a) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission setDefaultPermission
= new NetPermission("setDefaultAuthenticator");
sm.checkPermission(setDefaultPermission);
}
theAuthenticator = a;
}
@ -130,13 +122,6 @@ class Authenticator {
* @since 9
*/
public static Authenticator getDefault() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission requestPermission
= new NetPermission("requestPasswordAuthentication");
sm.checkPermission(requestPermission);
}
return theAuthenticator;
}
@ -161,14 +146,6 @@ class Authenticator {
String prompt,
String scheme) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission requestPermission
= new NetPermission("requestPasswordAuthentication");
sm.checkPermission(requestPermission);
}
Authenticator a = theAuthenticator;
if (a == null) {
return null;
@ -212,14 +189,6 @@ class Authenticator {
String prompt,
String scheme) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission requestPermission
= new NetPermission("requestPasswordAuthentication");
sm.checkPermission(requestPermission);
}
Authenticator a = theAuthenticator;
if (a == null) {
return null;
@ -267,14 +236,6 @@ class Authenticator {
URL url,
RequestorType reqType) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission requestPermission
= new NetPermission("requestPasswordAuthentication");
sm.checkPermission(requestPermission);
}
Authenticator a = theAuthenticator;
if (a == null) {
return null;
@ -328,14 +289,6 @@ class Authenticator {
URL url,
RequestorType reqType) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
NetPermission requestPermission
= new NetPermission("requestPasswordAuthentication");
sm.checkPermission(requestPermission);
}
Authenticator a = authenticator == null ? theAuthenticator : authenticator;
if (a == null) {
return null;

View File

@ -28,7 +28,6 @@ package java.net;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import sun.security.util.SecurityConstants;
/**
* A CookieHandler object provides a callback mechanism to hook up a
@ -73,11 +72,6 @@ public abstract class CookieHandler {
* @see #setDefault(CookieHandler)
*/
public static synchronized CookieHandler getDefault() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.GET_COOKIEHANDLER_PERMISSION);
}
return cookieHandler;
}
@ -91,11 +85,6 @@ public abstract class CookieHandler {
* @see #getDefault()
*/
public static synchronized void setDefault(CookieHandler cHandler) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.SET_COOKIEHANDLER_PERMISSION);
}
cookieHandler = cHandler;
}

View File

@ -28,7 +28,6 @@ package java.net;
import java.io.IOException;
import java.util.Map;
import java.util.List;
import sun.security.util.SecurityConstants;
/**
* Represents implementations of URLConnection caches. An instance of
@ -84,11 +83,6 @@ public abstract class ResponseCache {
* @since 1.5
*/
public static synchronized ResponseCache getDefault() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.GET_RESPONSECACHE_PERMISSION);
}
return theResponseCache;
}
@ -104,11 +98,6 @@ public abstract class ResponseCache {
* @since 1.5
*/
public static synchronized void setDefault(ResponseCache responseCache) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.SET_RESPONSECACHE_PERMISSION);
}
theResponseCache = responseCache;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2024, 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
@ -80,22 +80,6 @@ public final class SecurityConstants {
public static final NetPermission GET_PROXYSELECTOR_PERMISSION =
new NetPermission("getProxySelector");
// java.net.CookieHandler
public static final NetPermission SET_COOKIEHANDLER_PERMISSION =
new NetPermission("setCookieHandler");
// java.net.CookieHandler
public static final NetPermission GET_COOKIEHANDLER_PERMISSION =
new NetPermission("getCookieHandler");
// java.net.ResponseCache
public static final NetPermission SET_RESPONSECACHE_PERMISSION =
new NetPermission("setResponseCache");
// java.net.ResponseCache
public static final NetPermission GET_RESPONSECACHE_PERMISSION =
new NetPermission("getResponseCache");
// java.net.ServerSocket, java.net.Socket
public static final NetPermission SET_SOCKETIMPL_PERMISSION =
new NetPermission("setSocketImpl");