org.restlet.security

## 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 Summary

Constructors
Constructor and Description
`MemoryRealm()` Constructor.

### Method Summary

Methods
`java.util.Set<Group>` `findGroups(User user)` Finds the set of groups where a given user is a member.
`java.util.Set<Group>` `findGroups(User user, boolean inheritOnly)` Finds the set of groups where a given user is a member.
`java.util.Set<Role>` `findRoles(Group userGroup)` Finds the roles mapped to given user group.
`java.util.Set<Role>` `findRoles(java.util.Set<Group> userGroups)` Finds the roles mapped to given user groups.
`java.util.Set<Role>` `findRoles(User user)` Finds the roles mapped to a given user.
`User` `findUser(java.lang.String userIdentifier)` Finds a user in the organization based on its identifier.
`java.util.List<Group>` `getRootGroups()` Returns the modifiable list of root groups.
`java.util.List<User>` `getUsers()` Returns the modifiable list of users.
`void` `map(Group group, Role role)` Maps a group defined in a component to a role defined in the application.
`void` `map(User user, Role role)` Maps a user defined in a component to a role defined in the application.
`void` `setRootGroups(java.util.List<Group> rootGroups)` Sets the modifiable list of root groups.
`void` `setUsers(java.util.List<User> users)` Sets the modifiable list of users.
`void` `unmap(Group group, Role role)` Unmaps a group defined in a component from a role defined in the application.
`void` `unmap(User user, Role role)` Unmaps a user defined in a component from a role defined in the application.

### Methods inherited from class org.restlet.security.Realm

`getEnroler, getName, getParameters, getVerifier, isStarted, isStopped, setEnroler, setName, setParameters, setVerifier, start, stop, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### MemoryRealm

    public MemoryRealm()

Constructor.

### Method Detail

#### findGroups

    public java.util.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 java.util.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 java.util.Set<Role> findRoles(Group userGroup)

Finds the roles mapped to given user group.

Parameters:
  `userGroup` - The user group.
Returns:
  The roles found.

#### findRoles

    public java.util.Set<Role> findRoles(java.util.Set<Group> userGroups)

Finds the roles mapped to given user groups.

Parameters:
  `userGroups` - The user groups.
Returns:
  The roles found.

#### findRoles

    public java.util.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(java.lang.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 java.util.List<Group> getRootGroups()

Returns the modifiable list of root groups.

Returns:
  The modifiable list of root groups.

#### getUsers

    public java.util.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,
           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(java.util.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(java.util.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,
             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,
             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.