org.restlet.security

## Class Authorizer

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

All Implemented Interfaces:
  Uniform

Direct Known Subclasses:
  MethodAuthorizer, RoleAuthorizer

    public abstract class Authorizer
    extends Filter

Filter authorizing requests.

Author:
  Jerome Louvel
See Also:
  User Guide - Authorization

### Field Summary

Fields
`static Authorizer` `ALWAYS` Authorizer returning true all the time.
`static Authorizer` `AUTHENTICATED` Authorizer returning true for all authenticated requests.
`static Authorizer` `NEVER` Authorizer returning false all the time.

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

`CONTINUE, SKIP, STOP`

### Constructor Summary

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

### Method Summary

Methods
`protected abstract boolean` `authorize(Request request, Response response)` Attempts to authorize the request.
`protected int` `authorized(Request request, Response response)` Invoked upon successful authorization.
`protected int` `beforeHandle(Request request, Response response)` Allows filtering before processing by the next Restlet.
`java.lang.String` `getIdentifier()` Returns the identifier unique within an application.
`void` `setIdentifier(java.lang.String identifier)` Sets the identifier unique within an application.
`protected int` `unauthorized(Request request, Response response)` Invoked upon failed authorization.

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

### Field Detail

#### ALWAYS

    public static final Authorizer ALWAYS

Authorizer returning true all the time.

#### AUTHENTICATED

    public static final Authorizer AUTHENTICATED

Authorizer returning true for all authenticated requests. For unauthenticated requests, it sets the response's status to `Status.CLIENT_ERROR_UNAUTHORIZED` instead of the default `Status.CLIENT_ERROR_FORBIDDEN`.

See Also:
  `ClientInfo.isAuthenticated()`

#### NEVER

    public static final Authorizer NEVER

Authorizer returning false all the time.

### Constructor Detail

#### Authorizer

    public Authorizer()

Default constructor.

#### Authorizer

    public Authorizer(java.lang.String identifier)

Constructor.

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

### Method Detail

#### authorize

    protected abstract boolean authorize(Request request,
                    Response response)

Attempts to authorize the request.

Parameters:
  `request` - The request sent.
  `response` - The response to update.
Returns:
  True if the authorization succeeded.

#### authorized

    protected int authorized(Request request,
                 Response response)

Invoked upon successful authorization. Returns `Filter.CONTINUE` by default.

Parameters:
  `request` - The request sent.
  `response` - The response to update.
Returns:
  The filter continuation code.

#### beforeHandle

    protected int beforeHandle(Request request,
                   Response response)

Description copied from class: `Filter`
Allows filtering before processing by the next Restlet. Returns `Filter.CONTINUE` by default.

Overrides:
  `beforeHandle` in class `Filter`
Parameters:
  `request` - The request to handle.
  `response` - The response to update.
Returns:
  The continuation status. Either `Filter.CONTINUE` or `Filter.SKIP` or `Filter.STOP`.

#### getIdentifier

    public java.lang.String getIdentifier()

Returns the identifier unique within an application.

Returns:
  The identifier unique within an application.

#### setIdentifier

    public void setIdentifier(java.lang.String identifier)

Sets the identifier unique within an application.

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

#### unauthorized

    protected int unauthorized(Request request,
                   Response response)

Invoked upon failed authorization. Sets the status to `Status.CLIENT_ERROR_FORBIDDEN` and returns `Filter.STOP` by default.

Parameters:
  `request` - The request sent.
  `response` - The response to update.
Returns:
  The filter continuation code.