Class OpenPolicyResourceHandler

java.lang.Object
org.astrogrid.samp.web.OpenPolicyResourceHandler
All Implemented Interfaces:
HttpServer.Handler

public class OpenPolicyResourceHandler extends Object implements HttpServer.Handler
HTTP resource handler suitable for serving static cross-origin policy files.
Since:
2 Feb 2011
Author:
Mark Taylor
  • Constructor Details

    • OpenPolicyResourceHandler

      public OpenPolicyResourceHandler(String policyPath, ServerResource policyResource, OriginAuthorizer authorizer)
      Constructor.
      Parameters:
      policyPath - path at which the policy file will reside on this handler's server
      policyResource - content of policy file
      authorizer - controls who is permitted to view the policy file
  • Method Details

    • serveRequest

      public HttpServer.Response serveRequest(HttpServer.Request request)
      Description copied from interface: HttpServer.Handler
      Provides a response to an HTTP request. A handler which does not recognise the URL should simply return null; in this case there may be another handler which is able to serve the request. If the URL appears to be in this handler's domain but the request cannot be served for some reason, an error response should be returned.
      Specified by:
      serveRequest in interface HttpServer.Handler
      Parameters:
      request - HTTP request
      Returns:
      response response to request, or null
    • createPolicyHandler

      public static HttpServer.Handler createPolicyHandler(String path, URL contentUrl, String contentType, OriginAuthorizer oAuth) throws IOException
      Creates a handler suitable for serving static cross-origin policy files.
      Parameters:
      path - path at which the policy file will reside on the handler's HTTP server
      contentUrl - external URL at which the resource contents can be found; this will be retrieved once and cached
      oAuth - controls who is permitted to retrieve the policy file
      Throws:
      IOException
    • createFlashPolicyHandler

      public static HttpServer.Handler createFlashPolicyHandler(OriginAuthorizer oAuth) throws IOException
      Returns a handler which can serve the /crossdomain.xml file used by Adobe Flash. The policy file permits access from anywhere.
      Parameters:
      oAuth - controls who is permitted to retrieve the policy file
      Returns:
      policy file handler
      Throws:
      IOException
      See Also:
    • createSilverlightPolicyHandler

      public static HttpServer.Handler createSilverlightPolicyHandler(OriginAuthorizer oAuth) throws IOException
      Returns a handler which can serve the /clientaccesspolicy.xml file used by Microsoft Silverlight. The policy file permits access from anywhere.
      Parameters:
      oAuth - controls who is permitted to retrieve the policy file
      Returns:
      policy file handler
      Throws:
      IOException
      See Also: