- java.lang.Object
-
- com.ibm.security.auth.ThreadSubject
-
- Direct Known Subclasses:
OS390ThreadSubject
public abstract class ThreadSubject extends java.lang.Object
Subclasses 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
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 desiredThreadSubject
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.
-
-
Constructor Summary
Constructors Constructor Description ThreadSubject()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
doAs(javax.security.auth.Subject subject, java.security.PrivilegedAction action)
Perform work as a particularSubject
.static java.lang.Object
doAs(javax.security.auth.Subject subject, java.security.PrivilegedExceptionAction action)
Perform work as a particularSubject
.static java.lang.Object
doAsPrivileged(javax.security.auth.Subject subject, java.security.PrivilegedAction action, java.security.AccessControlContext acc)
Perform work as a particularSubject
.static java.lang.Object
doAsPrivileged(javax.security.auth.Subject subject, java.security.PrivilegedExceptionAction action, java.security.AccessControlContext acc)
Perform work as a particularSubject
.static void
whoaminow()
-
-
-
Method Detail
-
doAs
public static java.lang.Object doAs(javax.security.auth.Subject subject, java.security.PrivilegedAction action)
Perform work as a particularSubject
. This method implementation is identical to the correspondingSubject.doAs
method implementation but with one major addition:This method instantiates the default or specified
ThreadSubject
which invokes pthread_security_np for the existing thread to set the identity of the thread prior to executing thePrivilegedAction
. After thePrivilegedAction
execution completes, pthread_security_np is again invoked to restore the environment to that of the original thread identity.- Parameters:
subject
- theSubject
that the specifiedaction
will run as.action
- the code to be run as the specifiedSubject
.- Returns:
- the
Object
returned by the PrivilegedAction's execution. - Throws:
java.lang.NullPointerException
- if thePrivilegedAction
isnull
.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 theThreadSubject
implementation fails or is not supported, or if there is no OS/390 public principal for theSubject
.
-
doAs
public static java.lang.Object doAs(javax.security.auth.Subject subject, java.security.PrivilegedExceptionAction action) throws java.security.PrivilegedActionException
Perform work as a particularSubject
. This method implementation is identical to the correspondingSubject.doAs
method implementation but with one major addition:This method instantiates the default or specified
ThreadSubject
and invokes pthread_security_np for the existing thread to set the identity of the thread prior to executing thePrivilegedExceptionAction
. After thePrivilegedExceptionAction
execution completes, pthread_security_np is again invoked to restore the environment to that of the original thread identity.- Parameters:
subject
- theSubject
that the specifiedaction
will run as.action
- the code to be run as the specifiedSubject
.- Returns:
- the
Object
returned by the PrivilegedAction's execution. - Throws:
java.lang.NullPointerException
- if thePrivilegedAction
isnull
.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 theThreadSubject
implementation 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(javax.security.auth.Subject subject, java.security.PrivilegedAction action, java.security.AccessControlContext acc)
Perform work as a particularSubject
. This method implementation is identical to the correspondingSubject.doAsPrivileged
method implementation but with one major addition:This method instantiates the default or specified
ThreadSubject
then invokes pthread_security_np for the existing thread to set the identity of the thread prior prior to executing thePrivilegedAction
. After thePrivilegedAction
execution completes, pthread_security_np is again invoked to restore the environment to that of the original thread identity.- Parameters:
subject
- theSubject
that the specifiedaction
will run as.action
- the code to be run as the specifiedSubject
.- Returns:
- the
Object
returned by the PrivilegedAction's execution. - Throws:
java.lang.NullPointerException
- if thePrivilegedAction
isnull
.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 theThreadSubject
implementation fails or is not supported, or if there is no OS/390 public principal for theSubject
.
-
doAsPrivileged
public static java.lang.Object doAsPrivileged(javax.security.auth.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.doAsPrivileged
method implementation but with one major addition:This method instantiates the default or specified
ThreadSubject
then invokes pthread_security_np for the existing thread to set the identity of the thread prior to executing thePrivilegedExceptionAction
. After thePrivilegedExceptionAction
execution completes, pthread_security_np is again invoked to restore the environment to that of the original thread identity.- Parameters:
subject
- theSubject
that the specifiedaction
will run as.action
- the code to be run as the specifiedSubject
.- Returns:
- the
Object
returned by the PrivilegedAction's execution. - Throws:
java.lang.NullPointerException
- if thePrivilegedAction
isnull
.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 theThreadSubject
implementation fails or is not supported, or if there is no OS/390 public principal for theSubject
.java.security.PrivilegedActionException
-
whoaminow
public static void whoaminow()
-
-