Package org.jboss.security
Class SecurityContextAssociation
- java.lang.Object
-
- org.jboss.security.SecurityContextAssociation
-
public class SecurityContextAssociation extends Object
Security Context association in a threadlocal- Since:
- Dec 27, 2006
- Version:
- $Revision$
- Author:
- Anil Saldhana
-
-
Field Summary
Fields Modifier and Type Field Description static StringSECURITYCONTEXT_THREADLOCALFlag to indicate whether threads that are spawned inherit the security context from parent Set this to false if you do not want inheritance.
-
Constructor Summary
Constructors Constructor Description SecurityContextAssociation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclearSecurityContext()Clear the current security contextstatic ObjectgetContextInfo(String key)Get the current thread context info.static ObjectgetCredential()static PrincipalgetPrincipal()static SecurityContextgetSecurityContext()Get a security contextstatic SubjectgetSubject()static booleanisClient()Indicates whether we are on the client sidestatic RunAspeekRunAsIdentity()Look at the current thread of control's run-as identitystatic RunAspopRunAsIdentity()Pops a RunAs identitystatic voidpushRunAsIdentity(RunAs runAs)Pushes a RunAs identitystatic voidsetClient()Set the VM-wide client side usagestatic ObjectsetContextInfo(String key, Object value)Set the current thread context info.static voidsetCredential(Object credential)static voidsetPrincipal(Principal principal)static voidsetSecurityContext(SecurityContext sc)Set a security context
-
-
-
Field Detail
-
SECURITYCONTEXT_THREADLOCAL
public static final String SECURITYCONTEXT_THREADLOCAL
Flag to indicate whether threads that are spawned inherit the security context from parent Set this to false if you do not want inheritance. By default the context is inherited.- See Also:
- Constant Field Values
-
-
Method Detail
-
isClient
public static boolean isClient()
Indicates whether we are on the client side- Returns:
-
setClient
public static void setClient()
Set the VM-wide client side usage
-
setSecurityContext
public static void setSecurityContext(SecurityContext sc)
Set a security context- Parameters:
sc-
-
getSecurityContext
public static SecurityContext getSecurityContext()
Get a security context- Returns:
-
clearSecurityContext
public static void clearSecurityContext()
Clear the current security context
-
pushRunAsIdentity
public static void pushRunAsIdentity(RunAs runAs)
Pushes a RunAs identity- Parameters:
runAs-
-
popRunAsIdentity
public static RunAs popRunAsIdentity()
Pops a RunAs identity- Returns:
-
peekRunAsIdentity
public static RunAs peekRunAsIdentity()
Look at the current thread of control's run-as identity
-
getContextInfo
public static Object getContextInfo(String key)
Get the current thread context info. If a security manager is present, then this method calls the security manager'scheckPermissionmethod with aRuntimePermission("org.jboss.security.accessContextInfo", "get")permission to ensure it's ok to access context information. If not, aSecurityExceptionwill be thrown.- Parameters:
key- - the context key- Returns:
- the mapping for the key in the current thread context
-
setContextInfo
public static Object setContextInfo(String key, Object value)
Set the current thread context info. If a security manager is present, then this method calls the security manager'scheckPermissionmethod with aRuntimePermission("org.jboss.security.accessContextInfo", "set")permission to ensure it's ok to access context information. If not, aSecurityExceptionwill be thrown.- Parameters:
key- - the context keyvalue- - the context value to associate under key- Returns:
- the previous mapping for the key if one exists
-
getSubject
public static Subject getSubject()
-
getPrincipal
public static Principal getPrincipal()
-
setPrincipal
public static void setPrincipal(Principal principal)
-
getCredential
public static Object getCredential()
-
setCredential
public static void setCredential(Object credential)
-
-