Package org.astrogrid.samp.web
Class OpenPolicyResourceHandler
- java.lang.Object
-
- org.astrogrid.samp.web.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 Summary
Constructors Constructor Description OpenPolicyResourceHandler(java.lang.String policyPath, ServerResource policyResource, OriginAuthorizer authorizer)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HttpServer.Handler
createFlashPolicyHandler(OriginAuthorizer oAuth)
Returns a handler which can serve the /crossdomain.xml file used by Adobe Flash.static HttpServer.Handler
createPolicyHandler(java.lang.String path, java.net.URL contentUrl, java.lang.String contentType, OriginAuthorizer oAuth)
Creates a handler suitable for serving static cross-origin policy files.static HttpServer.Handler
createSilverlightPolicyHandler(OriginAuthorizer oAuth)
Returns a handler which can serve the /clientaccesspolicy.xml file used by Microsoft Silverlight.HttpServer.Response
serveRequest(HttpServer.Request request)
Provides a response to an HTTP request.
-
-
-
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 serverpolicyResource
- content of policy fileauthorizer
- 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 interfaceHttpServer.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 servercontentUrl
- external URL at which the resource contents can be found; this will be retrieved once and cachedoAuth
- 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
-
-