Compoze Software, Inc.

com.compoze.ejb
Class PolicyManager


java.lang.Object

  |

  +--com.compoze.ejb.PolicyManager

All Implemented Interfaces:
java.io.Serializable

public class PolicyManager
extends java.lang.Object
implements java.io.Serializable

A class which extends this class is capable of moderating the access to a resource. Roles and targets are created at development time and may not change during the course of execution.

See Also:
Serialized Form

Inner Class Summary
 class PolicyManager.Role
          Represents a role for a user and has the targets that the role has access to.
 
Constructor Summary
PolicyManager(ObjectProperties props)
          Constructor.
 
Method Summary
 boolean checkAccess(java.lang.String sUsername, int iRolesMask, IOwnedTarget ownedTarget, int iTarget)
          Checks access by role and owner.
 boolean checkOwnerAccess(java.lang.String sUsername, IOwnedTarget ownedTarget)
          Checks if the specified user owns the specified target.
 boolean checkRoleAccess(int iRole, int iTarget)
          Checks if a role has access to a target.
 boolean checkRolesMask(int iRolesMask, int iRoleNumber)
          Checks if any of the roles listed in the specified mask are the provided role number.
 boolean checkRolesMaskAccess(int iRolesMask, int iTarget)
          Checks if any of the roles listed in the specified mask have access to a target.
static int getMaskFromRoles(int[] roles)
          Gets a roles mask from a list of roles.
 PolicyManager.Role getRoleByRoleNumber(int iRoleNumber)
          Gets the role by role number.
 int getRoleNumberByName(java.lang.String sRoleName)
          Gets a role number by its name.
 PolicyManager.Role[] getRoles()
          Gets the available roles.
 int[] getRolesFromMask(int iRolesMask)
          Gets a list of roles from a roles mask.
 int getTargetNumberByName(java.lang.String sTargetName)
          Gets a target number by its name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolicyManager


public PolicyManager(ObjectProperties props)
Constructor.
Parameters:
props - the object propoerties
Method Detail

checkOwnerAccess


public boolean checkOwnerAccess(java.lang.String sUsername,
                                IOwnedTarget ownedTarget)
Checks if the specified user owns the specified target.
Parameters:
sUsername - the username
ownedTarget - the owned target
Returns:
true if the owner has access to the owned target

checkAccess


public boolean checkAccess(java.lang.String sUsername,
                           int iRolesMask,
                           IOwnedTarget ownedTarget,
                           int iTarget)
Checks access by role and owner.
Parameters:
sUsername - the username
iRolesMask - the roles mask
ownedTarget - the owned target
iTarget - the given target
Returns:
true if the role and owner have access to the owned target

checkRoleAccess


public boolean checkRoleAccess(int iRole,
                               int iTarget)
Checks if a role has access to a target.
Parameters:
iRoles - the role number
iTarget - the given target
Returns:
true of the role has access to the given target

checkRolesMaskAccess


public boolean checkRolesMaskAccess(int iRolesMask,
                                    int iTarget)
Checks if any of the roles listed in the specified mask have access to a target.
Parameters:
iRolesMask - the role mask
iTarget - the given target
Returns:
true if the given target is accessible by the role mask

checkRolesMask


public boolean checkRolesMask(int iRolesMask,
                              int iRoleNumber)
Checks if any of the roles listed in the specified mask are the provided role number.
Parameters:
iRolesMask - the role mask
iRoleNumber - the role number
Returns:
true if the given role number is listed in the roles mask

getRolesFromMask


public int[] getRolesFromMask(int iRolesMask)
Gets a list of roles from a roles mask.
Parameters:
iRolesMask - the role mask
Returns:
the role list

getMaskFromRoles


public static int getMaskFromRoles(int[] roles)
Gets a roles mask from a list of roles.
Parameters:
roles - the list of roles
Returns:
the roles mask

getRoleNumberByName


public int getRoleNumberByName(java.lang.String sRoleName)
Gets a role number by its name.
Parameters:
sRoleName - the role name
Returns:
the role number.
Throws:
java.lang.IllegalArgumentException - if role name is not found

getTargetNumberByName


public int getTargetNumberByName(java.lang.String sTargetName)
Gets a target number by its name.
Parameters:
sTargetName - the target name
Returns:
the target number
Throws:
java.lang.IllegalArgumentException - if target name is not found

getRoles


public PolicyManager.Role[] getRoles()
Gets the available roles.
Returns:
the available roles

getRoleByRoleNumber


public PolicyManager.Role getRoleByRoleNumber(int iRoleNumber)
Gets the role by role number.
Parameters:
iRoleNumber - the role number
Returns:
the role or null if does not exist

Compoze Software, Inc.

Copyright ©1999-2001 Compoze Software, Inc. All rights reserved.