org.exist.security
Class UnixStylePermission

java.lang.Object
  extended by org.exist.security.UnixStylePermission
All Implemented Interfaces:
Permission

public class UnixStylePermission
extends Object
implements Permission

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 Permission SYSTEM_DEFAULT
           
 
Fields inherited from interface org.exist.security.Permission
GROUP_STRING, OTHER_STRING, READ, UPDATE, USER_STRING, WRITE
 
Constructor Summary
UnixStylePermission()
           
UnixStylePermission(int permissions)
          Construct a Permission with given permissions
UnixStylePermission(String user, String group, int permissions)
          Construct a permission with given user, group and permissions
 
Method Summary
 int getGroupPermissions()
          Get the active permissions for group
 String getOwner()
          Gets the user who owns this resource
 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(DataInput istream)
          Read the Permission from an input stream
 void setGroup(String group)
          Set the owner group
 void setGroupPermissions(int perm)
          Sets permissions for group
 void setOwner(String user)
          Set the owner
 void setOwner(User user)
          Set the owner passed as User object
 void setPermissions(int perm)
          Set permissions
 void setPermissions(String str)
          Set permissions using a string.
 void setPublicPermissions(int perm)
          Set permissions for others
 void setUserPermissions(int perm)
          Set permissions for the owner
 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
Constructor Detail

UnixStylePermission

public UnixStylePermission()

UnixStylePermission

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

Parameters:
permissions - Description of the Parameter

UnixStylePermission

public UnixStylePermission(String user,
                           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

Specified by:
getGroupPermissions in interface Permission
Returns:
The groupPermissions value

getOwner

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

Specified by:
getOwner in interface Permission
Returns:
The owner value

getOwnerGroup

public String getOwnerGroup()
Gets the group

Specified by:
getOwnerGroup in interface Permission
Returns:
The ownerGroup value

getPermissions

public int getPermissions()
Get the permissions

Specified by:
getPermissions in interface Permission
Returns:
The permissions value

getPublicPermissions

public int getPublicPermissions()
Get the active permissions for others

Specified by:
getPublicPermissions in interface Permission
Returns:
The publicPermissions value

getUserPermissions

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

Specified by:
getUserPermissions in interface Permission
Returns:
The userPermissions value

read

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

Specified by:
read in interface Permission
Parameters:
istream - Description of the Parameter
Throws:
IOException - Description of the Exception

setGroup

public void setGroup(String group)
Set the owner group

Specified by:
setGroup in interface Permission
Parameters:
group - The new group value

setGroupPermissions

public void setGroupPermissions(int perm)
Sets permissions for group

Specified by:
setGroupPermissions in interface Permission
Parameters:
perm - The new groupPermissions value

setOwner

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

Specified by:
setOwner in interface Permission
Parameters:
user - The new owner value

setOwner

public void setOwner(String user)
Set the owner

Specified by:
setOwner in interface Permission
Parameters:
user - The new owner value

setPermissions

public void setPermissions(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.

Specified by:
setPermissions in interface Permission
Parameters:
str - The new permissions
Throws:
SyntaxException - Description of the Exception

setPermissions

public void setPermissions(int perm)
Set permissions

Specified by:
setPermissions in interface Permission
Parameters:
perm - The new permissions value

setPublicPermissions

public void setPublicPermissions(int perm)
Set permissions for others

Specified by:
setPublicPermissions in interface Permission
Parameters:
perm - The new publicPermissions value

setUserPermissions

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

Specified by:
setUserPermissions in interface Permission
Parameters:
perm - The new userPermissions value

toString

public String toString()
Format permissions

Specified by:
toString in interface Permission
Overrides:
toString in class Object
Returns:
Description of the Return Value

validate

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

Specified by:
validate in interface Permission
Parameters:
user - The user
perm - The requested permissions
Returns:
true if user has the requested permissions


Copyright (C) Wolfgang Meier. All rights reserved.