8312444: Delete unused parameters and variables in SocketPermission

Reviewed-by: gli, aturbanov, dfuchs
This commit is contained in:
Korov 2024-03-12 15:55:19 +00:00 committed by Daniel Fuchs
parent 782206bc97
commit 379ad1fbb4

View file

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -188,8 +188,6 @@ public final class SocketPermission extends Permission
// various port constants
private static final int PORT_MIN = 0;
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
private transient int mask;
@ -242,9 +240,9 @@ public final class SocketPermission extends Permission
// lazy initializer
private static class EphemeralRange {
static final int low = initEphemeralPorts("low", DEF_EPH_LOW);
static final int high = initEphemeralPorts("high", PORT_MAX);
};
static final int low = initEphemeralPorts("low");
static final int high = initEphemeralPorts("high");
}
private static synchronized Debug getDebug() {
if (!debugInit) {
@ -342,10 +340,7 @@ public final class SocketPermission extends Permission
}
}
private int[] parsePort(String port)
throws Exception
{
private int[] parsePort(String port) {
if (port == null || port.isEmpty() || port.equals("*")) {
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.
char ch = host.charAt(0);
if (ch == ':' || IPAddressUtil.digit(ch, 16) != -1) {
byte ip[] = IPAddressUtil.textToNumericFormatV4(host);
byte[] ip = IPAddressUtil.textToNumericFormatV4(host);
if (ip == null) {
ip = IPAddressUtil.textToNumericFormatV6(host);
}
@ -521,8 +516,6 @@ public final class SocketPermission extends Permission
char[] a = action.toCharArray();
int i = a.length - 1;
if (i < 0)
return mask;
while (i != -1) {
char c;
@ -625,7 +618,7 @@ public final class SocketPermission extends Permission
}
if (!match(cname, hostname)) {
// Last chance
if (!authorized(hostname, addresses[0].getAddress())) {
if (!authorized(addresses[0].getAddress())) {
untrusted = true;
Debug debug = getDebug();
if (debug != null && Debug.isOn("failure")) {
@ -711,16 +704,16 @@ public final class SocketPermission extends Permission
return !cdomain.isEmpty() && !hdomain.isEmpty() && cdomain.equals(hdomain);
}
private boolean authorized(String cname, byte[] addr) {
private boolean authorized(byte[] addr) {
if (addr.length == 4)
return authorizedIPv4(cname, addr);
return authorizedIPv4(addr);
else if (addr.length == 16)
return authorizedIPv6(cname, addr);
return authorizedIPv6(addr);
else
return false;
}
private boolean authorizedIPv4(String cname, byte[] addr) {
private boolean authorizedIPv4(byte[] addr) {
String authHost = "";
InetAddress auth;
@ -749,7 +742,7 @@ public final class SocketPermission extends Permission
return false;
}
private boolean authorizedIPv6(String cname, byte[] addr) {
private boolean authorizedIPv6(byte[] addr) {
String authHost = "";
InetAddress auth;
@ -854,8 +847,6 @@ public final class SocketPermission extends Permission
*/
@Override
public boolean implies(Permission p) {
int i,j;
if (!(p instanceof SocketPermission that))
return false;
@ -1221,7 +1212,7 @@ public final class SocketPermission extends Permission
* for this system. The suffix is either "high" or "low"
*/
@SuppressWarnings("removal")
private static int initEphemeralPorts(String suffix, int defval) {
private static int initEphemeralPorts(String suffix) {
return AccessController.doPrivileged(
new PrivilegedAction<>(){
public Integer run() {