org.naregi.rns
Class ACL

java.lang.Object
  extended by org.naregi.rns.ACL

public class ACL
extends java.lang.Object

ACL structure for Server side and Client side.


Field Summary
static java.lang.String ANONYMOUS
          String of anonymous user and group
static short PERM_ALL
          allow to do all operations
static short PERM_EXEC
          allow to execute (This is not used in RNS)
static short PERM_READ
          allow to read
static short PERM_WRITE
          allow to write
static short PERM_ZERO
          do not allow to do all operations
static short TYPE_DEFAULT_GROUP
          default group
static short TYPE_DEFAULT_MASK
          default mask
static short TYPE_DEFAULT_OTHER
          default other
static short TYPE_DEFAULT_OWNER
          default owner
static short TYPE_DEFAULT_OWNERGROUP
          default owner group
static short TYPE_DEFAULT_USER
          default user
static short TYPE_GROUP
          group
static short TYPE_MASK
          mask
static short TYPE_OTHER
          other
static short TYPE_OWNER
          owner
static short TYPE_OWNERGROUP
          owner group
static short TYPE_USER
          user
 
Constructor Summary
ACL()
          Create a new ACL instance.
ACL(org.naregi.rns.stubs.ACLEntryType[] list)
          Create a new ACL instance.
ACL(java.lang.String[] aclSpecs)
          Create a new ACL instance.
 
Method Summary
 void autoComplete()
          Complete missing ACL entries automatically.
static boolean canExec(short perm)
          Check whether the permission bits has PERM_EXEC bit.
static boolean canRead(short perm)
          Check whether the permission bits has PERM_READ bit.
static boolean canWrite(short perm)
          Check whether the permission bits has PERM_WRITE bit.
 void clearGroupPerm()
          Clear permission bits of all groups.
 void clearMask()
          Reset the ACL entry of mask.
 void clearUserPerm()
          Clear permission bits of all users.
 void copyAllDefaultPermToNormal()
          Inherit default ACL.
 java.util.Map<java.lang.String,java.lang.Short> getDefaultGroupMap()
          Get Map for default group.
 java.util.Map<java.lang.String,java.lang.Short> getDefaultUserMap()
          Get Map for default user.
 java.util.Map<java.lang.String,java.lang.Short> getGroupMap()
          Get Map for group.
 java.lang.Short getGroupPerm(java.lang.String name)
          Get the permission bits of the specified group
 short getOtherPerm()
          Get the permission bits of other.
 java.lang.String getOwner()
          Get the name of owner.
 java.lang.String getOwnerGroup()
          Get the name of owner group
 short getOwnerGroupPerm()
          Get the permission bits of owner group
 short getOwnerPerm()
          Get the permission bits of owner.
 java.util.Map<java.lang.String,java.lang.Short> getUserMap()
          Get Map for user.
 java.lang.Short getUserPerm(java.lang.String name)
          Get the permission bits of the specified user.
 boolean hasExtension()
          Check whether the ACL has extended ACL entries.
static short permStringToShort(java.lang.String permStr)
          Convert rwx form to permission bits
static java.lang.String permToString(short perm)
          Convert permission bits to String.
 void setACLString(java.lang.String aclSpec)
          Set (replace or add) an ACL entry.
 void setACLString(java.lang.String[] aclSpecs)
          Set (replace or add) ACL entries.
 void setOther(short perm)
          Set the permission bits of other (not match any other entry)
 void setOwner(java.lang.String name, short perm)
          Set the ACL entry of owner.
 void setOwnerGroup(java.lang.String name, short perm)
          Set the ACL entry of owner group.
 org.naregi.rns.stubs.ACLEntryType[] toACLEntries()
          Convert this object to ACLEntryType array.
 java.lang.String[] toAclSpecs()
          Convert this ACL to String[] of AclSpecs
 java.lang.String toString()
           
static short typeStringToShort(java.lang.String type)
          Convert String of ACL type to TYPE_*.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANONYMOUS

public static final java.lang.String ANONYMOUS
String of anonymous user and group

See Also:
Constant Field Values

TYPE_OWNER

public static final short TYPE_OWNER
owner

See Also:
Constant Field Values

TYPE_OWNERGROUP

public static final short TYPE_OWNERGROUP
owner group

See Also:
Constant Field Values

TYPE_USER

public static final short TYPE_USER
user

See Also:
Constant Field Values

TYPE_GROUP

public static final short TYPE_GROUP
group

See Also:
Constant Field Values

TYPE_MASK

public static final short TYPE_MASK
mask

See Also:
Constant Field Values

TYPE_OTHER

public static final short TYPE_OTHER
other

See Also:
Constant Field Values

TYPE_DEFAULT_OWNER

public static final short TYPE_DEFAULT_OWNER
default owner

See Also:
Constant Field Values

TYPE_DEFAULT_OWNERGROUP

public static final short TYPE_DEFAULT_OWNERGROUP
default owner group

See Also:
Constant Field Values

TYPE_DEFAULT_USER

public static final short TYPE_DEFAULT_USER
default user

See Also:
Constant Field Values

TYPE_DEFAULT_GROUP

public static final short TYPE_DEFAULT_GROUP
default group

See Also:
Constant Field Values

TYPE_DEFAULT_MASK

public static final short TYPE_DEFAULT_MASK
default mask

See Also:
Constant Field Values

TYPE_DEFAULT_OTHER

public static final short TYPE_DEFAULT_OTHER
default other

See Also:
Constant Field Values

PERM_READ

public static final short PERM_READ
allow to read

See Also:
Constant Field Values

PERM_WRITE

public static final short PERM_WRITE
allow to write

See Also:
Constant Field Values

PERM_EXEC

public static final short PERM_EXEC
allow to execute (This is not used in RNS)

See Also:
Constant Field Values

PERM_ALL

public static final short PERM_ALL
allow to do all operations

See Also:
Constant Field Values

PERM_ZERO

public static final short PERM_ZERO
do not allow to do all operations

See Also:
Constant Field Values
Constructor Detail

ACL

public ACL()
Create a new ACL instance.


ACL

public ACL(java.lang.String[] aclSpecs)
    throws java.lang.Exception
Create a new ACL instance. This aclSpec is the following format.
 --- aclSpec format ---
 default(d):owner(ou):[name]:rwx
 default(d):ownergroup(og):[name]:rwx
 default(d):user(u):name:rwx
 default(d):group(g):name:rwx
 default(d):mask(m):rwx
 default(d):other(o):rwx
 owner(ou):[name]:rwx
 ownergroup(og):[name]:rwx
 user(u):name:rwx
 group(g):name:rwx
 mask(m):rwx
 other(o):rwx
 

Parameters:
aclSpecs - aclSpec array
Throws:
java.lang.Exception

ACL

public ACL(org.naregi.rns.stubs.ACLEntryType[] list)
Create a new ACL instance.

Parameters:
list - array of ACLEntryType
Method Detail

canRead

public static boolean canRead(short perm)
Check whether the permission bits has PERM_READ bit.

Parameters:
perm - a permission bits
Returns:
true if the permission bits has PERM_READ bit.

canWrite

public static boolean canWrite(short perm)
Check whether the permission bits has PERM_WRITE bit.

Parameters:
perm - a permission bits
Returns:
true if the permission bits has PERM_WRITE bit.

canExec

public static boolean canExec(short perm)
Check whether the permission bits has PERM_EXEC bit.

Parameters:
perm - a permission bits
Returns:
true if the permission bits has PERM_EXEC bit.

permToString

public static java.lang.String permToString(short perm)
Convert permission bits to String.

Parameters:
perm - permission bits
Returns:
String of rwx from

typeStringToShort

public static short typeStringToShort(java.lang.String type)
Convert String of ACL type to TYPE_*.

Parameters:
type - a name of ACL type
Returns:
a TYPE_* of ACL type

permStringToShort

public static short permStringToShort(java.lang.String permStr)
Convert rwx form to permission bits

Parameters:
permStr - String of rwx form (ex. rw-, r--, r-x, ---)
Returns:
permission bits

setACLString

public void setACLString(java.lang.String aclSpec)
                  throws java.lang.Exception
Set (replace or add) an ACL entry. The aclSpec format is described at ACL(String[]).

Parameters:
aclSpec - aclSpec
Throws:
java.lang.Exception - if an error occurs

setACLString

public void setACLString(java.lang.String[] aclSpecs)
                  throws java.lang.Exception
Set (replace or add) ACL entries. The aclSpec format is described at ACL(String[]).

Parameters:
aclSpecs - aclSpec array (not null)
Throws:
java.lang.Exception - if an error occurs

toACLEntries

public org.naregi.rns.stubs.ACLEntryType[] toACLEntries()
Convert this object to ACLEntryType array.

Returns:
ACLEntryType array

autoComplete

public void autoComplete()
Complete missing ACL entries automatically. This must be used after reading from DB or before doing toString(). This should not be used before writing into DB or sending Server.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toAclSpecs

public java.lang.String[] toAclSpecs()
Convert this ACL to String[] of AclSpecs

Returns:
String[] of AclSpecs

getOwner

public java.lang.String getOwner()
Get the name of owner.

Returns:
a name

getOwnerPerm

public short getOwnerPerm()
Get the permission bits of owner.

Returns:
the permission bits

setOwner

public void setOwner(java.lang.String name,
                     short perm)
Set the ACL entry of owner.

Parameters:
name - a name
perm - permission bits

getOwnerGroup

public java.lang.String getOwnerGroup()
Get the name of owner group

Returns:
a name

getOwnerGroupPerm

public short getOwnerGroupPerm()
Get the permission bits of owner group

Returns:
permission bits

setOwnerGroup

public void setOwnerGroup(java.lang.String name,
                          short perm)
Set the ACL entry of owner group.

Parameters:
name - a name
perm - permission bits

setOther

public void setOther(short perm)
Set the permission bits of other (not match any other entry)

Parameters:
perm - permission bits

getUserPerm

public java.lang.Short getUserPerm(java.lang.String name)
Get the permission bits of the specified user.

Parameters:
name - a user name
Returns:
permission bits as Short. return null if the name does not exist

clearUserPerm

public void clearUserPerm()
Clear permission bits of all users.


getGroupPerm

public java.lang.Short getGroupPerm(java.lang.String name)
Get the permission bits of the specified group

Parameters:
name - a group name
Returns:
permission bits as Short. return null if the name does not exist

clearGroupPerm

public void clearGroupPerm()
Clear permission bits of all groups.


clearMask

public void clearMask()
Reset the ACL entry of mask.


getOtherPerm

public short getOtherPerm()
Get the permission bits of other.

Returns:
permission bits

getUserMap

public java.util.Map<java.lang.String,java.lang.Short> getUserMap()
Get Map for user.

Returns:
Map (a name to permission bits)

getGroupMap

public java.util.Map<java.lang.String,java.lang.Short> getGroupMap()
Get Map for group.

Returns:
Map (a name to permission bits)

getDefaultUserMap

public java.util.Map<java.lang.String,java.lang.Short> getDefaultUserMap()
Get Map for default user.

Returns:
Map (a name to permission bits)

getDefaultGroupMap

public java.util.Map<java.lang.String,java.lang.Short> getDefaultGroupMap()
Get Map for default group.

Returns:
Map (a name to permission bits)

copyAllDefaultPermToNormal

public void copyAllDefaultPermToNormal()
Inherit default ACL.


hasExtension

public boolean hasExtension()
Check whether the ACL has extended ACL entries. (whether this ACL consists ACL entries of owner, ownergroup and other)

Returns:
true if an extended ACL entry exists in this ACL.