Class NetIORequest
public class NetIORequest implements ISecurityRequest
{
// Fields
public static final int ACCEPT;
public static final int CONNECT;
public static final int LISTEN;
public static final int MULTICAST;
// Constructors
public NetIORequest (int accesstype, String hostname);
public NetIORequest (int accesstype, String hostname, int port);
public NetIORequest (int accesstype, int port);
public NetIORequest (int accesstype, InetAddress addr, int ttl);
public NetIORequest (int accesstype, InetAddress addr);
// Methods
public PermissionID getPermissionID();
public String toString ();
}
This class represents a request to perform a network-related action. Use NetIORequest objects as the security request objects for parameterized security checks involving the networking I/O permission. The NetIOPermission.check method expects a NetIORequest object as its parameter.
This example shows how to use a NetIORequest object to perform a security check.
...
// Create a NetIORequest that indicates that you want to
// connect to the host 'any.thing.com'.
NetIORequest sreq = new NetIORequest(NetIORequest.CONNECT,
"any.thing.com");
// Check to see that all of your callers have the rights to
// connect to that host.
PolicyEngine.checkPermission(sreq);
...
For more information about checking networking permissions, see the PolicyEngine class and the NetIOPermission class.
public NetIORequest (int accesstype, String hostname);
Creates a networking I/O request that specifies an attempt to connect to the specified host or to receive connections from the specified host.
Parameter | Description |
accesstype
| The type of access requested.
|
hostname
| The name of the host.
|
public NetIORequest (int accesstype, String hostname, int port);
Creates a networking I/O request that specifies an attempt to connect to the specified host/port or to receive connections from the specified host on the specified port.
Parameter | Description |
accesstype
| The type of access requested. The value must be CONNECT or ACCEPT.
|
hostname
| The network host to access.
|
port
| The port to access.
|
public NetIORequest (int accesstype, int port);
Creates a networking I/O request that specifies an attempt to listen for networking connections on the specified port.
Parameter | Description |
accesstype
| The type of access requested. The value should be LISTEN.
|
port
| The local port number to listen on.
|
public NetIORequest (int accesstype, InetAddress addr, int ttl);
Creates a networking I/O request that specifies an attempt to perform a multicast operation to the specified Internet address with the specified time to live value.
Parameter | Description |
accesstype
| The type of access requested. The value should be MULTICAST.
|
addr
| The Internet address.
|
ttl
| The time to live value.
|
public NetIORequest (int accesstype, InetAddress addr);
Creates a networking I/O request that specifies an attempt to perform a multicast operation to the specified Internet address.
Parameter | Description |
accesstype
| The type of access requested. The value should be MULTICAST.
|
addr
| The Internet address.
|
public PermissionID getPermissionID();
Retrieves the permission identifier for the NetIORequest object.
Return Value:
Returns PermissionID.NETIO.
Remarks:
This method satisfies the ISecurityRequest interface and returns PermissionID.NETIO to indicate that instances of the NetIORequest class are associated with the networking permission.
public String toString ();
Converts the NetIORequest object to its string representation.
Return Value:
Returns the string representation of the NetIORequest object.
- ACCEPT
- The network I/O access type that indicates an attempt to accept network connections from a remote computer.
- CONNECT
- The network I/O access type that indicates an attempt to initiate a connection with a remote machine.
- LISTEN
- The network I/O access type that indicates an attempt to listen for networking connections on a local port.
- MULTICAST
- The network I/O access type that indicates an attempt to perform a multicast socket operation.