Java Code Examples for org.apache.catalina.security.SecurityUtil#isPackageProtectionEnabled()
The following examples show how to use
org.apache.catalina.security.SecurityUtil#isPackageProtectionEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardManager.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Save any currently active sessions in the appropriate persistence * mechanism, if any. If persistence is not supported, this method * returns without doing anything. * * @exception IOException if an input/output error occurs */ @Override public void unload() throws IOException { if (SecurityUtil.isPackageProtectionEnabled()){ try{ AccessController.doPrivileged( new PrivilegedDoUnload() ); } catch (PrivilegedActionException ex){ Exception exception = ex.getException(); if (exception instanceof IOException){ throw (IOException)exception; } if (log.isDebugEnabled()) log.debug("Unreported exception in unLoad() " + exception); } } else { doUnload(); } }
Example 2
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Executes the method of the specified <code>ApplicationContext</code> * @param method The method object to be invoked. * @param context The AppliationContext object on which the method * will be invoked * @param params The arguments passed to the called method. */ private Object executeMethod(final Method method, final ApplicationContext context, final Object[] params) throws PrivilegedActionException, IllegalAccessException, InvocationTargetException { if (SecurityUtil.isPackageProtectionEnabled()){ return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>(){ @Override public Object run() throws IllegalAccessException, InvocationTargetException{ return method.invoke(context, params); } }); } else { return method.invoke(context, params); } }
Example 3
Source File: ApplicationContextFacade.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override @SuppressWarnings("unchecked") // doPrivileged() returns the correct type public <T extends Servlet> T createServlet(Class<T> c) throws ServletException { if (SecurityUtil.isPackageProtectionEnabled()) { try { return (T) invokeMethod(context, "createServlet", new Object[]{c}); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); if (t instanceof ServletException) { throw (ServletException) t; } return null; } } else { return context.createServlet(c); } }
Example 4
Source File: StandardManager.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public void load() throws ClassNotFoundException, IOException { if (SecurityUtil.isPackageProtectionEnabled()){ try{ AccessController.doPrivileged( new PrivilegedDoLoad() ); } catch (PrivilegedActionException ex){ Exception exception = ex.getException(); if (exception instanceof ClassNotFoundException) { throw (ClassNotFoundException)exception; } else if (exception instanceof IOException) { throw (IOException)exception; } if (log.isDebugEnabled()) { log.debug("Unreported exception in load() ", exception); } } } else { doLoad(); } }
Example 5
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public <T extends EventListener> void addListener(T t) { if (SecurityUtil.isPackageProtectionEnabled()) { doPrivileged("addListener", new Class[]{EventListener.class}, new Object[]{t}); } else { context.addListener(t); } }
Example 6
Source File: ApplicationContextFacade.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Object getAttribute(String name) { if (SecurityUtil.isPackageProtectionEnabled()) { return doPrivileged("getAttribute", new Object[]{name}); } else { return context.getAttribute(name); } }
Example 7
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public String getInitParameter(String name) { if (SecurityUtil.isPackageProtectionEnabled()) { return (String) doPrivileged("getInitParameter", new Object[]{name}); } else { return context.getInitParameter(name); } }
Example 8
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * @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(); } }
Example 9
Source File: ApplicationContextFacade.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override @SuppressWarnings("unchecked") // doPrivileged() returns the correct type public Set<String> getResourcePaths(String path) { if (SecurityUtil.isPackageProtectionEnabled()){ return (Set<String>)doPrivileged("getResourcePaths", new Object[]{path}); } else { return context.getResourcePaths(path); } }
Example 10
Source File: ResponseFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void setContentType(String type) { if (isCommitted()) { return; } if (SecurityUtil.isPackageProtectionEnabled()){ AccessController.doPrivileged(new SetContentTypePrivilegedAction(type)); } else { response.setContentType(type); } }
Example 11
Source File: ApplicationContextFacade.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public String getRequestCharacterEncoding() { if (SecurityUtil.isPackageProtectionEnabled()) { return (String) doPrivileged("getRequestCharacterEncoding", null); } else { return context.getRequestCharacterEncoding(); } }
Example 12
Source File: ApplicationContextFacade.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public String getRealPath(String path) { if (SecurityUtil.isPackageProtectionEnabled()) { return (String) doPrivileged("getRealPath", new Object[]{path}); } else { return context.getRealPath(path); } }
Example 13
Source File: ResponseFacade.java From Tomcat8-Source-Read with MIT License | 5 votes |
@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(); } }
Example 14
Source File: ApplicationContextFacade.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void log(String msg) { if (SecurityUtil.isPackageProtectionEnabled()) { doPrivileged("log", new Object[]{msg} ); } else { context.log(msg); } }
Example 15
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") // doPrivileged() returns the correct type public Set<SessionTrackingMode> getDefaultSessionTrackingModes() { if (SecurityUtil.isPackageProtectionEnabled()) { return (Set<SessionTrackingMode>) doPrivileged("getDefaultSessionTrackingModes", null); } else { return context.getDefaultSessionTrackingModes(); } }
Example 16
Source File: PersistentManagerBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Write the provided session to the Store without modifying * the copy in memory or triggering passivation events. Does * nothing if the session is invalid or past its expiration. * @param session The session that should be written * @throws IOException an IO error occurred */ protected void writeSession(Session session) throws IOException { if (store == null || !session.isValid()) { return; } try { if (SecurityUtil.isPackageProtectionEnabled()){ try{ AccessController.doPrivileged(new PrivilegedStoreSave(session)); }catch(PrivilegedActionException ex){ Exception exception = ex.getException(); if (exception instanceof IOException) { throw (IOException) exception; } log.error("Exception in the Store during writeSession: " + exception, exception); } } else { store.save(session); } } catch (IOException e) { log.error(sm.getString ("persistentManager.serializeError", session.getIdInternal(), e)); throw e; } }
Example 17
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public InputStream getResourceAsStream(String path) { if (SecurityUtil.isPackageProtectionEnabled()) { return (InputStream) doPrivileged("getResourceAsStream", new Object[]{path}); } else { return context.getResourceAsStream(path); } }
Example 18
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public int getEffectiveMajorVersion() { if (SecurityUtil.isPackageProtectionEnabled()) { return ((Integer) doPrivileged("getEffectiveMajorVersion", null)).intValue(); } else { return context.getEffectiveMajorVersion(); } }
Example 19
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) { if (SecurityUtil.isPackageProtectionEnabled()) { return (ServletRegistration.Dynamic) doPrivileged("addServlet", new Class[]{String.class, Class.class}, new Object[]{servletName, servletClass}); } else { return context.addServlet(servletName, servletClass); } }
Example 20
Source File: ApplicationContextFacade.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) { if (SecurityUtil.isPackageProtectionEnabled()) { return (ServletRegistration.Dynamic) doPrivileged("addServlet", new Class[]{String.class, Servlet.class}, new Object[]{servletName, servlet}); } else { return context.addServlet(servletName, servlet); } }