@Override
  protected void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    ApplicationContext applicationContext = ApplicationContext.getInstance();

    try {
      HttpContext httpContext = this.read(req);
      httpContext =
          this.filter.process(
              httpContext, applicationContext.getModel(), applicationContext.getConfiguration());
      this.write(resp, httpContext);

    } catch (FilterException e) {
      this.error(e, resp);
    }
  }
Ejemplo n.º 2
0
 @Override
 public void declareRoles(String... roleNames) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("declareRoles", roleNames);
   } else {
     context.declareRoles(roleNames);
   }
 }
Ejemplo n.º 3
0
 @Override
 public String getContextPath() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getContextPath", null);
   } else {
     return context.getContextPath();
   }
 }
Ejemplo n.º 4
0
 @Override
 public Object getAttribute(String name) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return doPrivileged("getAttribute", new Object[] {name});
   } else {
     return context.getAttribute(name);
   }
 }
Ejemplo n.º 5
0
 /**
  * Sets the session tracking modes that are to become effective for this <tt>ServletContext</tt>.
  */
 @Override
 public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("setSessionTrackingModes", new Object[] {sessionTrackingModes});
   } else {
     context.setSessionTrackingModes(sessionTrackingModes);
   }
 }
Ejemplo n.º 6
0
 @Override
 public void log(String msg) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("log", new Object[] {msg});
   } else {
     context.log(msg);
   }
 }
Ejemplo n.º 7
0
 /** Adds the listener with the given class name to this ServletContext. */
 @Override
 public void addListener(String className) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("addListener", new Object[] {className});
   } else {
     context.addListener(className);
   }
 }
Ejemplo n.º 8
0
 @Override
 public void setAttribute(String name, Object object) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("setAttribute", new Object[] {name, object});
   } else {
     context.setAttribute(name, object);
   }
 }
Ejemplo n.º 9
0
 @Override
 public void removeAttribute(String name) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("removeAttribute", new Object[] {name});
   } else {
     context.removeAttribute(name);
   }
 }
Ejemplo n.º 10
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public Enumeration<String> getAttributeNames() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (Enumeration<String>) doPrivileged("getAttributeNames", null);
   } else {
     return context.getAttributeNames();
   }
 }
Ejemplo n.º 11
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public String getInitParameter(String name) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getInitParameter", new Object[] {name});
   } else {
     return context.getInitParameter(name);
   }
 }
Ejemplo n.º 12
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public String getRealPath(String path) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getRealPath", new Object[] {path});
   } else {
     return context.getRealPath(path);
   }
 }
Ejemplo n.º 13
0
 @Override
 public void log(String message, Throwable throwable) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged(
         "log", new Class[] {String.class, Throwable.class}, new Object[] {message, throwable});
   } else {
     context.log(message, throwable);
   }
 }
Ejemplo n.º 14
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public RequestDispatcher getNamedDispatcher(String name) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (RequestDispatcher) doPrivileged("getNamedDispatcher", new Object[] {name});
   } else {
     return context.getNamedDispatcher(name);
   }
 }
Ejemplo n.º 15
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public String getServletContextName() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getServletContextName", null);
   } else {
     return context.getServletContextName();
   }
 }
Ejemplo n.º 16
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public ClassLoader getClassLoader() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (ClassLoader) doPrivileged("getClassLoader", null);
   } else {
     return context.getClassLoader();
   }
 }
Ejemplo n.º 17
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public String getMimeType(String file) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getMimeType", new Object[] {file});
   } else {
     return context.getMimeType(file);
   }
 }
Ejemplo n.º 18
0
 /**
  * Instantiates the given EventListener class and performs any required resource injection into
  * the new EventListener instance before returning it.
  */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (T) doPrivileged("createListener", new Object[] {clazz});
   } else {
     return context.createListener(clazz);
   }
 }
Ejemplo n.º 19
0
 /**
  * Gets the <code>&lt;jsp-config&gt;</code> related configuration that was aggregated from the
  * <code>web.xml</code> and <code>web-fragment.xml</code> descriptor files of the web application
  * represented by this ServletContext.
  */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public JspConfigDescriptor getJspConfigDescriptor() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (JspConfigDescriptor) doPrivileged("getJspConfigDescriptor", null);
   } else {
     return context.getJspConfigDescriptor();
   }
 }
Ejemplo n.º 20
0
 /** Adds the given listener to this ServletContext. */
 @Override
 public <T extends EventListener> void addListener(T t) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged(
         "addListener", new Class[] {EventListener.class}, new Object[] {t.getClass().getName()});
   } else {
     context.addListener(t);
   }
 }
Ejemplo n.º 21
0
 /** Adds a listener of the given class type to this ServletContext. */
 @Override
 public void addListener(Class<? extends EventListener> listenerClass) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged(
         "addListener", new Class[] {Class.class}, new Object[] {listenerClass.getName()});
   } else {
     context.addListener(listenerClass);
   }
 }
Ejemplo n.º 22
0
 /**
  * Gets the session tracking modes that are in effect for this <tt>ServletContext</tt>.
  *
  * @return set of the session tracking modes in effect for this <tt>ServletContext</tt>
  */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (Set<SessionTrackingMode>) doPrivileged("getEffectiveSessionTrackingModes", null);
   } else {
     return context.getEffectiveSessionTrackingModes();
   }
 }
Ejemplo n.º 23
0
 /**
  * Gets the <tt>SessionCookieConfig</tt> object through which various properties of the session
  * tracking cookies created on behalf of this <tt>ServletContext</tt> may be configured.
  */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public SessionCookieConfig getSessionCookieConfig() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (SessionCookieConfig) doPrivileged("getSessionCookieConfig", null);
   } else {
     return context.getSessionCookieConfig();
   }
 }
Ejemplo n.º 24
0
 /**
  * Gets a Map of the FilterRegistration objects corresponding to all currently registered filters.
  */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (Map<String, FilterRegistration>) doPrivileged("getFilterRegistrations", null);
   } else {
     return context.getFilterRegistrations();
   }
 }
Ejemplo n.º 25
0
 /** Gets the FilterRegistration corresponding to the filter with the given <tt>filterName</tt>. */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public FilterRegistration getFilterRegistration(String filterName) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (FilterRegistration) doPrivileged("getFilterRegistration", new Object[] {filterName});
   } else {
     return context.getFilterRegistration(filterName);
   }
 }
Ejemplo n.º 26
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public InputStream getResourceAsStream(String path) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (InputStream) doPrivileged("getResourceAsStream", new Object[] {path});
   } else {
     return context.getResourceAsStream(path);
   }
 }
Ejemplo n.º 27
0
 /** @deprecated As of Java Servlet API 2.1, with no direct replacement. */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 @Deprecated
 public Enumeration<Servlet> getServlets() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (Enumeration<Servlet>) doPrivileged("getServlets", null);
   } else {
     return context.getServlets();
   }
 }
Ejemplo n.º 28
0
 /** @deprecated As of Java Servlet API 2.1, use <code>log(String, Throwable)</code> instead */
 @Override
 @Deprecated
 public void log(Exception exception, String msg) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged(
         "log", new Class[] {Exception.class, String.class}, new Object[] {exception, msg});
   } else {
     context.log(exception, msg);
   }
 }
Ejemplo n.º 29
0
 /** Adds the filter with the given name and class name to this servlet context. */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public FilterRegistration.Dynamic addFilter(String filterName, String className) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (FilterRegistration.Dynamic)
         doPrivileged("addFilter", new Object[] {filterName, className});
   } else {
     return context.addFilter(filterName, className);
   }
 }
Ejemplo n.º 30
0
 /**
  * @return true if the context initialization parameter with the given name and value was set
  *     successfully on this ServletContext, and false if it was not set because this
  *     ServletContext already contains a context initialization parameter with a matching name
  */
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public boolean setInitParameter(String name, String value) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return ((Boolean) doPrivileged("setInitParameter", new Object[] {name, value}))
         .booleanValue();
   } else {
     return context.setInitParameter(name, value);
   }
 }