- Direct Known Subclasses:
OS390ThreadSubject
The default ThreadSubject implementation 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 desired ThreadSubject implementation 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 doAs method
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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectdoAs(Subject subject, PrivilegedAction<?> action) Perform work as a particularSubject.static ObjectdoAs(Subject subject, PrivilegedExceptionAction<?> action) Perform work as a particularSubject.static ObjectdoAsPrivileged(Subject subject, PrivilegedAction<?> action, AccessControlContext acc) Perform work as a particularSubject.static ObjectdoAsPrivileged(Subject subject, PrivilegedExceptionAction<?> action, AccessControlContext acc) Perform work as a particularSubject.static void
-
Method Details
-
doAs
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:
NullPointerException- if thePrivilegedActionisnull.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.UnsupportedOperationException- if theThreadSubjectimplementation fails or is not supported, or if there is no OS/390 public principal for theSubject.
-
doAs
public static Object doAs(Subject subject, PrivilegedExceptionAction<?> action) throws 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:
NullPointerException- if thePrivilegedActionisnull.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.UnsupportedOperationException- if theThreadSubjectimplementation fails or is not supported, or if there is no OS/390 public principal for theSubject.PrivilegedActionException
-
doAsPrivileged
public static Object doAsPrivileged(Subject subject, PrivilegedAction<?> action, 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:
NullPointerException- if thePrivilegedActionisnull.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.UnsupportedOperationException- if theThreadSubjectimplementation fails or is not supported, or if there is no OS/390 public principal for theSubject.
-
doAsPrivileged
public static Object doAsPrivileged(Subject subject, PrivilegedExceptionAction<?> action, AccessControlContext acc) throws 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:
NullPointerException- if thePrivilegedActionisnull.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.UnsupportedOperationException- if theThreadSubjectimplementation fails or is not supported, or if there is no OS/390 public principal for theSubject.PrivilegedActionException
-
whoaminow
public static void whoaminow()
-