/** Release the Filter instance associated with this FilterConfig, if there is one. */
  void release() {

    unregisterJMX();

    if (this.filter != null) {
      if (Globals.IS_SECURITY_ENABLED) {
        try {
          SecurityUtil.doAsPrivilege("destroy", filter);
        } catch (java.lang.Exception ex) {
          context.getLogger().error("ApplicationFilterConfig.doAsPrivilege", ex);
        }
        SecurityUtil.remove(filter);
      } else {
        filter.destroy();
      }
      if (!context.getIgnoreAnnotations()) {
        try {
          ((StandardContext) context).getInstanceManager().destroyInstance(this.filter);
        } catch (Exception e) {
          Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
          ExceptionUtils.handleThrowable(t);
          context.getLogger().error("ApplicationFilterConfig.preDestroy", t);
        }
      }
    }
    this.filter = null;
  }
 public String getMimeType(String file) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getMimeType", new Object[] {file});
   } else {
     return context.getMimeType(file);
   }
 }
 public String getContextPath() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getContextPath", null);
   } else {
     return context.getContextPath();
   }
 }
 public Enumeration getAttributeNames() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (Enumeration) doPrivileged("getAttributeNames", null);
   } else {
     return context.getAttributeNames();
   }
 }
 public Set getResourcePaths(String path) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (Set) doPrivileged("getResourcePaths", new Object[] {path});
   } else {
     return context.getResourcePaths(path);
   }
 }
 public void setAttribute(String name, Object object) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("setAttribute", new Object[] {name, object});
   } else {
     context.setAttribute(name, object);
   }
 }
 public String getInitParameter(String name) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getInitParameter", new Object[] {name});
   } else {
     return context.getInitParameter(name);
   }
 }
 public void log(String msg) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("log", new Object[] {msg});
   } else {
     context.log(msg);
   }
 }
 public RequestDispatcher getRequestDispatcher(final String path) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (RequestDispatcher) doPrivileged("getRequestDispatcher", new Object[] {path});
   } else {
     return context.getRequestDispatcher(path);
   }
 }
 public RequestDispatcher getNamedDispatcher(String name) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (RequestDispatcher) doPrivileged("getNamedDispatcher", new Object[] {name});
   } else {
     return context.getNamedDispatcher(name);
   }
 }
Ejemplo n.º 11
0
  protected void setConverter() throws IOException {

    if (coyoteRequest != null) {
      enc = coyoteRequest.getCharacterEncoding();
    }

    gotEnc = true;
    if (enc == null) {
      enc = DEFAULT_ENCODING;
    }
    conv = encoders.get(enc);
    if (conv == null) {
      if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
          conv =
              AccessController.doPrivileged(
                  new PrivilegedExceptionAction<B2CConverter>() {

                    @Override
                    public B2CConverter run() throws IOException {
                      return new B2CConverter(enc);
                    }
                  });
        } catch (PrivilegedActionException ex) {
          Exception e = ex.getException();
          if (e instanceof IOException) {
            throw (IOException) e;
          }
        }
      } else {
        conv = new B2CConverter(enc);
      }
      encoders.put(enc, conv);
    }
  }
 public InputStream getResourceAsStream(String path) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (InputStream) doPrivileged("getResourceAsStream", new Object[] {path});
   } else {
     return context.getResourceAsStream(path);
   }
 }
  @Override
  public void flushBuffer() throws IOException {

    if (isFinished())
      //            throw new IllegalStateException
      //                (/*sm.getString("responseFacade.finished")*/);
      return;

    if (SecurityUtil.isPackageProtectionEnabled()) {
      try {
        AccessController.doPrivileged(
            new PrivilegedExceptionAction<Void>() {

              @Override
              public Void run() throws IOException {
                response.setAppCommitted(true);

                response.flushBuffer();
                return null;
              }
            });
      } catch (PrivilegedActionException e) {
        Exception ex = e.getException();
        if (ex instanceof IOException) {
          throw (IOException) ex;
        }
      }
    } else {
      response.setAppCommitted(true);

      response.flushBuffer();
    }
  }
 public Object getAttribute(String name) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return doPrivileged("getAttribute", new Object[] {name});
   } else {
     return context.getAttribute(name);
   }
 }
 public void removeAttribute(String name) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("removeAttribute", new Object[] {name});
   } else {
     context.removeAttribute(name);
   }
 }
 public String getRealPath(String path) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getRealPath", new Object[] {path});
   } else {
     return context.getRealPath(path);
   }
 }
 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);
   }
 }
 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.º 19
0
 @Override
 public void declareRoles(String... roleNames) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("declareRoles", roleNames);
   } else {
     context.declareRoles(roleNames);
   }
 }
Ejemplo n.º 20
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.º 21
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);
   }
 }
 @Override
 public SessionCookieConfig getSessionCookieConfig() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (SessionCookieConfig) doPrivileged("getSessionCookieConfig", null);
   } else {
     return context.getSessionCookieConfig();
   }
 }
 @Override
 public int getEffectiveMinorVersion() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return ((Integer) doPrivileged("getEffectiveMinorVersion", null)).intValue();
   } else {
     return context.getEffectiveMinorVersion();
   }
 }
 @Override
 public <T extends EventListener> void addListener(T t) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("addListener", new Object[] {t.getClass().getName()});
   } else {
     context.addListener(t);
   }
 }
 @Override
 public JspConfigDescriptor getJspConfigDescriptor() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (JspConfigDescriptor) doPrivileged("getJspConfigDescriptor", null);
   } else {
     return context.getJspConfigDescriptor();
   }
 }
 @Override
 public FilterRegistration getFilterRegistration(String filterName) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (FilterRegistration) doPrivileged("getFilterRegistration", new Object[] {filterName});
   } else {
     return context.getFilterRegistration(filterName);
   }
 }
 @Override
 public ClassLoader getClassLoader() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (ClassLoader) doPrivileged("getClassLoader", null);
   } else {
     return context.getClassLoader();
   }
 }
 @Override
 public String getServletContextName() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (String) doPrivileged("getServletContextName", null);
   } else {
     return context.getServletContextName();
   }
 }
 @Override
 public void addListener(Class<? extends EventListener> listenerClass) {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     doPrivileged("addListener", new Object[] {listenerClass.getName()});
   } else {
     context.addListener(listenerClass);
   }
 }
Ejemplo n.º 30
0
 @Override
 @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
 public ClassLoader getClassLoader() {
   if (SecurityUtil.isPackageProtectionEnabled()) {
     return (ClassLoader) doPrivileged("getClassLoader", null);
   } else {
     return context.getClassLoader();
   }
 }