Java Code Examples for org.apache.jasper.Constants#IS_SECURITY_ENABLED

The following examples show how to use org.apache.jasper.Constants#IS_SECURITY_ENABLED . 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: JspFactoryImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public PageContext getPageContext(Servlet servlet,
			      ServletRequest request,
                                     ServletResponse response,
                                     String errorPageURL,                    
                                     boolean needsSession,
			      int bufferSize,
                                     boolean autoflush) {

if (Constants.IS_SECURITY_ENABLED) {
    PrivilegedGetPageContext dp =
                   new PrivilegedGetPageContext(
	        this, servlet, request, response, errorPageURL,
                       needsSession, bufferSize, autoflush);
    return AccessController.doPrivileged(dp);
} else {
    return internalGetPageContext(servlet, request, response,
				  errorPageURL, needsSession,
				  bufferSize, autoflush);
}
   }
 
Example 2
Source File: JspFactoryImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public PageContext getPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {

    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
                this, servlet, request, response, errorPageURL,
                needsSession, bufferSize, autoflush);
        return AccessController.doPrivileged(dp);
    } else {
        return internalGetPageContext(servlet, request, response,
                errorPageURL, needsSession,
                bufferSize, autoflush);
    }
}
 
Example 3
Source File: ELFunctionMapper.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Convert a binary class name into a canonical one that can be used
 * when generating Java source code.
 *
 * @param className Binary class name
 * @return          Canonical equivalent
 */
private String getCanonicalName(String className) throws JasperException {
    Class<?> clazz;

    ClassLoader tccl;
    if (Constants.IS_SECURITY_ENABLED) {
        PrivilegedAction<ClassLoader> pa = new PrivilegedGetTccl();
        tccl = AccessController.doPrivileged(pa);
    } else {
        tccl = Thread.currentThread().getContextClassLoader();
    }

    try {
        clazz = Class.forName(className, false, tccl);
    } catch (ClassNotFoundException e) {
        throw new JasperException(e);
    }
    return clazz.getCanonicalName();
}
 
Example 4
Source File: JspRuntimeLibrary.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public static void introspecthelper(Object bean, String prop,
                                      String value, ServletRequest request,
                                      String param, boolean ignoreMethodNF)
                                      throws JasperException
  {
      if (Constants.IS_SECURITY_ENABLED) {
          try {
              PrivilegedIntrospectHelper dp =
    new PrivilegedIntrospectHelper(
	bean,prop,value,request,param,ignoreMethodNF);
              AccessController.doPrivileged(dp);
          } catch( PrivilegedActionException pe) {
              Exception e = pe.getException();
              throw (JasperException)e;
          }
      } else {
          internalIntrospecthelper(
bean,prop,value,request,param,ignoreMethodNF);
      }
  }
 
Example 5
Source File: JspRuntimeLibrary.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
public static void introspecthelper(Object bean, String prop,
                                    String value, ServletRequest request,
                                    String param, boolean ignoreMethodNF)
                                    throws JasperException
{
    if( Constants.IS_SECURITY_ENABLED ) {
        try {
            PrivilegedIntrospectHelper dp =
                new PrivilegedIntrospectHelper(
                    bean,prop,value,request,param,ignoreMethodNF);
            AccessController.doPrivileged(dp);
        } catch( PrivilegedActionException pe) {
            Exception e = pe.getException();
            throw (JasperException)e;
        }
    } else {
        internalIntrospecthelper(
            bean,prop,value,request,param,ignoreMethodNF);
    }
}
 
Example 6
Source File: JspFactoryImpl.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public PageContext getPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {

    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
                this, servlet, request, response, errorPageURL,
                needsSession, bufferSize, autoflush);
        return AccessController.doPrivileged(dp);
    } else {
        return internalGetPageContext(servlet, request, response,
                errorPageURL, needsSession,
                bufferSize, autoflush);
    }
}
 
Example 7
Source File: ELFunctionMapper.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Convert a binary class name into a canonical one that can be used
 * when generating Java source code.
 * 
 * @param className Binary class name
 * @return          Canonical equivalent
 */
private String getCanonicalName(String className) throws JasperException {
    Class<?> clazz;
    
    ClassLoader tccl;
    if (Constants.IS_SECURITY_ENABLED) {
        PrivilegedAction<ClassLoader> pa = new PrivilegedGetTccl();
        tccl = AccessController.doPrivileged(pa);
    } else {
        tccl = Thread.currentThread().getContextClassLoader();
    }

    try {
        clazz = Class.forName(className, false, tccl);
    } catch (ClassNotFoundException e) {
        throw new JasperException(e);
    }
    return clazz.getCanonicalName();
}
 
Example 8
Source File: ELFunctionMapper.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Convert a binary class name into a canonical one that can be used
 * when generating Java source code.
 * 
 * @param className Binary class name
 * @return          Canonical equivalent
 */
private String getCanonicalName(String className) throws JasperException {
    Class<?> clazz;
    
    ClassLoader tccl;
    if (Constants.IS_SECURITY_ENABLED) {
        PrivilegedAction<ClassLoader> pa = new PrivilegedGetTccl();
        tccl = AccessController.doPrivileged(pa);
    } else {
        tccl = Thread.currentThread().getContextClassLoader();
    }

    try {
        clazz = Class.forName(className, false, tccl);
    } catch (ClassNotFoundException e) {
        throw new JasperException(e);
    }
    return clazz.getCanonicalName();
}
 
Example 9
Source File: JspFactoryImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public JspApplicationContext getJspApplicationContext(
        final ServletContext context) {
    if (Constants.IS_SECURITY_ENABLED) {
        return AccessController.doPrivileged(
                new PrivilegedAction<JspApplicationContext>() {
            @Override
            public JspApplicationContext run() {
                return JspApplicationContextImpl.getInstance(context);
            }
        });
    } else {
        return JspApplicationContextImpl.getInstance(context);
    }
}
 
Example 10
Source File: SecurityUtil.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Return the <code>SecurityManager</code> only if Security is enabled AND
 * package protection mechanism is enabled.
 * @return <code>true</code> if package protection is enabled
 */
public static boolean isPackageProtectionEnabled(){
    if (packageDefinitionEnabled && Constants.IS_SECURITY_ENABLED){
        return true;
    }
    return false;
}
 
Example 11
Source File: JspFactoryImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void releasePageContext(PageContext pc) {
    if( pc == null )
        return;
    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(
                this,pc);
        AccessController.doPrivileged(dp);
    } else {
        internalReleasePageContext(pc);
    }
}
 
Example 12
Source File: SecurityUtil.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Return the <code>SecurityManager</code> only if Security is enabled AND
 * package protection mechanism is enabled.
 */
public static boolean isPackageProtectionEnabled(){
    if (packageDefinitionEnabled && Constants.IS_SECURITY_ENABLED){
        return true;
    }
    return false;
}
 
Example 13
Source File: ELContextImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static ELResolver getDefaultResolver() {
    if (Constants.IS_SECURITY_ENABLED) {
        CompositeELResolver defaultResolver = new CompositeELResolver();
        defaultResolver.add(new MapELResolver());
        defaultResolver.add(new ResourceBundleELResolver());
        defaultResolver.add(new ListELResolver());
        defaultResolver.add(new ArrayELResolver());
        defaultResolver.add(new BeanELResolver());
        return defaultResolver;
    } else {
        return DefaultResolver;
    }
}
 
Example 14
Source File: JspFactoryImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void releasePageContext(PageContext pc) {
    if( pc == null )
        return;
    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(
                this,pc);
        AccessController.doPrivileged(dp);
    } else {
        internalReleasePageContext(pc);
    }
}
 
Example 15
Source File: ELContextImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static ELResolver getDefaultResolver(ExpressionFactory factory) {
    if (Constants.IS_SECURITY_ENABLED) {
        CompositeELResolver defaultResolver = new CompositeELResolver();
        defaultResolver.add(factory.getStreamELResolver());
        defaultResolver.add(new StaticFieldELResolver());
        defaultResolver.add(new MapELResolver());
        defaultResolver.add(new ResourceBundleELResolver());
        defaultResolver.add(new ListELResolver());
        defaultResolver.add(new ArrayELResolver());
        defaultResolver.add(new BeanELResolver());
        return defaultResolver;
    } else {
        return DefaultResolver;
    }
}
 
Example 16
Source File: ELContextImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public static ELResolver getDefaultResolver() {
    if (Constants.IS_SECURITY_ENABLED) {
        CompositeELResolver defaultResolver = new CompositeELResolver();
        defaultResolver.add(new MapELResolver());
        defaultResolver.add(new ResourceBundleELResolver());
        defaultResolver.add(new ListELResolver());
        defaultResolver.add(new ArrayELResolver());
        defaultResolver.add(new BeanELResolver());
        return defaultResolver;
    } else {
        return DefaultResolver;
    }
}
 
Example 17
Source File: JspFactoryImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void releasePageContext(PageContext pc) {
    if( pc == null )
        return;
    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(
                this,pc);
        AccessController.doPrivileged(dp);
    } else {
        internalReleasePageContext(pc);
    }
}
 
Example 18
Source File: ParserUtils.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public ParserUtils(boolean validating) {
    this(validating, Constants.IS_SECURITY_ENABLED);
}
 
Example 19
Source File: JspRuntimeContext.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Create a JspRuntimeContext for a web application context.
 *
 * Loads in any previously generated dependencies from file.
 *
 * @param context ServletContext for web application
 */
public JspRuntimeContext(ServletContext context, Options options) {

    this.context = context;
    this.options = options;

    // Get the parent class loader
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    if (loader == null) {
        loader = this.getClass().getClassLoader();
    }

    if (log.isDebugEnabled()) {
        if (loader != null) {
            log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
                                           loader.toString()));
        } else {
            log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
                                           "<none>"));
        }
    }

    parentClassLoader =  loader;
    classpath = initClassPath();

    if (context instanceof org.apache.jasper.servlet.JspCServletContext) {
        codeSource = null;
        permissionCollection = null;
        return;
    }

    if (Constants.IS_SECURITY_ENABLED) {
        SecurityHolder holder = initSecurity();
        codeSource = holder.cs;
        permissionCollection = holder.pc;
    } else {
        codeSource = null;
        permissionCollection = null;
    }

    // If this web application context is running from a
    // directory, start the background compilation thread
    String appBase = context.getRealPath("/");         
    if (!options.getDevelopment()
            && appBase != null
            && options.getCheckInterval() > 0) {
        lastCompileCheck = System.currentTimeMillis();
    }                                            

    if (options.getMaxLoadedJsps() > 0) {
        jspQueue = new FastRemovalDequeue<JspServletWrapper>(options.getMaxLoadedJsps());
        if (log.isDebugEnabled()) {
            log.debug(Localizer.getMessage("jsp.message.jsp_queue_created",
                                           "" + options.getMaxLoadedJsps(), context.getContextPath()));
        }
    }

    /* Init parameter is in seconds, locally we use milliseconds */
    jspIdleTimeout = options.getJspIdleTimeout() * 1000;
}
 
Example 20
Source File: JspRuntimeContext.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * Create a JspRuntimeContext for a web application context.
 *
 * Loads in any previously generated dependencies from file.
 *
 * @param context ServletContext for web application
 * @param options The main Jasper options
 */
public JspRuntimeContext(ServletContext context, Options options) {

    this.context = context;
    this.options = options;

    // Get the parent class loader
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    if (loader == null) {
        loader = this.getClass().getClassLoader();
    }

    if (log.isDebugEnabled()) {
        if (loader != null) {
            log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
                                           loader.toString()));
        } else {
            log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
                                           "<none>"));
        }
    }

    parentClassLoader =  loader;
    classpath = initClassPath();

    if (context instanceof org.apache.jasper.servlet.JspCServletContext) {
        codeSource = null;
        permissionCollection = null;
        return;
    }

    if (Constants.IS_SECURITY_ENABLED) {
        SecurityHolder holder = initSecurity();
        codeSource = holder.cs;
        permissionCollection = holder.pc;
    } else {
        codeSource = null;
        permissionCollection = null;
    }

    // If this web application context is running from a
    // directory, start the background compilation thread
    String appBase = context.getRealPath("/");
    if (!options.getDevelopment()
            && appBase != null
            && options.getCheckInterval() > 0) {
        lastCompileCheck = System.currentTimeMillis();
    }

    if (options.getMaxLoadedJsps() > 0) {
        jspQueue = new FastRemovalDequeue<>(options.getMaxLoadedJsps());
        if (log.isDebugEnabled()) {
            log.debug(Localizer.getMessage("jsp.message.jsp_queue_created",
                                           "" + options.getMaxLoadedJsps(), context.getContextPath()));
        }
    }

    /* Init parameter is in seconds, locally we use milliseconds */
    jspIdleTimeout = options.getJspIdleTimeout() * 1000;
}