CLDC 1.1.1

javax.microedition.io
Class DatagramProtocolPermission

java.lang.Object
  extended byjava.security.Permission
      extended byjavax.microedition.io.GCFPermission
          extended byjavax.microedition.io.DatagramProtocolPermission

public final class DatagramProtocolPermission
extends GCFPermission

This class represents access rights to connections via the "datagram" protocol. A DatagramProtocolPermission consists of a URI string but no actions list.

The URI string specifies a connection for sending and receiving datagrams. It takes the following general form:

 datagram://{host}:{portspec} | datagram://[:{portspec}]
 
The exact syntax for the DatagramProtocolPermission URI is provided by this BNF. The value of the {host} field must be a symbolic hostname, a literal IPv4 address or a literal IPv6 address, as specified by RFC 3986. The {host} field is omitted to indicate an inbound, "server mode" connection. Server-mode URIs may also omit the {portspec} field to request a system-assigned port number. In such a case, the DatagramProtocolPermission is normalized to the equivalent URI "datagram://:1024-65535".

If the {host} string is a DNS name, an asterisk may appear in the leftmost position to indicate a match of 1 or more entire domain labels. Partial domain label matches are not permitted, therefore "*.sun.com" is valid, but "*sun.com" is not. An asterisk by itself matches all hosts in outbound, "client-mode" connections.

The {portspec} string takes the following form:

 portnumber | -portnumber | portnumber-[portnumber] | "*"
 
A {portspec} 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. A single asterisk in the place of the {portspec} field matches all ports. Therefore, the URI "datagram://:*" matches server-mode datagram connections to all ports, and the URI "datagram://*:*" matches client-mode datagram connections to all hosts on all ports.

See Also:
DatagramConnection, Connector.open(java.lang.String), "javax.microedition.io.UDPDatagramConnection" in MIDP 3.0 Specification

Constructor Summary
DatagramProtocolPermission(String uri)
          Creates a new DatagramProtocolPermission with the specified URI as its name.
 
Method Summary
 boolean equals(Object obj)
          Checks two DatagramProtocolPermission objects for equality.
 String getActions()
          Returns the canonical string representation of the actions, which currently is the empty string "", since there are no actions defined for DatagramProtocolPermission.
 int hashCode()
          Returns the hash code value for this object.
 boolean implies(Permission p)
          Checks if this DatagramProtocolPermission object "implies" the specified permission.
 PermissionCollection newPermissionCollection()
          Returns a new PermissionCollection for storing DatagramProtocolPermission objects.
 
Methods inherited from class javax.microedition.io.GCFPermission
getProtocol, getURI
 
Methods inherited from class java.security.Permission
getName, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DatagramProtocolPermission

public DatagramProtocolPermission(String uri)
Creates a new DatagramProtocolPermission with the specified URI as its name. The URI string must conform to the specification given above, and is normalized to facilitate subsequent comparisons.

Parameters:
uri - the URI string.
Throws:
IllegalArgumentException - if uri is malformed.
NullPointerException - if uri is null.
See Also:
Permission.getName()
Method Detail

implies

public boolean implies(Permission p)
Checks if this DatagramProtocolPermission object "implies" the specified permission.

Because the {host} field of the permission URI may indicate an individual host by means of either a symbolic hostname or an IP address, a thorough evaluation of the implies relation between two DatagramProtocolPermission objects requires the underlying platform to be able to transform symbolic hostnames into IP addresses (via address lookup) and vice-versa (via name lookup). Either service may be unavailable on a given platform. As a result, the comparison of URI strings from two permissions can only be best-effort. For each DatagramProtocolPermission constructed with a URI that contains a {host} field, the implementation will attempt to determine both the fully-qualified domain name (the "canonical name") and the IP address(es) of the host. However, either value may be unknown.

To determine whether this object implies another permission, p, this method first ensures that all of the following are true (and returns false if any of them are not):

Then implies checks each of the following, in order, and for each returns true if the stated condition is true:

If none of the above are true, implies returns false.

Specified by:
implies in class Permission
Parameters:
p - the permission to check against.
Returns:
true if the specified permission is implied by this object, false if not.

equals

public boolean equals(Object obj)
Checks two DatagramProtocolPermission objects for equality.

Specified by:
equals in class Permission
Parameters:
obj - the object we are testing for equality with this object.
Returns:
true if obj is a DatagramProtocolPermission and has the same URI string as this DatagramProtocolPermission object.

hashCode

public int hashCode()
Returns the hash code value for this object.

Specified by:
hashCode in class Permission
Returns:
a hash code value for this object.

getActions

public String getActions()
Returns the canonical string representation of the actions, which currently is the empty string "", since there are no actions defined for DatagramProtocolPermission.

Specified by:
getActions in class Permission
Returns:
the empty string "".

newPermissionCollection

public PermissionCollection newPermissionCollection()
Returns a new PermissionCollection for storing DatagramProtocolPermission objects.

DatagramProtocolPermission 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 implies method to be implemented in an efficient (and consistent) manner.

Overrides:
newPermissionCollection in class Permission
Returns:
a new PermissionCollection suitable for storing DatagramProtocolPermission objects.

CLDC 1.1.1

Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. Use of this specification is subject to license terms.