net.jini.security
Class AccessPermission

java.lang.Object
  extended by java.security.Permission
      extended by net.jini.security.AccessPermission
All Implemented Interfaces:
Serializable, Guard
Direct Known Subclasses:
ActivatorPermission, ContextPermission, FiddlerPermission, InstantiatorPermission, MahaloPermission, MercuryPermission, MonitorPermission, NormPermission, OutriggerPermission, RegistrarPermission, SystemPermission

public class AccessPermission
extends Permission

Represents permission to call a method. An instance of this class contains a name (also referred to as a "target name") but no actions list; you either have the named permission or you don't. The target name can be any of the following forms:

 *
 Identifier
 *Suffix
 Identifier*
 QualifiedIdentifier.*
 QualifiedIdentifier.Identifier
 QualifiedIdentifier.*Suffix
 QualifiedIdentifier.Identifier*
 
where QualifiedIdentifier and Identifier are as defined in The Java(TM) Language Specification except that whitespace is not permitted, and Suffix is defined to be one or more characters that may be part of an Identifier. These forms are defined to match fully qualified names of the form QualifiedIdentifier.Identifier as follows:
Target Name QualifiedIdentifier Match Identifier Match
* any any
method any method
*suffix any any ending with suffix
prefix* any any starting with prefix
type.* type any
type.method type method
type.*suffix type any ending with suffix
type.prefix* type any starting with prefix

This class, and simple subclasses of it, can be used (for example) with BasicInvocationDispatcher. It is recommended that a simple subclass of this class be defined for each remote object implementation class that can be exported using an Exporter, to allow separation of grants in policy files.

Since:
2.0
Author:
Sun Microsystems, Inc.
See Also:
Serialized Form

Field Summary
private  String iface
          The interface name, or null if wildcarded.
private  String method
          The name of the method, with prefix or suffix '*' permitted, or null if wildcarded.
private static long serialVersionUID
           
 
Constructor Summary
AccessPermission(String name)
          Creates an instance with the specified target name.
 
Method Summary
 boolean equals(Object obj)
          Returns true if the specified object is an instance of the same class as this permission and has the same target name as this permission; returns false otherwise.
 String getActions()
          Returns the empty string.
 int hashCode()
          Returns a hash code value for this object.
 boolean implies(Permission perm)
          Returns true if every fully qualified name that matches the specified permission's name also matches this permission's name; returns false otherwise.
private  void init(String name)
          Parses the target name and initializes the transient fields.
private  void readObject(ObjectInputStream s)
          Verifies the syntax of the target name and recreates any transient state.
private static boolean validClass(String name)
          Returns true if the name is a syntactically valid fully qualified class name (no whitespace permitted), and returns false otherwise.
private static boolean validMethod(String name)
          Returns true if the name is a syntactically valid method name, or if the name is a syntactically valid method name with a '*' appended or could be constructed from some syntactically valid method name containing more than two characters by replacing the first character of that name with '*', and returns false otherwise.
 
Methods inherited from class java.security.Permission
checkGuard, getName, newPermissionCollection, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

iface

private transient String iface
The interface name, or null if wildcarded.


method

private transient String method
The name of the method, with prefix or suffix '*' permitted, or null if wildcarded.

Constructor Detail

AccessPermission

public AccessPermission(String name)
Creates an instance with the specified target name.

Parameters:
name - the target name
Throws:
NullPointerException - if the target name is null
IllegalArgumentException - if the target name does not match the syntax specified in the comments at the beginning of this class
Method Detail

init

private void init(String name)
Parses the target name and initializes the transient fields.


validClass

private static boolean validClass(String name)
Returns true if the name is a syntactically valid fully qualified class name (no whitespace permitted), and returns false otherwise.


validMethod

private static boolean validMethod(String name)
Returns true if the name is a syntactically valid method name, or if the name is a syntactically valid method name with a '*' appended or could be constructed from some syntactically valid method name containing more than two characters by replacing the first character of that name with '*', and returns false otherwise.


implies

public boolean implies(Permission perm)
Returns true if every fully qualified name that matches the specified permission's name also matches this permission's name; returns false otherwise.

Specified by:
implies in class Permission
Parameters:
perm - the permission to check
Returns:
true if every fully qualified name that matches the specified permission's name also matches this permission's name; false otherwise

equals

public boolean equals(Object obj)
Returns true if the specified object is an instance of the same class as this permission and has the same target name as this permission; returns false otherwise.

Specified by:
equals in class Permission

hashCode

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

Specified by:
hashCode in class Permission

getActions

public String getActions()
Returns the empty string.

Specified by:
getActions in class Permission

readObject

private void readObject(ObjectInputStream s)
                 throws IOException,
                        ClassNotFoundException
Verifies the syntax of the target name and recreates any transient state.

Throws:
InvalidObjectException - if the target name is null, or if the target name does not match the syntax specified in the comments at the beginning of this class
IOException
ClassNotFoundException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.