org.molgenis.omx.auth.service.permissionmanagement
Class PermissionManagementService

java.lang.Object
  extended by org.molgenis.omx.auth.service.permissionmanagement.PermissionManagementService

public class PermissionManagementService
extends Object


Method Summary
 boolean exists(MolgenisPermission mp)
          Check to see if a given permission exists
 List<MolgenisEntity> findEntities()
          Find all Molgenis Users
 MolgenisEntity findEntity(Integer id)
          Find a MolgenisEntity by id
 MolgenisPermission findPermission(Integer id)
          Finds permission based on a MolgenisPermission id
 List<MolgenisPermission> findPermissions(Integer id)
          Given a role id, finds all MolgenisPermissions for the role.
 MolgenisPermission findPermissions(Integer roleId, Integer entityId)
          Given a role id and an entity id, searches for a MolgenisPermission on a particular entity for the given role.
 MolgenisPermission findPermissions(Integer roleId, Integer entityId, String permType)
          Given a role id, entity id, and a permission type, check to see whether a MolgenisPermission exists
 List<MolgenisPermission> findPermissions(Integer roleId, String permType)
          Given a role id and a permission type (i.e.
 MolgenisRole findRole(Integer id)
          Find a MolgenisUser
 List<MolgenisRole> findRoles()
          Find all Molgenis Users
 List<MolgenisPermission> findUserPermissions(Integer roleId, boolean includeOwnership)
          Given a role id, return a list of MolgenisPermissions for all users, where the given roleId owns the entity in the matched MolgenisPermissions.
 List<MolgenisPermission> findUserPermissions(Integer roleId, Integer entityId)
          Given a role id and an entity id, return a list of MolgenisPermissions for all users, where the given roleId owns the entity in the matched MolgenisPermissions (and only the entity passed in).
static PermissionManagementService getInstance()
          Get an instance of PermissionManagementService
 void insert(Integer userId, MolgenisPermission mp)
          Inserts a given MolgenisPermission iff the given user is owner on the entity for whom a permission is being made.
 void remove(int roleId, int permId)
          Remove a permission based on permission id.
 void setDb(Database db)
           
 void update(Integer userId, MolgenisPermission mp)
          Updates a given MolgenisPermission iff the given user is owner on that entity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setDb

public void setDb(Database db)

getInstance

public static PermissionManagementService getInstance()
Get an instance of PermissionManagementService

Parameters:
Database - object
Returns:
PermissionManagementService object

findPermissions

public List<MolgenisPermission> findPermissions(Integer id)
                                         throws DatabaseException,
                                                ParseException
Given a role id, finds all MolgenisPermissions for the role.

Parameters:
id - MolgenisRole id
Returns:
list of MolgenisPermissions for the given Role
Throws:
DatabaseException
ParseException

findPermissions

public MolgenisPermission findPermissions(Integer roleId,
                                          Integer entityId)
                                   throws DatabaseException,
                                          ParseException
Given a role id and an entity id, searches for a MolgenisPermission on a particular entity for the given role.

Parameters:
roleId - role Id
entityId - entity Id
Returns:
MolgenisPermission if one exists, otherwise null
Throws:
DatabaseException
ParseException

findPermissions

public MolgenisPermission findPermissions(Integer roleId,
                                          Integer entityId,
                                          String permType)
                                   throws DatabaseException,
                                          ParseException
Given a role id, entity id, and a permission type, check to see whether a MolgenisPermission exists

Parameters:
roleId - the role id
entityId - the entity id
permType - the type of permission (i.e. READ, WRITE, EXECUTE, or OWN)
Returns:
A MolgenisPermission if one exists, otherwise null
Throws:
DatabaseException
ParseException

findPermissions

public List<MolgenisPermission> findPermissions(Integer roleId,
                                                String permType)
                                         throws DatabaseException,
                                                ParseException
Given a role id and a permission type (i.e. READ, WRITE, EXECUTE, or OWN), return a list of MolgenisPermissions matching these parameters.

Parameters:
id -
permType -
Returns:
Throws:
DatabaseException
ParseException

findUserPermissions

public List<MolgenisPermission> findUserPermissions(Integer roleId,
                                                    boolean includeOwnership)
                                             throws DatabaseException,
                                                    ParseException
Given a role id, return a list of MolgenisPermissions for all users, where the given roleId owns the entity in the matched MolgenisPermissions.

Parameters:
roleId - role id
includeOwnership - whether to include the permission for ownership from the given role
Returns:
List all matching Permissions
Throws:
ParseException
DatabaseException

findUserPermissions

public List<MolgenisPermission> findUserPermissions(Integer roleId,
                                                    Integer entityId)
                                             throws DatabaseException,
                                                    ParseException
Given a role id and an entity id, return a list of MolgenisPermissions for all users, where the given roleId owns the entity in the matched MolgenisPermissions (and only the entity passed in).

Parameters:
roleId - role id
entityId - entity id
Returns:
List matching permissions
Throws:
ParseException
DatabaseException

findPermission

public MolgenisPermission findPermission(Integer id)
                                  throws DatabaseException,
                                         ParseException
Finds permission based on a MolgenisPermission id

Parameters:
id -
Returns:
Throws:
DatabaseException
ParseException

update

public void update(Integer userId,
                   MolgenisPermission mp)
            throws DatabaseException,
                   ParseException,
                   IOException
Updates a given MolgenisPermission iff the given user is owner on that entity

Parameters:
userId - userId of user trying to update
mp - MolgenisPermission to update
Throws:
ParseException
DatabaseException
IOException

insert

public void insert(Integer userId,
                   MolgenisPermission mp)
            throws DatabaseException,
                   ParseException,
                   IOException
Inserts a given MolgenisPermission iff the given user is owner on the entity for whom a permission is being made. Note: Does not currently check for superusers

Parameters:
userId - userId of user trying to insert
mp - MolgenisPermission to insert
Throws:
ParseException
DatabaseException
IOException

exists

public boolean exists(MolgenisPermission mp)
               throws DatabaseException,
                      ParseException
Check to see if a given permission exists

Parameters:
mp -
Returns:
Throws:
DatabaseException
ParseException

findRole

public MolgenisRole findRole(Integer id)
                      throws DatabaseException,
                             ParseException
Find a MolgenisUser

Parameters:
id - UserId
Returns:
MolgenisUser
Throws:
DatabaseException
ParseException

findEntity

public MolgenisEntity findEntity(Integer id)
                          throws DatabaseException,
                                 ParseException
Find a MolgenisEntity by id

Parameters:
id - EntityId
Returns:
MolgenisEntity
Throws:
DatabaseException
ParseException

findRoles

public List<MolgenisRole> findRoles()
                             throws DatabaseException,
                                    ParseException
Find all Molgenis Users

Parameters:
id - EntityId
Returns:
MolgenisEntity
Throws:
DatabaseException
ParseException

findEntities

public List<MolgenisEntity> findEntities()
                                  throws DatabaseException,
                                         ParseException
Find all Molgenis Users

Parameters:
id - EntityId
Returns:
MolgenisEntity
Throws:
DatabaseException
ParseException

remove

public void remove(int roleId,
                   int permId)
            throws DatabaseException,
                   IOException,
                   ParseException
Remove a permission based on permission id. RoleId is also required to check for sufficient rights.

Parameters:
roleId - MolgenisRole id
permId - MolgenisPermission id
Throws:
DatabaseException
IOException
ParseException


Copyright © 2013. All Rights Reserved.