Class MemoryRealm

java.lang.Object
org.restlet.security.Realm
org.restlet.security.MemoryRealm

public class MemoryRealm extends Realm
Security realm based on a memory model. The model is composed of root groups, users and mapping to associated roles.
Author:
Jerome Louvel
  • Constructor Details

    • MemoryRealm

      public MemoryRealm()
      Constructor.
  • Method Details

    • findGroups

      public Set<Group> findGroups(User user)
      Finds the set of groups where a given user is a member. Note that inheritable ancestors groups are also returned.
      Parameters:
      user - The member user.
      Returns:
      The set of groups.
    • findGroups

      public Set<Group> findGroups(User user, boolean inheritOnly)
      Finds the set of groups where a given user is a member.
      Parameters:
      user - The member user.
      inheritOnly - Indicates if only the ancestors groups that have their "inheritRoles" property enabled should be added.
      Returns:
      The set of groups.
    • findRoles

      public Set<Role> findRoles(Application application, Group userGroup)
      Finds the roles mapped to a given user group.
      Parameters:
      application - The parent application. Can't be null.
      userGroup - The user group.
      Returns:
      The roles found.
      Throws:
      IllegalArgumentException - If application is null.
    • findRoles

      public Set<Role> findRoles(Application application, Set<Group> userGroups)
      Finds the roles mapped to given user groups.
      Parameters:
      application - The parent application. Can't be null.
      userGroups - The user groups.
      Returns:
      The roles found.
      Throws:
      IllegalArgumentException - If application is null.
    • findRoles

      public Set<Role> findRoles(Application application, User user)
      Finds the roles mapped to a given user, for a specific application.
      Parameters:
      application - The parent application. Can't be null.
      user - The user.
      Returns:
      The roles found.
      Throws:
      IllegalArgumentException - If application is null.
    • findRoles

      public Set<Role> findRoles(Group userGroup)
      Finds the roles mapped to given user group.
      Parameters:
      userGroup - The user group.
      Returns:
      The roles found.
    • findRoles

      public Set<Role> findRoles(Set<Group> userGroups)
      Finds the roles mapped to given user groups.
      Parameters:
      userGroups - The user groups.
      Returns:
      The roles found.
    • findRoles

      public Set<Role> findRoles(User user)
      Finds the roles mapped to a given user.
      Parameters:
      user - The user.
      Returns:
      The roles found.
    • findUser

      public User findUser(String userIdentifier)
      Finds a user in the organization based on its identifier.
      Parameters:
      userIdentifier - The identifier to match.
      Returns:
      The matched user or null.
    • getRootGroups

      public List<Group> getRootGroups()
      Returns the modifiable list of root groups.
      Returns:
      The modifiable list of root groups.
    • getUsers

      public List<User> getUsers()
      Returns the modifiable list of users.
      Returns:
      The modifiable list of users.
    • map

      public void map(Group group, Role role)
      Maps a group defined in a component to a role defined in the application.
      Parameters:
      group - The source group.
      role - The target role.
    • map

      public void map(User user, Application application, String roleName)
      Maps a user defined in a component to a role defined in the application.
      Parameters:
      user - The source user.
      application - The parent application. Can't be null.
      roleName - The target role name.
      Throws:
      IllegalArgumentException - If application is null.
    • map

      public void map(User user, Role role)
      Maps a user defined in a component to a role defined in the application.
      Parameters:
      user - The source user.
      role - The target role.
    • setRootGroups

      public void setRootGroups(List<Group> rootGroups)
      Sets the modifiable list of root groups. This method clears the current list and adds all entries in the parameter list.
      Parameters:
      rootGroups - A list of root groups.
    • setUsers

      public void setUsers(List<User> users)
      Sets the modifiable list of users. This method clears the current list and adds all entries in the parameter list.
      Parameters:
      users - A list of users.
    • unmap

      public void unmap(Group group, Application application, String roleName)
      Unmaps a group defined in a component from a role defined in the application.
      Parameters:
      group - The source group.
      application - The parent application. Can't be null.
      roleName - The target role name.
      Throws:
      IllegalArgumentException - If application is null.
    • unmap

      public void unmap(Group group, Role role)
      Unmaps a group defined in a component from a role defined in the application.
      Parameters:
      group - The source group.
      role - The target role.
    • unmap

      public void unmap(User user, Application application, String roleName)
      Unmaps a user defined in a component from a role defined in the application.
      Parameters:
      user - The source user.
      application - The parent application. Can't be null.
      roleName - The target role name.
      Throws:
      IllegalArgumentException - If application is null.
    • unmap

      public void unmap(User user, Role role)
      Unmaps a user defined in a component from a role defined in the application.
      Parameters:
      user - The source user.
      role - The target role.