org.apache.catalina.ContainerServlet Java Examples

The following examples show how to use org.apache.catalina.ContainerServlet. 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: DefaultInstanceManager.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private void checkAccess(Class<?> clazz) {
    if (privileged) {
        return;
    }
    if (ContainerServlet.class.isAssignableFrom(clazz)) {
        throw new SecurityException(sm.getString(
                "defaultInstanceManager.restrictedContainerServlet", clazz));
    }
    while (clazz != null) {
        if (restrictedClasses.contains(clazz.getName())) {
            throw new SecurityException(sm.getString(
                    "defaultInstanceManager.restrictedClass", clazz));
        }
        clazz = clazz.getSuperclass();
    }
}
 
Example #2
Source File: StandardWrapper.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * @return <code>true</code> if the specified class name represents a
 * container provided servlet class that should be loaded by the
 * server class loader.
 *
 * @param classname Name of the class to be checked
 *
 * @deprecated Unused. Will be removed in Tomcat 9
 */
@Deprecated
protected boolean isContainerProvidedServlet(String classname) {

    if (classname.startsWith("org.apache.catalina.")) {
        return true;
    }
    try {
        Class<?> clazz =
            this.getClass().getClassLoader().loadClass(classname);
        return (ContainerServlet.class.isAssignableFrom(clazz));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        return false;
    }

}
 
Example #3
Source File: DefaultInstanceManager.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
private void checkAccess(Class<?> clazz) {
    if (privileged) {
        return;
    }
    if (Filter.class.isAssignableFrom(clazz)) {
        checkAccess(clazz, restrictedFilters);
    } else if (Servlet.class.isAssignableFrom(clazz)) {
        if (ContainerServlet.class.isAssignableFrom(clazz)) {
            throw new SecurityException("Restricted (ContainerServlet) " +
                    clazz);
        }
        checkAccess(clazz, restrictedServlets);
    } else {
        checkAccess(clazz, restrictedListeners);
    }
}
 
Example #4
Source File: StandardWrapper.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Return <code>true</code> if the specified class name represents a
 * container provided servlet class that should be loaded by the
 * server class loader.
 *
 * @param classname Name of the class to be checked
 */
protected boolean isContainerProvidedServlet(String classname) {

    if (classname.startsWith("org.apache.catalina.")) {
        return (true);
    }
    try {
        Class<?> clazz =
            this.getClass().getClassLoader().loadClass(classname);
        return (ContainerServlet.class.isAssignableFrom(clazz));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        return (false);
    }

}
 
Example #5
Source File: DefaultInstanceManager.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
private void checkAccess(Class<?> clazz) {
    if (privileged) {
        return;
    }
    if (ContainerServlet.class.isAssignableFrom(clazz)) {
        throw new SecurityException(sm.getString(
                "defaultInstanceManager.restrictedContainerServlet", clazz));
    }
    while (clazz != null) {
        if (restrictedClasses.contains(clazz.getName())) {
            throw new SecurityException(sm.getString(
                    "defaultInstanceManager.restrictedClass", clazz));
        }
        clazz = clazz.getSuperclass();
    }
}
 
Example #6
Source File: DefaultInstanceManager.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected Class<?> loadClass(String className, ClassLoader classLoader)
        throws ClassNotFoundException {
    if (className.startsWith("org.apache.catalina")) {
        return containerClassLoader.loadClass(className);
    }
    try {
        Class<?> clazz = containerClassLoader.loadClass(className);
        if (ContainerServlet.class.isAssignableFrom(clazz)) {
            return clazz;
        }
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
    }
    return classLoader.loadClass(className);
}
 
Example #7
Source File: DefaultInstanceManager.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
protected Class<?> loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
    if (className.startsWith("org.apache.catalina")) {
        return containerClassLoader.loadClass(className);
    }
    try {
        Class<?> clazz = containerClassLoader.loadClass(className);
        if (ContainerServlet.class.isAssignableFrom(clazz)) {
            return clazz;
        }
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
    }
    return classLoader.loadClass(className);
}
 
Example #8
Source File: DefaultInstanceManager.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
protected Class<?> loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
    if (className.startsWith("org.apache.catalina")) {
        return containerClassLoader.loadClass(className);
    }
    try {
        Class<?> clazz = containerClassLoader.loadClass(className);
        if (ContainerServlet.class.isAssignableFrom(clazz)) {
            return clazz;
        }
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
    }
    return classLoader.loadClass(className);
}