in plugin-core/plugin/src/main/groovy/grails/plugin/springsecurity/web/access/GrailsWebInvocationPrivilegeEvaluator.groovy [114:151]
static HttpServletRequest createInstance(String contextPath, String httpMethod, String requestURI) {
Map<String, Object> attributes = [:]
(HttpServletRequest)Proxy.newProxyInstance(HttpServletRequest.classLoader,
[HttpServletRequest] as Class[], new InvocationHandler() {
def invoke(proxy, Method method, Object[] args) {
String methodName = method.name
if ('getContextPath' == methodName) return contextPath
if ('getMethod' == methodName) return httpMethod
if ('getRequestURI' == methodName) return requestURI
if ('setAttribute' == methodName) {
attributes[(String)args[0]] = args[1]
return null
}
if ('getAttribute' == methodName) {
return attributes[args[0]]
}
if ('getProtocol' == methodName || 'getScheme' == methodName) return 'http'
if ('getServerName' == methodName) return 'localhost'
if ('getServerPort' == methodName) return 8080
if (methodName.startsWith('is')) return false
if ('getParameterMap' == methodName) return Collections.emptyMap()
if ('getAttributeNames' == methodName ||
'getHeaderNames' == methodName ||
'getHeaders' == methodName ||
'getLocales' == methodName ||
'getParameterNames' == methodName) {
return Collections.enumeration(Collections.emptySet())
}
}
})
}