Class ThreadSubject
- java.lang.Object
-
- com.ibm.security.auth.ThreadSubject
-
- Direct Known Subclasses:
- OS390ThreadSubject
public abstract class ThreadSubject extends java.lang.ObjectSubclasses of this abstract class provide a way to set the underlying operating system thread identity to the appropriate value, the default implementation is OS390ThreadSubject.The default
ThreadSubjectimplementation for OS390 is com.ibm.security.auth.OS390ThreadSubject. This can be overridded by specifying or modifying the value of the "thread.subject.provider" security property (in the Java security properties file) to the fully qualified name of the desiredThreadSubjectimplementation class. The Java security properties file is located in the file named <JAVA_HOME>/lib/security/java.security, where <JAVA_HOME> refers to the directory where the JDK was installed. To disallow ThreadSubject processing completely, the following line can be inserted in the Java security properties file:thread.subject.provider=Each implementation must have a constructor which takes no arguments. This allows the
doAsmethod to properly instantiate it.This implementation will perform a pthread_security_np for the existing thread to set the identity of the thread prior to executing the action.
-
-
Constructor Summary
Constructors Constructor and Description ThreadSubject()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.ObjectdoAs(Subject subject, java.security.PrivilegedAction action)Perform work as a particularSubject.static java.lang.ObjectdoAs(Subject subject, java.security.PrivilegedExceptionAction action)Perform work as a particularSubject.static java.lang.ObjectdoAsPrivileged(Subject subject, java.security.PrivilegedAction action, java.security.AccessControlContext acc)Perform work as a particularSubject.static java.lang.ObjectdoAsPrivileged(Subject subject, java.security.PrivilegedExceptionAction action, java.security.AccessControlContext acc)Perform work as a particularSubject.static voidwhoaminow()
-
-
-
Method Detail
-
doAs
public static java.lang.Object doAs(Subject subject, java.security.PrivilegedAction action)
Perform work as a particularSubject. This method implementation is identical to the correspondingSubject.doAsmethod implementation but with one major addition:This method instantiates the default or specified
ThreadSubjectwhich invokes pthread_security_np for the existing thread to set the identity of the thread prior to executing thePrivilegedAction. After thePrivilegedActionexecution completes, pthread_security_np is again invoked to restore the environment to that of the original thread identity.- Parameters:
subject- theSubjectthat the specifiedactionwill run as.action- the code to be run as the specifiedSubject.- Returns:
- the
Objectreturned by the PrivilegedAction's execution. - Throws:
java.lang.NullPointerException- if thePrivilegedActionisnull.java.lang.SecurityException- if the caller attempts to invoke this method and does not have permission, or if the caller invokes this method as privileged and does not have permission. Note that since ThreadSubject also incorporates Subject processing, the permissions must include doAs permissions as well as threadSubjectDoAs.java.lang.UnsupportedOperationException- if theThreadSubjectimplementation fails or is not supported, or if there is no OS/390 public principal for theSubject.
-
doAs
public static java.lang.Object doAs(Subject subject, java.security.PrivilegedExceptionAction action) throws java.security.PrivilegedActionException
Perform work as a particularSubject. This method implementation is identical to the correspondingSubject.doAsmethod implementation but with one major addition:This method instantiates the default or specified
ThreadSubjectand invokes pthread_security_np for the existing thread to set the identity of the thread prior to executing thePrivilegedExceptionAction. After thePrivilegedExceptionActionexecution completes, pthread_security_np is again invoked to restore the environment to that of the original thread identity.- Parameters:
subject- theSubjectthat the specifiedactionwill run as.action- the code to be run as the specifiedSubject.- Returns:
- the
Objectreturned by the PrivilegedAction's execution. - Throws:
java.lang.NullPointerException- if thePrivilegedActionisnull.java.lang.SecurityException- if the caller attempts to invoke this method and does not have permission, or if the caller invokes this method as privileged and does not have permission. Note that since ThreadSubject also incorporates Subject processing, the permissions must include doAs permissions as well as threadSubjectDoAs.java.lang.UnsupportedOperationException- if theThreadSubjectimplementation fails or is not supported, or if there is no OS/390 public principal for theSubject.java.security.PrivilegedActionException
-
doAsPrivileged
public static java.lang.Object doAsPrivileged(Subject subject, java.security.PrivilegedAction action, java.security.AccessControlContext acc)
Perform work as a particularSubject. This method implementation is identical to the correspondingSubject.doAsPrivilegedmethod implementation but with one major addition:This method instantiates the default or specified
ThreadSubjectthen invokes pthread_security_np for the existing thread to set the identity of the thread prior prior to executing thePrivilegedAction. After thePrivilegedActionexecution completes, pthread_security_np is again invoked to restore the environment to that of the original thread identity.- Parameters:
subject- theSubjectthat the specifiedactionwill run as.action- the code to be run as the specifiedSubject.- Returns:
- the
Objectreturned by the PrivilegedAction's execution. - Throws:
java.lang.NullPointerException- if thePrivilegedActionisnull.java.lang.SecurityException- if the caller attempts to invoke this method and does not have permission, or if the caller invokes this method as privileged and does not have permission. Note that since ThreadSubject also incorporates Subject processing, the permissions must include doAs permissions as well as threadSubjectDoAs.java.lang.UnsupportedOperationException- if theThreadSubjectimplementation fails or is not supported, or if there is no OS/390 public principal for theSubject.
-
doAsPrivileged
public static java.lang.Object doAsPrivileged(Subject subject, java.security.PrivilegedExceptionAction action, java.security.AccessControlContext acc) throws java.security.PrivilegedActionException
Perform work as a particularSubject. This method implementation is identical to the correspondingSubject.doAsPrivilegedmethod implementation but with one major addition:This method instantiates the default or specified
ThreadSubjectthen invokes pthread_security_np for the existing thread to set the identity of the thread prior to executing thePrivilegedExceptionAction. After thePrivilegedExceptionActionexecution completes, pthread_security_np is again invoked to restore the environment to that of the original thread identity.- Parameters:
subject- theSubjectthat the specifiedactionwill run as.action- the code to be run as the specifiedSubject.- Returns:
- the
Objectreturned by the PrivilegedAction's execution. - Throws:
java.lang.NullPointerException- if thePrivilegedActionisnull.java.lang.SecurityException- if the caller attempts to invoke this method and does not have permission, or if the caller invokes this method as privileged and does not have permission. Note that since ThreadSubject also incorporates Subject processing, the permissions must include doAs permissions as well as threadSubjectDoAs.java.lang.UnsupportedOperationException- if theThreadSubjectimplementation fails or is not supported, or if there is no OS/390 public principal for theSubject.java.security.PrivilegedActionException
-
whoaminow
public static void whoaminow()
-
-