org.apache.tomcat.util.security.PrivilegedSetTccl Java Examples

The following examples show how to use org.apache.tomcat.util.security.PrivilegedSetTccl. 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: TaskThreadFactory.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public Thread newThread(Runnable r) {
    TaskThread t = new TaskThread(group, r, namePrefix + threadNumber.getAndIncrement());
    t.setDaemon(daemon);
    t.setPriority(threadPriority);

    // Set the context class loader of newly created threads to be the class
    // loader that loaded this factory. This avoids retaining references to
    // web application class loaders and similar.
    if (Constants.IS_SECURITY_ENABLED) {
        PrivilegedAction<Void> pa = new PrivilegedSetTccl(
                t, getClass().getClassLoader());
        AccessController.doPrivileged(pa);
    } else {
        t.setContextClassLoader(getClass().getClassLoader());
    }

    return t;
}
 
Example #2
Source File: PersistentValve.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
private void bind(Context context) {
    // Bind the context CL to the current thread
    if (clBindRequired && context.getLoader() != null) {
        if (Globals.IS_SECURITY_ENABLED) {
            PrivilegedAction<Void> pa =
                    new PrivilegedSetTccl(context.getLoader().getClassLoader());
            AccessController.doPrivileged(pa);                
        } else {
            Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());
        }
    }
}
 
Example #3
Source File: PersistentValve.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
private void unbind() {
    if (clBindRequired) {
        if (Globals.IS_SECURITY_ENABLED) {
            PrivilegedAction<Void> pa = new PrivilegedSetTccl(MY_CLASSLOADER);
            AccessController.doPrivileged(pa);                
        } else {
            Thread.currentThread().setContextClassLoader(MY_CLASSLOADER);
        }
    }
}
 
Example #4
Source File: PersistentValve.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private void bind(Context context) {
    // Bind the context CL to the current thread
    if (clBindRequired && context.getLoader() != null) {
        if (Globals.IS_SECURITY_ENABLED) {
            PrivilegedAction<Void> pa =
                    new PrivilegedSetTccl(context.getLoader().getClassLoader());
            AccessController.doPrivileged(pa);                
        } else {
            Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());
        }
    }
}
 
Example #5
Source File: PersistentValve.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private void unbind() {
    if (clBindRequired) {
        if (Globals.IS_SECURITY_ENABLED) {
            PrivilegedAction<Void> pa = new PrivilegedSetTccl(MY_CLASSLOADER);
            AccessController.doPrivileged(pa);                
        } else {
            Thread.currentThread().setContextClassLoader(MY_CLASSLOADER);
        }
    }
}