com.bradmcevoy.http.http11
Class OptionsHandler

java.lang.Object
  extended by com.bradmcevoy.http.http11.OptionsHandler
All Implemented Interfaces:
Handler, ResourceHandler

public class OptionsHandler
extends java.lang.Object
implements ResourceHandler

Support the OPTIONS http method. Note that windows 7 appears to require un-authenticated access to OPTIONS requests, so this handler now supports configurable selection of allowing un-authenticated access.

Author:
brad

Constructor Summary
OptionsHandler(Http11ResponseHandler responseHandler)
          Creates an OptionHandler with no authorisation
OptionsHandler(Http11ResponseHandler responseHandler, HandlerHelper handlerHelper)
          Creates an OptionHandler with no authorisation Note that the handlerHelper is redundant, but this constructor is kept for backwards compatibility
OptionsHandler(Http11ResponseHandler responseHandler, HandlerHelper handlerHelper, boolean enableAuthorisation)
          Allows the choice of enabling authorisation.
 
Method Summary
 java.lang.String[] getMethods()
           
 boolean isCompatible(Resource handler)
           
 boolean isEnableAuthorisation()
           
 void process(HttpManager manager, Request request, Response response)
           
 void processResource(HttpManager manager, Request request, Response response, Resource resource)
           
 void setEnableAuthorisation(boolean enableAuthorisation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionsHandler

public OptionsHandler(Http11ResponseHandler responseHandler)
Creates an OptionHandler with no authorisation

Parameters:
responseHandler -

OptionsHandler

public OptionsHandler(Http11ResponseHandler responseHandler,
                      HandlerHelper handlerHelper)
Creates an OptionHandler with no authorisation Note that the handlerHelper is redundant, but this constructor is kept for backwards compatibility

Parameters:
responseHandler -

OptionsHandler

public OptionsHandler(Http11ResponseHandler responseHandler,
                      HandlerHelper handlerHelper,
                      boolean enableAuthorisation)
Allows the choice of enabling authorisation. Some webdav clients (such as windows 7) require un-authenticated OPTIONS requests, because they use the information returned to determine how to authenticate. However, this might be considered a security risk as it allows mailicious users to determine the existence of resources, although not their content.

Parameters:
responseHandler -
handlerHelper - - redundant if enableAuthorisation is false
enableAuthorisation - - if false OPTIONS requests will never request authentication
Method Detail

process

public void process(HttpManager manager,
                    Request request,
                    Response response)
             throws NotAuthorizedException,
                    ConflictException,
                    BadRequestException
Specified by:
process in interface Handler
Throws:
NotAuthorizedException
ConflictException
BadRequestException

processResource

public void processResource(HttpManager manager,
                            Request request,
                            Response response,
                            Resource resource)
                     throws NotAuthorizedException,
                            ConflictException,
                            BadRequestException
Specified by:
processResource in interface ResourceHandler
Throws:
NotAuthorizedException
ConflictException
BadRequestException

getMethods

public java.lang.String[] getMethods()
Specified by:
getMethods in interface Handler
Returns:
- the http methods supported by this handler. Must be all upper case.

isCompatible

public boolean isCompatible(Resource handler)
Specified by:
isCompatible in interface Handler
Returns:
- true if the given resource is compatible with this method

isEnableAuthorisation

public boolean isEnableAuthorisation()

setEnableAuthorisation

public void setEnableAuthorisation(boolean enableAuthorisation)


Copyright © 2011. All Rights Reserved.