public final class

SocketPermission

extends Permission
implements Serializable
java.lang.Object
   ↳ java.security.Permission
     ↳ java.net.SocketPermission

Class Overview

Regulates the access to network operations available through sockets through permissions. A permission consists of a target (a host), and an associated action list. The target should identify the host by either indicating the (possibly wildcarded (eg. .company.com)) DNS style name of the host or its IP address in standard nn.nn.nn.nn ("dot") notation. The action list can be made up of one or more of the following actions separated by a comma:

connect
requests permission to connect to the host
listen
requests permission to listen for connections from the host
accept
requests permission to accept connections from the host
resolve
requests permission to resolve the hostname
Note that resolve is implied when any (or none) of the others are present.

Access to a particular port can be requested by appending a colon and a single digit to the name (eg. .company.com:7000). A range of port numbers can also be specified, by appending a pattern of the form LOW-HIGH where LOW and HIGH are valid port numbers. If either LOW or HIGH is omitted it is equivalent to entering the lowest or highest possible value respectively. For example:

 SocketPermission("www.company.com:7000-", "connect,accept")
 
represents the permission to connect to and accept connections from www.company.com on ports in the range 7000 to 65535.

Summary

Public Constructors
SocketPermission(String host, String action)
Constructs a new SocketPermission instance.
Public Methods
boolean equals(Object o)
Compares the argument o to this instance and returns true if they represent the same permission using a class specific comparison.
String getActions()
Gets a comma-separated list of all actions allowed by this permission.
int hashCode()
Returns the hash value for this SocketPermission instance.
boolean implies(Permission p)
Checks whether this SocketPermission instance allows all actions which are allowed by the given permission object p.
PermissionCollection newPermissionCollection()
Creates a new PermissionCollection to store SocketPermission objects.
[Expand]
Inherited Methods
From class java.security.Permission
From class java.lang.Object
From interface java.security.Guard

Public Constructors

public SocketPermission (String host, String action)

Constructs a new SocketPermission instance. The hostname can be a DNS name, an individual hostname, an IP address or the empty string which implies localhost. The port or port range is optional.

The action list is a comma-separated list which can consists of the possible operations "connect", "listen", "accept" , and "resolve". They are case-insensitive and can be put together in any order. "resolve" is implied per default.

Parameters
host the hostname this permission is valid for.
action the action string of this permission.

Public Methods

public boolean equals (Object o)

Compares the argument o to this instance and returns true if they represent the same permission using a class specific comparison.

Parameters
o the object to compare with this SocketPermission instance.
Returns
  • true if they represent the same permission, false otherwise.
See Also

public String getActions ()

Gets a comma-separated list of all actions allowed by this permission. If more than one action is returned they follow this order: connect, listen, accept, resolve.

Returns
  • the comma-separated action list.

public int hashCode ()

Returns the hash value for this SocketPermission instance. Any two objects which returns true when passed to equals() must return the same value as a result of this method.

Returns
  • the hashcode value for this instance.
See Also

public boolean implies (Permission p)

Checks whether this SocketPermission instance allows all actions which are allowed by the given permission object p. All argument permission actions, hosts and ports must be implied by this permission instance in order to return true. This permission may imply additional actions not present in the argument permission.

Parameters
p the socket permission which has to be implied by this instance.
Returns
  • true if this permission instance implies all permissions represented by p, false otherwise.

public PermissionCollection newPermissionCollection ()

Creates a new PermissionCollection to store SocketPermission objects.

Returns
  • the new permission collection.