Class OpenPolicyResourceHandler

  • All Implemented Interfaces:
    HttpServer.Handler

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

      • OpenPolicyResourceHandler

        public OpenPolicyResourceHandler​(java.lang.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 Detail

      • 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​(java.lang.String path,
                                                             java.net.URL contentUrl,
                                                             java.lang.String contentType,
                                                             OriginAuthorizer oAuth)
                                                      throws java.io.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:
        java.io.IOException
      • createFlashPolicyHandler

        public static HttpServer.Handler createFlashPolicyHandler​(OriginAuthorizer oAuth)
                                                           throws java.io.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:
        java.io.IOException
        See Also:
        Adobe Flash cross-origin policy
      • createSilverlightPolicyHandler

        public static HttpServer.Handler createSilverlightPolicyHandler​(OriginAuthorizer oAuth)
                                                                 throws java.io.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:
        java.io.IOException
        See Also:
        MS Silverlight cross-origin policy