Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.net

Class SocketPermission

java.lang.Object
|
+--java.security.Permission
   |
   +--java.net.SocketPermission

All Implemented Interfaces:

Serializable, Guard, Serializable


public final class SocketPermission

extends Permission

implements Serializable

This class models a specific set of permssions for connecting to a host. There are two elements to this, the host/port combination and the permission list.

The host/port combination is specified as followed

 hostname[:[-]port[-[port]]]
 

The hostname portion can be either a hostname or IP address. If it is a hostname, a wildcard is allowed in hostnames. This wildcard is a "*" and matches one or more characters. Only one "*" may appear in the host and it must be the leftmost character. For example, "*.urbanophile.com" matches all hosts in the "urbanophile.com" domain.

The port portion can be either a single value, or a range of values treated as inclusive. The first or the last port value in the range can be omitted in which case either the minimum or maximum legal value for a port (respectively) is used by default. Here are some examples:

The permission list is a comma separated list of individual permissions. These individual permissions are:

accept
connect
listen
resolve

The "listen" permission is only relevant if the host is localhost. If any permission at all is specified, then resolve permission is implied to exist.

Here are a variety of examples of how to create SocketPermission's

 SocketPermission("www.urbanophile.com", "connect");
   Can connect to any port on www.urbanophile.com
 SocketPermission("www.urbanophile.com:80", "connect,accept");
   Can connect to or accept connections from www.urbanophile.com on port 80
 SocketPermission("localhost:1024-", "listen,accept,connect");
   Can connect to, accept from, an listen on any local port number 1024
   and up.
 SocketPermission("*.edu", "connect");
   Can connect to any host in the edu domain
 SocketPermission("197.197.20.1", "accept");
   Can accept connections from 197.197.20.1
 

Since:Author:

Constructor Summary

SocketPermission(java.lang.String hostport, java.lang.String actions)

Initializes a new instance of SocketPermission with the specified host/port combination and actions string.

Method Summary

booleanequals(java.lang.Object obj)

Tests this object for equality against another.
java.lang.StringgetActions()

Returns the list of permission actions in this object in canonical order.
inthashCode()

Returns a hash code value for this object.
booleanimplies(java.security.Permission perm)

Returns true if the permission object passed it is implied by the this permission.
java.security.PermissionCollectionnewPermissionCollection()

Returns a new PermissionCollection object that can hold SocketPermission's.

Constructor Details

SocketPermission

public SocketPermission(java.lang.String hostport, java.lang.String actions)

Initializes a new instance of SocketPermission with the specified host/port combination and actions string.

Parameters:


Method Details

equals

public boolean equals(java.lang.Object obj)

Tests this object for equality against another. This will be true if and only if the passed object is an instance of SocketPermission and both its hostname/port combination and permissions string are identical.

Parameters:

Returns:


getActions

public String getActions()

Returns the list of permission actions in this object in canonical order. The canonical order is "connect,listen,accept,resolve"

Returns:


hashCode

public int hashCode()

Returns a hash code value for this object. Overrides the Permission.hashCode()

Returns:


implies

public boolean implies(java.security.Permission perm)

Returns true if the permission object passed it is implied by the this permission. This will be true if

The argument's hostname will be a subset of this object's hostname if:

Parameters:

Returns:


newPermissionCollection

public PermissionCollection newPermissionCollection()

Returns a new PermissionCollection object that can hold SocketPermission's.

Returns: