Restlet Framework 2.2.1
Java Standard Edition

org.restlet.security
Class Role

java.lang.Object
  extended by org.restlet.security.Role
All Implemented Interfaces:
Principal

public class Role
extends Object
implements 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

Field Summary
static Role ALL
          Deprecated. To be removed as it is ambiguous, roles being specific to a given application.
 
Constructor Summary
Role()
          Default constructor.
Role(Application application, String name)
          Constructor.
Role(Application application, String name, String description)
          Constructor.
Role(String name)
          Deprecated. Use Role(Application, String) instead.
Role(String name, String description)
          Deprecated. Use Role(Application, String, String) instead.
 
Method Summary
 boolean equals(Object o)
           
static Role get(Application application, String name)
          Finds an existing role or creates a new one if needed.
static Role get(Application application, String name, String description)
          Finds an existing role or creates a new one if needed.
 Application getApplication()
          Returns the parent application.
 List<Role> getChildRoles()
          Returns the modifiable list of child roles.
 String getDescription()
          Returns the description.
 String getName()
          Returns the name.
 int hashCode()
           
 void setApplication(Application application)
          Sets the parent application.
 void setChildRoles(List<Role> childRoles)
          Sets the modifiable list of child roles.
 void setDescription(String description)
          Sets the description.
 void setName(String name)
          Sets the name.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

@Deprecated
public static final Role ALL
Deprecated. To be removed as it is ambiguous, roles being specific to a given application.
Unmodifiable role that covers all existing roles. Its name is "*" by convention.

Constructor Detail

Role

public Role()
Default constructor. Note that the parent application is retrieved using the Application.getCurrent() method if available or is null.


Role

public Role(Application application,
            String name)
Constructor.

Parameters:
application - The parent application or null.
name - The name.

Role

public Role(Application application,
            String name,
            String description)
Constructor.

Parameters:
application - The parent application or null.
name - The name.
description - The description.

Role

@Deprecated
public Role(String name)
Deprecated. Use Role(Application, String) instead.

Constructor. Note that the parent application is retrieved using the Application.getCurrent() method.

Parameters:
name - The name.

Role

@Deprecated
public Role(String name,
                       String description)
Deprecated. Use Role(Application, String, String) instead.

Constructor. Note that the parent application is retrieved using the Application.getCurrent() method.

Parameters:
name - The name.
description - The description.
Method Detail

get

public static Role get(Application application,
                       String name)
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

public static Role get(Application application,
                       String name,
                       String description)
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

public boolean equals(Object o)
Specified by:
equals in interface Principal
Overrides:
equals in class Object

getApplication

public Application getApplication()
Returns the parent application.

Returns:
The parent application.

getChildRoles

public List<Role> getChildRoles()
Returns the modifiable list of child roles.

Returns:
The modifiable list of child roles.

getDescription

public String getDescription()
Returns the description.

Returns:
The description.

getName

public String getName()
Returns the name.

Specified by:
getName in interface Principal
Returns:
The name.

hashCode

public int hashCode()
Specified by:
hashCode in interface Principal
Overrides:
hashCode in class Object

setApplication

public void setApplication(Application application)
Sets the parent application.

Parameters:
application - The parent application.

setChildRoles

public void setChildRoles(List<Role> childRoles)
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

public void setDescription(String description)
Sets the description.

Parameters:
description - The description.

setName

public void setName(String name)
Sets the name.

Parameters:
name - The name.

toString

public String toString()
Specified by:
toString in interface Principal
Overrides:
toString in class Object

Restlet Framework 2.2.1
Java Standard Edition

Copyright © 2005-2014 Restlet.