net.sf.jguard.core.authorization.permissions
Class URLPermission

java.lang.Object
  extended by java.security.Permission
      extended by java.security.BasicPermission
          extended by net.sf.jguard.core.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

It represents the right to execute one or more actions (or methods for HTTP) on one or more URLs via one or more protocols identified by their schemes. this permission, only implies URLPermission.

Author:
Charles Gay
See Also:
which wrap the, thrown if the URI is not correct., Serialized Form

Field Summary
static java.lang.String ANY
           
static java.lang.String DELETE
           
static java.lang.String GET
           
static java.lang.String HEAD
           
static java.lang.String HTTP
           
static java.lang.String HTTPS
           
static java.lang.String OPTIONS
           
static java.lang.String POST
           
static java.lang.String PUT
           
static java.lang.String TRACE
           
 
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 buildRegexpFromString(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. 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).
 boolean equals(java.lang.Object obj)
           
 java.lang.String getActions()
          return actions in a String splitted by comma.
 java.util.Collection getMethods()
           
static java.lang.String getPathFromURIString(java.lang.String uriString)
           
static java.lang.String getQueryFromURIString(java.lang.String uriString)
           
 java.lang.String getScheme()
           
 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
 

Field Detail

DELETE

public static final java.lang.String DELETE
See Also:
Constant Field Values

GET

public static final java.lang.String GET
See Also:
Constant Field Values

HEAD

public static final java.lang.String HEAD
See Also:
Constant Field Values

OPTIONS

public static final java.lang.String OPTIONS
See Also:
Constant Field Values

POST

public static final java.lang.String POST
See Also:
Constant Field Values

PUT

public static final java.lang.String PUT
See Also:
Constant Field Values

TRACE

public static final java.lang.String TRACE
See Also:
Constant Field Values

ANY

public static final java.lang.String ANY
See Also:
Constant Field Values

HTTP

public static final java.lang.String HTTP
See Also:
Constant Field Values

HTTPS

public static final java.lang.String HTTPS
See Also:
Constant Field Values
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),http methods(optional) http methods and schemes (Http or https) are automatically recognized, after the regexp.
Throws:
java.lang.IllegalArgumentException - which wraps a
See Also:
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

getPathFromURIString

public static java.lang.String getPathFromURIString(java.lang.String uriString)

getQueryFromURIString

public static java.lang.String getQueryFromURIString(java.lang.String uriString)

buildRegexpFromString

public static java.lang.String buildRegexpFromString(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 java.lang.String getURI()

getMethods

public java.util.Collection getMethods()

getScheme

public java.lang.String getScheme()


Copyright © 2004-2009. All Rights Reserved.