org.exist.security
Class Permission

java.lang.Object
  extended byorg.exist.security.Permission

public class Permission
extends java.lang.Object

Manages the permissions assigned to a ressource. This includes the user who owns the ressource, the owner group and the permissions for user, group and others. Permissions are encoded in a single byte according to common unix conventions.

Author:
Wolfgang Meier

Field Summary
static int DEFAULT_PERM
           
static java.lang.String DEFAULT_STRING
           
static java.lang.String GROUP_STRING
           
static int READ
           
static Permission SYSTEM_DEFAULT
           
static int UPDATE
           
static java.lang.String USER_STRING
           
static int WRITE
           
 
Constructor Summary
Permission()
           
Permission(int perm)
          Construct a Permission with given permissions
Permission(java.lang.String user, java.lang.String group, int permissions)
          Construct a permission with given user, group and permissions
 
Method Summary
 int getGroupPermissions()
          Get the active permissions for group
 java.lang.String getOwner()
          Gets the user who owns this resource
 java.lang.String getOwnerGroup()
          Gets the group
 int getPermissions()
          Get the permissions
 int getPublicPermissions()
          Get the active permissions for others
 int getUserPermissions()
          Get the active permissions for the owner
 void read(java.io.DataInput istream)
          Read the Permission from an input stream
 void setGroup(java.lang.String group)
          Set the owner group
 void setGroupPermissions(int perm)
          Sets permissions for group
 void setOwner(java.lang.String user)
          Set the owner
 void setOwner(User user)
          Set the owner passed as User object
 void setPermissions(int perm)
          Set permissions
 void setPermissions(java.lang.String str)
          Set permissions using a string.
 void setPublicPermissions(int perm)
          Set permissions for others
 void setUserPermissions(int perm)
          Set permissions for the owner
 java.lang.String toString()
          Format permissions
 boolean validate(User user, int perm)
          Check if user has the requested permissions for this resource.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PERM

public static final int DEFAULT_PERM
See Also:
Constant Field Values

SYSTEM_DEFAULT

public static final Permission SYSTEM_DEFAULT

DEFAULT_STRING

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

GROUP_STRING

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

READ

public static final int READ
See Also:
Constant Field Values

UPDATE

public static final int UPDATE
See Also:
Constant Field Values

USER_STRING

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

WRITE

public static final int WRITE
See Also:
Constant Field Values
Constructor Detail

Permission

public Permission()

Permission

public Permission(int perm)
Construct a Permission with given permissions

Parameters:
perm - Description of the Parameter

Permission

public Permission(java.lang.String user,
                  java.lang.String group,
                  int permissions)
Construct a permission with given user, group and permissions

Parameters:
user - Description of the Parameter
group - Description of the Parameter
permissions - Description of the Parameter
Method Detail

getGroupPermissions

public int getGroupPermissions()
Get the active permissions for group

Returns:
The groupPermissions value

getOwner

public java.lang.String getOwner()
Gets the user who owns this resource

Returns:
The owner value

getOwnerGroup

public java.lang.String getOwnerGroup()
Gets the group

Returns:
The ownerGroup value

getPermissions

public int getPermissions()
Get the permissions

Returns:
The permissions value

getPublicPermissions

public int getPublicPermissions()
Get the active permissions for others

Returns:
The publicPermissions value

getUserPermissions

public int getUserPermissions()
Get the active permissions for the owner

Returns:
The userPermissions value

read

public void read(java.io.DataInput istream)
          throws java.io.IOException
Read the Permission from an input stream

Parameters:
istream - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

setGroup

public void setGroup(java.lang.String group)
Set the owner group

Parameters:
group - The new group value

setGroupPermissions

public void setGroupPermissions(int perm)
Sets permissions for group

Parameters:
perm - The new groupPermissions value

setOwner

public void setOwner(User user)
Set the owner passed as User object

Parameters:
user - The new owner value

setOwner

public void setOwner(java.lang.String user)
Set the owner

Parameters:
user - The new owner value

setPermissions

public void setPermissions(java.lang.String str)
                    throws SyntaxException
Set permissions using a string. The string has the following syntax: [user|group|other]=[+|-][read|write|update] For example, to set read and write permissions for the group, but not for others: group=+read,+write,other=-read,-write The new settings are or'ed with the existing settings.

Parameters:
str - The new permissions
Throws:
SyntaxException - Description of the Exception

setPermissions

public void setPermissions(int perm)
Set permissions

Parameters:
perm - The new permissions value

setPublicPermissions

public void setPublicPermissions(int perm)
Set permissions for others

Parameters:
perm - The new publicPermissions value

setUserPermissions

public void setUserPermissions(int perm)
Set permissions for the owner

Parameters:
perm - The new userPermissions value

toString

public java.lang.String toString()
Format permissions

Returns:
Description of the Return Value

validate

public boolean validate(User user,
                        int perm)
Check if user has the requested permissions for this resource.

Parameters:
user - The user
perm - The requested permissions
Returns:
true if user has the requested permissions


Copyright (C) Wolfgang Meier. All rights reserved.