classCache.put("getRequestDispatcher", clazz);
classCache.put("getNamedDispatcher", clazz);
classCache.put("getServlet", clazz);
+ classCache.put("setInitParameter", new Class[]{String.class, String.class});
+ classCache.put("createServlet", new Class[]{Class.class});
+ classCache.put("addServlet", new Class[]{String.class, String.class});
+ classCache.put("createFilter", new Class[]{Class.class});
+ classCache.put("addFilter", new Class[]{String.class, String.class});
+ classCache.put("createListener", new Class[]{Class.class});
+ classCache.put("addListener", clazz);
+ classCache.put("getFilterRegistration", clazz);
+ classCache.put("getServletRegistration", clazz);
classCache.put("getInitParameter", clazz);
classCache.put("setAttribute", new Class[]{String.class, Object.class});
classCache.put("removeAttribute", clazz);
classCache.put("getAttribute", clazz);
classCache.put("log", clazz);
classCache.put("setSessionTrackingModes", new Class[]{EnumSet.class} );
- classCache.put("setSessionCookieConfig",
- new Class[]{SessionCookieConfig.class});
}
Filter filter) {
if (SecurityUtil.isPackageProtectionEnabled()) {
return (FilterRegistration.Dynamic) doPrivileged(
- "addFilter", new Object[]{filterName, filter});
+ "addFilter", new Class[]{String.class, Filter.class}, new Object[]{filterName, filter});
} else {
return context.addFilter(filterName, filter);
}
Class<? extends Filter> filterClass) {
if (SecurityUtil.isPackageProtectionEnabled()) {
return (FilterRegistration.Dynamic) doPrivileged(
- "addFilter", new Object[]{filterName, filterClass});
+ "addFilter", new Object[]{filterName, filterClass.getName()});
} else {
return context.addFilter(filterName, filterClass);
}
public <T extends Filter> T createFilter(Class<T> c)
throws ServletException {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (T) doPrivileged(
- "createFilter", new Object[]{c});
+ try {
+ return (T) invokeMethod(context, "createFilter",
+ new Object[]{c});
+ } catch (Throwable t) {
+ if (t instanceof ServletException) {
+ throw (ServletException) t;
+ }
+ return null;
+ }
} else {
return context.createFilter(c);
}
public FilterRegistration getFilterRegistration(String filterName) {
if (SecurityUtil.isPackageProtectionEnabled()) {
return (FilterRegistration) doPrivileged(
- "findFilterRegistration", new Object[]{filterName});
+ "getFilterRegistration", new Object[]{filterName});
} else {
return context.getFilterRegistration(filterName);
}
Servlet servlet) {
if (SecurityUtil.isPackageProtectionEnabled()) {
return (ServletRegistration.Dynamic) doPrivileged(
- "addServlet", new Object[]{servletName, servlet});
+ "addServlet", new Class[]{String.class, Servlet.class}, new Object[]{servletName, servlet});
} else {
return context.addServlet(servletName, servlet);
}
Class <? extends Servlet> servletClass) {
if (SecurityUtil.isPackageProtectionEnabled()) {
return (ServletRegistration.Dynamic) doPrivileged(
- "addServlet", new Object[]{servletName, servletClass});
+ "addServlet", new Object[]{servletName, servletClass.getName()});
} else {
return context.addServlet(servletName, servletClass);
}
public <T extends Servlet> T createServlet(Class<T> c)
throws ServletException {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (T) doPrivileged(
- "createServlet", new Object[]{c});
+ try {
+ return (T) invokeMethod(context, "createServlet",
+ new Object[]{c});
+ } catch (Throwable t) {
+ if (t instanceof ServletException) {
+ throw (ServletException) t;
+ }
+ return null;
+ }
} else {
return context.createServlet(c);
}
public ServletRegistration getServletRegistration(String servletName) {
if (SecurityUtil.isPackageProtectionEnabled()) {
return (ServletRegistration) doPrivileged(
- "findServletRegistration", new Object[]{servletName});
+ "getServletRegistration", new Object[]{servletName});
} else {
return context.getServletRegistration(servletName);
}
public void addListener(Class<? extends EventListener> listenerClass) {
if (SecurityUtil.isPackageProtectionEnabled()) {
doPrivileged("addListener",
- new Object[]{listenerClass});
+ new Object[]{listenerClass.getName()});
} else {
context.addListener(listenerClass);
}
public <T extends EventListener> void addListener(T t) {
if (SecurityUtil.isPackageProtectionEnabled()) {
doPrivileged("addListener",
- new Object[]{t});
+ new Object[]{t.getClass().getName()});
} else {
context.addListener(t);
}
public <T extends EventListener> T createListener(Class<T> c)
throws ServletException {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (T) doPrivileged("createListener", new Object[]{c});
+ try {
+ return (T) invokeMethod(context, "createListener",
+ new Object[]{c});
+ } catch (Throwable t) {
+ if (t instanceof ServletException) {
+ throw (ServletException) t;
+ }
+ return null;
+ }
} else {
return context.createListener(c);
}
@Override
public void declareRoles(String... roleNames) {
if (SecurityUtil.isPackageProtectionEnabled()) {
+//FIXME
doPrivileged("declareRoles",
new Object[]{roleNames});
} else {
/**
* Use reflection to invoke the requested method. Cache the method object
* to speed up the process
- * will be invoked
* @param methodName The method to call.
* @param params The arguments passed to the called method.
*/
- private Object doPrivileged(final String methodName, final Object[] params){
+ private Object doPrivileged(final String methodName, final Object[] params) {
try{
return invokeMethod(context, methodName, params);
}catch(Throwable t){
*/
private Object doPrivileged(final String methodName,
final Class<?>[] clazz,
- Object[] params){
+ Object[] params) {
try{
Method method = context.getClass().getMethod(methodName, clazz);