net.sf.jguard.authorization.permissions
Class URLPermission

java.lang.Object
  extended by java.security.Permission
      extended by java.security.BasicPermission
          extended by net.sf.jguard.authorization.permissions.URLPermission
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, java.security.Guard

public final class URLPermission
extends java.security.BasicPermission
implements java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

this permission, only implies URLPermission.

Author:
Charles Gay
See Also:
Serialized Form

Constructor Summary
URLPermission(java.lang.String n)
          Creates a new instance of URLPermission.
URLPermission(java.lang.String name, java.lang.String actions)
          Creates a new instance of URLPermission.
 
Method Summary
static java.lang.String buildRegexpFromURL(java.lang.String regexp)
          convenient method to escape regexp special characters, and only use the '*' characters for building the regexp Pattern.
 void checkGuard(java.lang.Object perm)
          Determines whether or not to allow access to the guarded object object.
 java.lang.Object clone()
          override the java.lang.Object 's clone method.
 int compareTo(java.lang.Object o)
          method used to compare two objects.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getActions()
          return actions in a String splitted by comma.
 java.lang.String getURI()
           
 int hashCode()
          methode used to accelerate the comparation process: useful when hashcode return different int.
 boolean implies(java.security.Permission permission)
          verify if this permission implies another URLPermission.
 java.security.PermissionCollection newPermissionCollection()
          return an enmpy JGPermissionCollection.
static java.lang.String removeRegexpFromURI(java.lang.String uriPath)
          replace '*'character (not followed by '*' character, or if it's the last '*') by '' and we replace '**' by '*'.
 java.lang.String toString()
          return a String representation of the permission.
 
Methods inherited from class java.security.Permission
getName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URLPermission

public URLPermission(java.lang.String n)
Creates a new instance of URLPermission.

Parameters:
n - permission's name

URLPermission

public URLPermission(java.lang.String name,
                     java.lang.String actions)
Creates a new instance of URLPermission.

Parameters:
name - permission name
actions - permission's actions splitted by a "," : regexp,scheme(optional),description(optional)
Throws:
java.lang.IllegalArgumentException - which wraps a @link URISyntaxException
Method Detail

removeRegexpFromURI

public static java.lang.String removeRegexpFromURI(java.lang.String uriPath)
replace '*'character (not followed by '*' character, or if it's the last '*') by '' and we replace '**' by '*'.

Parameters:
uriPath -
Returns:
URI escaped

buildRegexpFromURL

public static java.lang.String buildRegexpFromURL(java.lang.String regexp)
convenient method to escape regexp special characters, and only use the '*' characters for building the regexp Pattern.

Parameters:
regexp -
Returns:
escaped regexp candidate

checkGuard

public void checkGuard(java.lang.Object perm)
Determines whether or not to allow access to the guarded object object. this method comes from the Guard interface.

Specified by:
checkGuard in interface java.security.Guard
Overrides:
checkGuard in class java.security.Permission
Parameters:
perm - Permission to check

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
override the java.lang.Object 's clone method.

Overrides:
clone in class java.lang.Object
Returns:
new URLPermission with the same Domain.
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.security.BasicPermission
Parameters:
obj -
Returns:
true if equals, false otherwise

getActions

public java.lang.String getActions()
return actions in a String splitted by comma.

Overrides:
getActions in class java.security.BasicPermission
Returns:
permitted actions.

hashCode

public int hashCode()
methode used to accelerate the comparation process: useful when hashcode return different int.

Overrides:
hashCode in class java.security.BasicPermission
Returns:
hashcode

implies

public boolean implies(java.security.Permission permission)
verify if this permission implies another URLPermission.

Overrides:
implies in class java.security.BasicPermission
Parameters:
permission -
Returns:
true if implies, false otherwise

newPermissionCollection

public java.security.PermissionCollection newPermissionCollection()
return an enmpy JGPermissionCollection.

Overrides:
newPermissionCollection in class java.security.BasicPermission
Returns:
empty JGPermissionCollection

toString

public java.lang.String toString()
return a String representation of the permission.

Overrides:
toString in class java.security.Permission
Returns:
String

compareTo

public int compareTo(java.lang.Object o)
method used to compare two objects. this method is used in Collection to order items, and MUST be consistent with the equals method (eache method should return 0/true in the same cases).

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - object to compare
Returns:
0 if both objects are equals, <0 if 0 is lesser than the URLPermission, >0 if 0 is greater than the URLPermission
See Also:
Comparable.compareTo(java.lang.Object)

getURI

public final java.lang.String getURI()