mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8312444: Delete unused parameters and variables in SocketPermission
Reviewed-by: gli, aturbanov, dfuchs
This commit is contained in:
parent
782206bc97
commit
379ad1fbb4
1 changed files with 15 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -178,7 +178,7 @@ public final class SocketPermission extends Permission
|
||||||
/**
|
/**
|
||||||
* No actions
|
* No actions
|
||||||
*/
|
*/
|
||||||
private static final int NONE = 0x0;
|
private static final int NONE = 0x0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All actions
|
* All actions
|
||||||
|
@ -188,8 +188,6 @@ public final class SocketPermission extends Permission
|
||||||
// various port constants
|
// various port constants
|
||||||
private static final int PORT_MIN = 0;
|
private static final int PORT_MIN = 0;
|
||||||
private static final int PORT_MAX = 65535;
|
private static final int PORT_MAX = 65535;
|
||||||
private static final int PRIV_PORT_MAX = 1023;
|
|
||||||
private static final int DEF_EPH_LOW = 49152;
|
|
||||||
|
|
||||||
// the actions mask
|
// the actions mask
|
||||||
private transient int mask;
|
private transient int mask;
|
||||||
|
@ -242,9 +240,9 @@ public final class SocketPermission extends Permission
|
||||||
|
|
||||||
// lazy initializer
|
// lazy initializer
|
||||||
private static class EphemeralRange {
|
private static class EphemeralRange {
|
||||||
static final int low = initEphemeralPorts("low", DEF_EPH_LOW);
|
static final int low = initEphemeralPorts("low");
|
||||||
static final int high = initEphemeralPorts("high", PORT_MAX);
|
static final int high = initEphemeralPorts("high");
|
||||||
};
|
}
|
||||||
|
|
||||||
private static synchronized Debug getDebug() {
|
private static synchronized Debug getDebug() {
|
||||||
if (!debugInit) {
|
if (!debugInit) {
|
||||||
|
@ -342,10 +340,7 @@ public final class SocketPermission extends Permission
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] parsePort(String port)
|
private int[] parsePort(String port) {
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
if (port == null || port.isEmpty() || port.equals("*")) {
|
if (port == null || port.isEmpty() || port.equals("*")) {
|
||||||
return new int[] {PORT_MIN, PORT_MAX};
|
return new int[] {PORT_MIN, PORT_MAX};
|
||||||
}
|
}
|
||||||
|
@ -466,7 +461,7 @@ public final class SocketPermission extends Permission
|
||||||
// see if we are being initialized with an IP address.
|
// see if we are being initialized with an IP address.
|
||||||
char ch = host.charAt(0);
|
char ch = host.charAt(0);
|
||||||
if (ch == ':' || IPAddressUtil.digit(ch, 16) != -1) {
|
if (ch == ':' || IPAddressUtil.digit(ch, 16) != -1) {
|
||||||
byte ip[] = IPAddressUtil.textToNumericFormatV4(host);
|
byte[] ip = IPAddressUtil.textToNumericFormatV4(host);
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
ip = IPAddressUtil.textToNumericFormatV6(host);
|
ip = IPAddressUtil.textToNumericFormatV6(host);
|
||||||
}
|
}
|
||||||
|
@ -521,8 +516,6 @@ public final class SocketPermission extends Permission
|
||||||
char[] a = action.toCharArray();
|
char[] a = action.toCharArray();
|
||||||
|
|
||||||
int i = a.length - 1;
|
int i = a.length - 1;
|
||||||
if (i < 0)
|
|
||||||
return mask;
|
|
||||||
|
|
||||||
while (i != -1) {
|
while (i != -1) {
|
||||||
char c;
|
char c;
|
||||||
|
@ -619,13 +612,13 @@ public final class SocketPermission extends Permission
|
||||||
if (invalid || untrusted) return true;
|
if (invalid || untrusted) return true;
|
||||||
try {
|
try {
|
||||||
if (!trustNameService && (defaultDeny ||
|
if (!trustNameService && (defaultDeny ||
|
||||||
sun.net.www.URLConnection.isProxiedHost(hostname))) {
|
sun.net.www.URLConnection.isProxiedHost(hostname))) {
|
||||||
if (this.cname == null) {
|
if (this.cname == null) {
|
||||||
this.getCanonName();
|
this.getCanonName();
|
||||||
}
|
}
|
||||||
if (!match(cname, hostname)) {
|
if (!match(cname, hostname)) {
|
||||||
// Last chance
|
// Last chance
|
||||||
if (!authorized(hostname, addresses[0].getAddress())) {
|
if (!authorized(addresses[0].getAddress())) {
|
||||||
untrusted = true;
|
untrusted = true;
|
||||||
Debug debug = getDebug();
|
Debug debug = getDebug();
|
||||||
if (debug != null && Debug.isOn("failure")) {
|
if (debug != null && Debug.isOn("failure")) {
|
||||||
|
@ -711,16 +704,16 @@ public final class SocketPermission extends Permission
|
||||||
return !cdomain.isEmpty() && !hdomain.isEmpty() && cdomain.equals(hdomain);
|
return !cdomain.isEmpty() && !hdomain.isEmpty() && cdomain.equals(hdomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean authorized(String cname, byte[] addr) {
|
private boolean authorized(byte[] addr) {
|
||||||
if (addr.length == 4)
|
if (addr.length == 4)
|
||||||
return authorizedIPv4(cname, addr);
|
return authorizedIPv4(addr);
|
||||||
else if (addr.length == 16)
|
else if (addr.length == 16)
|
||||||
return authorizedIPv6(cname, addr);
|
return authorizedIPv6(addr);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean authorizedIPv4(String cname, byte[] addr) {
|
private boolean authorizedIPv4(byte[] addr) {
|
||||||
String authHost = "";
|
String authHost = "";
|
||||||
InetAddress auth;
|
InetAddress auth;
|
||||||
|
|
||||||
|
@ -749,7 +742,7 @@ public final class SocketPermission extends Permission
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean authorizedIPv6(String cname, byte[] addr) {
|
private boolean authorizedIPv6(byte[] addr) {
|
||||||
String authHost = "";
|
String authHost = "";
|
||||||
InetAddress auth;
|
InetAddress auth;
|
||||||
|
|
||||||
|
@ -854,8 +847,6 @@ public final class SocketPermission extends Permission
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean implies(Permission p) {
|
public boolean implies(Permission p) {
|
||||||
int i,j;
|
|
||||||
|
|
||||||
if (!(p instanceof SocketPermission that))
|
if (!(p instanceof SocketPermission that))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1221,7 +1212,7 @@ public final class SocketPermission extends Permission
|
||||||
* for this system. The suffix is either "high" or "low"
|
* for this system. The suffix is either "high" or "low"
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
private static int initEphemeralPorts(String suffix, int defval) {
|
private static int initEphemeralPorts(String suffix) {
|
||||||
return AccessController.doPrivileged(
|
return AccessController.doPrivileged(
|
||||||
new PrivilegedAction<>(){
|
new PrivilegedAction<>(){
|
||||||
public Integer run() {
|
public Integer run() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue