package admin; import java.util.Collection; /** * Manages user role assignments. Used by CommandTarget to authorize users * who issue commands. */ public abstract class RoleManager { public static final Role INSTRUCTOR_ROLE = Role.INSTRUCTOR; /** * One-to-one assignment of User and a Role. */ abstract class UserRoleAssignment { Role Role; User User; } /** * Assignment between a Role and the Permissions * it was given. */ abstract class RolePermission { Role role; Collection permissions; } /** * Collection of User-Role assignments. */ Collection userRoleAssignmentCollection; /** * Collection of Role-Permissions assignment. */ Collection rolePermissioncollection; /** * Assigns a Role to a User. * @param role Role to assign. * @param user User to assign to. */ abstract void assign(Role role, User user); /** * Revokes a Role from a User. * @param role Role to revoke. * @param user User to revoke from. */ abstract void revoke(Role role, User user); /** * Accessor for User-Role assignments. * @return all User-Role assignments. */ abstract Collection getUserRoleAssignments(); /** * Accessor for all Users enrolled in a course. * @return all Users enrolled in a course. */ abstract Collection getAllUsers(); /** * Returns all Users with the specified Role. * @param role Role to use as a key to * look for Users. * @return all Users with the specified Role. */ abstract Collection getUsers(Role role); /** * Returns all Roles that a given User has. * @param user User to get Roles from. * @return all Roles that the User has. pre: //none post: return != null */ abstract Collection getRoles(User user); /** * Accessor for the Permissionss a given User has. * @param user the User to find Permissionss for. * @return all Permissionss the given User has. pre: // none post: return != null */ abstract Collection getPerms(User user); /** * Grants a Permission to the given Role. * @param role Role to grant Permission to. * @param perm Permission to grant. */ abstract void grantRolePerm(Role role, Permission perm); /** * Revokes a Permission from the given Role. * @param role Role to revoke Permission from. * @param perm Permission to revoke. */ abstract void revokeRolePerm(Role role, Permission perm); }