org.restlet.security

## Class RoleAuthorizer

- java.lang.Object
- - org.restlet.Restlet
  - - org.restlet.routing.Filter
    - - org.restlet.security.Authorizer
      - - org.restlet.security.RoleAuthorizer

All Implemented Interfaces:
  Uniform

    public class RoleAuthorizer
    extends Authorizer

Authorizer based on authorized and forbidden roles. Note that if no role is added to the "authorizedRoles" list, then only the "forbiddenRoles" list is considered.

Author:
  Jerome Louvel

### Field Summary

### Fields inherited from class org.restlet.security.Authorizer

`ALWAYS, AUTHENTICATED, NEVER`

### Fields inherited from class org.restlet.routing.Filter

`CONTINUE, SKIP, STOP`

### Constructor Summary

Constructors
Constructor and Description
`RoleAuthorizer()` Default constructor.
`RoleAuthorizer(java.lang.String identifier)` Constructor.

### Method Summary

Methods
`boolean` `authorize(Request request, Response response)` Authorizes the request only if its subject is in one of the authorized roles and in none of the forbidden ones.
`java.util.List<Role>` `getAuthorizedRoles()` Returns the modifiable list of authorized roles.
`java.util.List<Role>` `getForbiddenRoles()` Returns the modifiable list of forbidden roles.
`void` `setAuthorizedRoles(java.util.List<Role> authorizedRoles)` Sets the modifiable list of authorized roles.
`void` `setForbiddenRoles(java.util.List<Role> forbiddenRoles)` Sets the modifiable list of forbidden roles.

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

`authorized, beforeHandle, getIdentifier, setIdentifier, unauthorized`

### Methods inherited from class org.restlet.routing.Filter

`afterHandle, doHandle, getNext, handle, hasNext, setNext, setNext, start, stop`

### Methods inherited from class org.restlet.Restlet

`finalize, getApplication, getAuthor, getContext, getDescription, getLogger, getName, getOwner, isStarted, isStopped, setAuthor, setContext, setDescription, setName, setOwner`

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

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

### Constructor Detail

#### RoleAuthorizer

    public RoleAuthorizer()

Default constructor.

#### RoleAuthorizer

    public RoleAuthorizer(java.lang.String identifier)

Constructor.

Parameters:
  `identifier` - The identifier unique within an application.

### Method Detail

#### authorize

    public boolean authorize(Request request,
                    Response response)

Authorizes the request only if its subject is in one of the authorized roles and in none of the forbidden ones.

Specified by:
  `authorize` in class `Authorizer`
Parameters:
  `request` - The request sent.
  `response` - The response to update.
Returns:
  True if the authorization succeeded.

#### getAuthorizedRoles

    public java.util.List<Role> getAuthorizedRoles()

Returns the modifiable list of authorized roles.

Returns:
  The modifiable list of authorized roles.

#### getForbiddenRoles

    public java.util.List<Role> getForbiddenRoles()

Returns the modifiable list of forbidden roles.

Returns:
  The modifiable list of forbidden roles.

#### setAuthorizedRoles

    public void setAuthorizedRoles(java.util.List<Role> authorizedRoles)

Sets the modifiable list of authorized roles. This method clears the current list and adds all entries in the parameter list.

Parameters:
  `authorizedRoles` - A list of authorized roles.

#### setForbiddenRoles

    public void setForbiddenRoles(java.util.List<Role> forbiddenRoles)

Sets the modifiable list of forbidden roles. This method clears the current list and adds all entries in the parameter list.

Parameters:
  `forbiddenRoles` - A list of forbidden roles.