Package org.restlet.security
Class Role
java.lang.Object
org.restlet.security.Role
- All Implemented Interfaces:
Principal
Application specific role. Common examples are "administrator", "user",
"anonymous", "supervisor". Note that for reusability purpose, it is
recommended that those role don't reflect an actual organization, but more
the functional requirements of your application.
Two roles are considered equals if they belong to the same parent application
and have the same name and child roles. The description isn't used for
equality assessment.
Since version 2.2, they don't need to be the same Java objects anymore. In
order to prevent the multiplication of equivalent
Role instances, you
should try to call Application.getRole(String) method.- Author:
- Jerome Louvel, Tim Peierls
-
Constructor Summary
ConstructorsConstructorDescriptionRole()Default constructor.Role(Application application, String name) Constructor.Role(Application application, String name, String description) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic Roleget(Application application, String name) Finds an existing role or creates a new one if needed.static Roleget(Application application, String name, String description) Finds an existing role or creates a new one if needed.Returns the parent application.Returns the modifiable list of child roles.Returns the description.getName()Returns the name.inthashCode()voidsetApplication(Application application) Sets the parent application.voidsetChildRoles(List<Role> childRoles) Sets the modifiable list of child roles.voidsetDescription(String description) Sets the description.voidSets the name.toString()
-
Constructor Details
-
Role
public Role()Default constructor. Note that the parent application is retrieved using theApplication.getCurrent()method if available or is null. -
Role
Constructor.- Parameters:
application- The parent application or null.name- The name.
-
Role
Constructor.- Parameters:
application- The parent application or null.name- The name.description- The description.
-
-
Method Details
-
get
Finds an existing role or creates a new one if needed. Note that a null description will be set if the role has to be created.- Parameters:
application- The parent application.name- The role name to find or create.- Returns:
- The role found or created.
-
get
Finds an existing role or creates a new one if needed.- Parameters:
application- The parent application.name- The role name to find or create.description- The role description if one needs to be created.- Returns:
- The role found or created.
-
equals
-
getApplication
Returns the parent application.- Returns:
- The parent application.
-
getChildRoles
Returns the modifiable list of child roles.- Returns:
- The modifiable list of child roles.
-
getDescription
Returns the description.- Returns:
- The description.
-
getName
Returns the name. -
hashCode
public int hashCode() -
setApplication
Sets the parent application.- Parameters:
application- The parent application.
-
setChildRoles
Sets the modifiable list of child roles. This method clears the current list and adds all entries in the parameter list.- Parameters:
childRoles- A list of child roles.
-
setDescription
Sets the description.- Parameters:
description- The description.
-
setName
Sets the name.- Parameters:
name- The name.
-
toString
-