org.bbqjs.spring.ajax
Class RequestForwarder
java.lang.Object
org.bbqjs.spring.ajax.RequestForwarder
- All Implemented Interfaces:
- org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
- ServerWhitelistRequestForwarder, SingleServerRequestForwarder
@Controller
public class RequestForwarder
- extends Object
- implements org.springframework.beans.factory.InitializingBean
Forwards requests on to remote servers. This controller is intended to work around the Single Origin Policy
enforced by most web browsers. The Single Origin Policy dictates that an AJAX request can only be sent
to the domain from which the JavaScript sending the request was loaded. This is to prevent cross site
scripting attacks. Sometimes though that functionality is useful though (when writing a client for a remote API
based service, for example).
By default this class forwards to whatever the client requests. To limit the destination servers, use
SingleServerRequestForwarder or ServerWhitelistRequestForwarder
- See Also:
ServerWhitelistRequestForwarder
,
SingleServerRequestForwarder
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
headerName
protected String headerName
RequestForwarder
public RequestForwarder()
afterPropertiesSet
public void afterPropertiesSet()
throws Exception
- Specified by:
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
- Throws:
Exception
getUrlToForwardTo
protected URL getUrlToForwardTo(javax.servlet.http.HttpServletRequest request)
throws Exception
- Throws:
Exception
copyHeaders
protected void copyHeaders(HttpURLConnection urlConnection,
javax.servlet.http.HttpServletResponse response)
forwardRequest
@RequestMapping(value="/forward")
public void forwardRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws Exception
- Throws:
Exception
sendRequest
protected HttpURLConnection sendRequest(URL url,
javax.servlet.http.HttpServletRequest request,
InputStream inputStream)
throws IOException
- Throws:
IOException
setHeaderName
public void setHeaderName(String headerName)
setForwardToSelfSignedCertificateServers
public void setForwardToSelfSignedCertificateServers(boolean forwardToSelfSignedCertificateServers)
Copyright © 2012. All Rights Reserved.