org.restlet.security

## Class MethodAuthorizer

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

All Implemented Interfaces:
  Uniform

    public class MethodAuthorizer
    extends Authorizer

Authorizer based on authorized methods. Note that this authorizer makes the difference between authenticated and anonymous users.

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
`MethodAuthorizer()` Default constructor.
`MethodAuthorizer(java.lang.String identifier)` Constructor.

### Method Summary

Methods
`boolean` `authorize(Request request, Response response)` Authorizes the request only if its method is one of the authorized methods.
`java.util.List<Method>` `getAnonymousMethods()` Returns the modifiable list of methods authorized for anonymous users.
`java.util.List<Method>` `getAuthenticatedMethods()` Returns the modifiable list of methods authorized for authenticated users.
`void` `setAnonymousMethods(java.util.List<Method> anonymousMethods)` Sets the modifiable list of methods authorized for anonymous users.
`void` `setAuthenticatedMethods(java.util.List<Method> authenticatedMethods)` Sets the modifiable list of methods authorized for authenticated users.

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

#### MethodAuthorizer

    public MethodAuthorizer()

Default constructor.

#### MethodAuthorizer

    public MethodAuthorizer(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 method is one of the authorized methods.

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

#### getAnonymousMethods

    public java.util.List<Method> getAnonymousMethods()

Returns the modifiable list of methods authorized for anonymous users.

Returns:
  The modifiable list of methods authorized for anonymous users.

#### getAuthenticatedMethods

    public java.util.List<Method> getAuthenticatedMethods()

Returns the modifiable list of methods authorized for authenticated users.

Returns:
  The modifiable list of methods authorized for authenticated users.

#### setAnonymousMethods

    public void setAnonymousMethods(java.util.List<Method> anonymousMethods)

Sets the modifiable list of methods authorized for anonymous users. This method clears the current list and adds all entries in the parameter list.

Parameters:
  `anonymousMethods` - A list of methods authorized for anonymous users.

#### setAuthenticatedMethods

    public void setAuthenticatedMethods(java.util.List<Method> authenticatedMethods)

Sets the modifiable list of methods authorized for authenticated users. This method clears the current list and adds all entries in the parameter list.

Parameters:
  `authenticatedMethods` - A list of methods authorized for authenticated users.