Additional top-level class in compilation unit: SocketPermissionCollection.
host = (hostname | IPv4address | iPv6reference) [:portrange] portrange = portnumber | -portnumber | portnumber-[portnumber]The host is expressed as a DNS name, as a numerical IP address, or as "localhost" (for the local machine). The wildcard "*" may be included once in a DNS name host specification. If it is included, it must be in the leftmost position, as in "*.example.com".
The format of the IPv6reference should follow that specified in RFC 2732: Format for Literal IPv6 Addresses in URLs:
ipv6reference = "[" IPv6address "]"For example, you can construct a SocketPermission instance as the following:
String hostAddress = inetaddress.getHostAddress(); if (inetaddress instanceof Inet6Address) { sp = new SocketPermission("[" + hostAddress + "]:" + port, action); } else { sp = new SocketPermission(hostAddress + ":" + port, action); }or
String host = url.getHost(); sp = new SocketPermission(host + ":" + port, action);
The full uncompressed form of an IPv6 literal address is also valid.
The port or portrange is optional. A port specification of the
form "N-", where N is a port number, signifies all ports
numbered N and above, while a specification of the
form "-N" indicates all ports numbered N and below.
The special port value 0
refers to the entire ephemeral
port range. This is a fixed range of ports a system may use to
allocate dynamic ports from. The actual range may be system dependent.
The possible ways to connect to the host are
accept connect listen resolveThe "listen" action is only meaningful when used with "localhost" and means the ability to bind to a specified port. The "resolve" action is implied when any of the other actions are present. The action "resolve" refers to host/ip name service lookups.
The actions string is converted to lowercase before processing.
API Note
This permission cannot be used for controlling access to resources as the Security Manager is no longer supported.
java.security.Permissions
, SocketPermission
Modifier and Type | Class and Description |
---|---|
private static class |
Modifier and Type | Field and Description |
---|---|
private static final int | ACCEPT
Accept a connection from host:port |
private String | actions
the actions string. |
private transient InetAddress[] | |
private static final int | ALL
All actions |
private transient String | |
private transient String | |
private static final int | CONNECT
Connect to host:port |
private static Debug | |
private static boolean | |
private transient boolean | |
private transient String | |
private transient String | |
private transient boolean | |
private transient boolean | |
private static final int | LISTEN
Listen on host:port |
private transient int | |
private static final int | NONE
No actions |
private static final int | |
private static final int | |
private transient int[] | |
private static final int | RESOLVE
Resolve DNS queries |
private static final long | |
private transient boolean | |
private static final boolean | |
private transient boolean | |
private transient boolean |
Access | Constructor and Description |
---|---|
public | SocketPermission(String
the hostname or IP address of the computer, optionally
including a colon followed by a port or port range. host, String the action string. action)Creates a new SocketPermission object with the specified actions. |
pack-priv |
Modifier and Type | Method and Description |
---|---|
private boolean | |
private boolean | |
private boolean | |
private static String | checkForIDN(String name)
previously we allowed domain names to be specified in IDN ACE form Need to check for that and convert to Unicode |
private boolean | |
public boolean | Returns: true if obj is a SocketPermission, and has the same hostname, port range, and actions as this SocketPermission object. However, port range will be ignored in the comparison if obj only contains the action, 'resolve'.the object to test for equality with this object. obj)Implements abstract java. Checks two SocketPermission objects for equality. |
private static String | Returns: the canonical string representation of the actionsa specific integer action mask to translate into a string mask)Returns the "canonical string representation" of the actions in the specified mask. |
public String | Returns: the canonical string representation of the actions.Implements abstract java. Returns the canonical string representation of the actions. |
pack-priv void | |
private static synchronized Debug | |
private static String | |
pack-priv void | |
private static int | |
pack-priv int | |
public int | Returns: a hash code value for this object.Implements abstract java. Returns the hash code value for this object. |
public boolean | Returns: true if the specified permission is implied by this object, false if not.the permission to check against. p)Implements abstract java. Checks if this socket permission object "implies" the specified permission. |
pack-priv boolean | Returns: true if "permission" is a proper subset of the current object, false if not.the incoming permission request that)Checks if the incoming Permission's action are a proper subset of this object's actions. |
private boolean | includesEphemerals()
Returns true if the permission has specified zero as its value (or lower bound) signifying the ephemeral range |
private void | |
private static int | initEphemeralPorts(String suffix)
Check the system/security property for the ephemeral port range for this system. |
private static boolean | inRange(int policyLow, int policyHigh, int targetLow, int targetHigh)
Check if the target range is within the policy range together with the ephemeral range for this platform (if policy includes ephemeral range) |
private boolean | |
private boolean | |
public PermissionCollection | Returns: a new PermissionCollection object suitable for storing SocketPermissions.Overrides java. Returns a new PermissionCollection object for storing SocketPermission objects. |
private int[] | |
private synchronized void | readObject(ObjectInputStream
the s)ObjectInputStream from which data is read
|
private void | |
private synchronized void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to which data is written
|
ACCEPT | back to summary |
---|---|
private static final int ACCEPT Accept a connection from host:port |
actions | back to summary |
---|---|
private String actions the actions string. |
addresses | back to summary |
---|---|
private transient InetAddress[] addresses |
ALL | back to summary |
---|---|
private static final int ALL All actions |
cdomain | back to summary |
---|---|
private transient String cdomain |
cname | back to summary |
---|---|
private transient String cname |
CONNECT | back to summary |
---|---|
private static final int CONNECT Connect to host:port |
debug | back to summary |
---|---|
private static Debug debug |
debugInit | back to summary |
---|---|
private static boolean debugInit |
defaultDeny | back to summary |
---|---|
private transient boolean defaultDeny |
hdomain | back to summary |
---|---|
private transient String hdomain |
hostname | back to summary |
---|---|
private transient String hostname |
init_with_ip | back to summary |
---|---|
private transient boolean init_with_ip |
invalid | back to summary |
---|---|
private transient boolean invalid |
LISTEN | back to summary |
---|---|
private static final int LISTEN Listen on host:port |
mask | back to summary |
---|---|
private transient int mask |
NONE | back to summary |
---|---|
private static final int NONE No actions |
PORT_MAX | back to summary |
---|---|
private static final int PORT_MAX |
PORT_MIN | back to summary |
---|---|
private static final int PORT_MIN |
portrange | back to summary |
---|---|
private transient int[] portrange |
RESOLVE | back to summary |
---|---|
private static final int RESOLVE Resolve DNS queries |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Hides java. |
trusted | back to summary |
---|---|
private transient boolean trusted |
trustNameService | back to summary |
---|---|
private static final boolean trustNameService |
untrusted | back to summary |
---|---|
private transient boolean untrusted |
wildcard | back to summary |
---|---|
private transient boolean wildcard |
SocketPermission | back to summary |
---|---|
public SocketPermission(String host, String action) Creates a new SocketPermission object with the specified actions. The host is expressed as a DNS name, or as a numerical IP address. Optionally, a port or a portrange may be supplied (separated from the DNS name or IP address by a colon). To specify the local machine, use "localhost" as the host. Also note: An empty host String ("") is equivalent to "localhost". The actions parameter contains a comma-separated list of the actions granted for the specified host (and port(s)). Possible actions are "connect", "listen", "accept", "resolve", or any combination of those. "resolve" is automatically added when any of the other three are specified. Examples of SocketPermission instantiation are the following: nr = new SocketPermission("www.example.com", "connect"); nr = new SocketPermission("www.example.com:80", "connect"); nr = new SocketPermission("*.example.com", "connect"); nr = new SocketPermission("*.edu", "resolve"); nr = new SocketPermission("204.160.241.0", "connect"); nr = new SocketPermission("localhost:1024-65535", "listen"); nr = new SocketPermission("204.160.241.0:1024-65535", "connect");
|
SocketPermission | back to summary |
---|---|
pack-priv SocketPermission(String host, int mask) |
authorized | back to summary |
---|---|
private boolean authorized(byte[] addr) |
authorizedIPv4 | back to summary |
---|---|
private boolean authorizedIPv4(byte[] addr) |
authorizedIPv6 | back to summary |
---|---|
private boolean authorizedIPv6(byte[] addr) |
checkForIDN | back to summary |
---|---|
private static String checkForIDN(String name) previously we allowed domain names to be specified in IDN ACE form Need to check for that and convert to Unicode |
compareHostnames | back to summary |
---|---|
private boolean compareHostnames(SocketPermission that) |
equals | back to summary |
---|---|
public boolean equals(Object obj) Implements abstract java. Checks two SocketPermission objects for equality.
|
getActions | back to summary |
---|---|
private static String getActions(int mask) Returns the "canonical string representation" of the actions in the specified mask. Always returns present actions in the following order: connect, listen, accept, resolve.
|
getActions | back to summary |
---|---|
public String getActions() Implements abstract java. Returns the canonical string representation of the actions. Always returns present actions in the following order: connect, listen, accept, resolve. |
getCanonName | back to summary |
---|---|
pack-priv void getCanonName() throws UnknownHostException attempt to get the fully qualified domain name |
getDebug | back to summary |
---|---|
private static synchronized Debug getDebug() |
getHost | back to summary |
---|---|
private static String getHost(String host) |
getIP | back to summary |
---|---|
pack-priv void getIP() throws UnknownHostException get IP addresses. Sets invalid to true if we can't get them. |
getMask | back to summary |
---|---|
private static int getMask(String action) Convert an action string to an integer actions mask.
|
getMask | back to summary |
---|---|
pack-priv int getMask() Return the current action mask.
|
hashCode | back to summary |
---|---|
public int hashCode() Implements abstract java. Returns the hash code value for this object.
|
implies | back to summary |
---|---|
public boolean implies(Permission p) Implements abstract java. Checks if this socket permission object "implies" the specified permission. More specifically, this method first ensures that all of the following are true (and returns false if any of them are not):
implies checks each of the following, in order,
and for each returns true if the stated condition is true:
implies returns false.
|
impliesIgnoreMask | back to summary |
---|---|
pack-priv boolean impliesIgnoreMask(SocketPermission that) Checks if the incoming Permission's action are a proper subset of this object's actions. Check, in the following order:
|
includesEphemerals | back to summary |
---|---|
private boolean includesEphemerals() Returns true if the permission has specified zero as its value (or lower bound) signifying the ephemeral range |
init | back to summary |
---|---|
private void init(String host, int mask) Initialize the SocketPermission object. We don't do any DNS lookups as this point, instead we hold off until the implies method is called. |
initEphemeralPorts | back to summary |
---|---|
private static int initEphemeralPorts(String suffix) Check the system/security property for the ephemeral port range for this system. The suffix is either "high" or "low" |
inRange | back to summary |
---|---|
private static boolean inRange(int policyLow, int policyHigh, int targetLow, int targetHigh) Check if the target range is within the policy range together with the ephemeral range for this platform (if policy includes ephemeral range) |
isUntrusted | back to summary |
---|---|
private boolean isUntrusted() throws UnknownHostException |
match | back to summary |
---|---|
private boolean match(String cname, String hname) |
newPermissionCollection | back to summary |
---|---|
public PermissionCollection newPermissionCollection() Overrides java. Returns a new PermissionCollection object for storing SocketPermission objects.
SocketPermission objects must be stored in a manner that allows them
to be inserted into the collection in any order, but that also enables the
PermissionCollection
|
parsePort | back to summary |
---|---|
private int[] parsePort(String port) |
readObject | back to summary |
---|---|
private synchronized void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
|
setDeny | back to summary |
---|---|
private void setDeny() |
writeObject | back to summary |
---|---|
private synchronized void writeObject(ObjectOutputStream s) throws IOException
|
Modifier and Type | Field and Description |
---|---|
pack-priv static final int | |
pack-priv static final int |
Access | Constructor and Description |
---|---|
private |
high | back to summary |
---|---|
pack-priv static final int high |
low | back to summary |
---|---|
pack-priv static final int low |
EphemeralRange | back to summary |
---|---|
private EphemeralRange() |