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 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.
-
Constructor Summary
Constructors Constructor Description SecurityContextAssociation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clearSecurityContext()
Clear the current security contextstatic Object
getContextInfo(String key)
Get the current thread context info.static Object
getCredential()
static Principal
getPrincipal()
static SecurityContext
getSecurityContext()
Get a security contextstatic Subject
getSubject()
static boolean
isClient()
Indicates whether we are on the client sidestatic RunAs
peekRunAsIdentity()
Look at the current thread of control's run-as identitystatic RunAs
popRunAsIdentity()
Pops a RunAs identitystatic void
pushRunAsIdentity(RunAs runAs)
Pushes a RunAs identitystatic void
setClient()
Set the VM-wide client side usagestatic Object
setContextInfo(String key, Object value)
Set the current thread context info.static void
setCredential(Object credential)
static void
setPrincipal(Principal principal)
static void
setSecurityContext(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'scheckPermission
method with aRuntimePermission("org.jboss.security.accessContextInfo", "get")
permission to ensure it's ok to access context information. If not, aSecurityException
will 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'scheckPermission
method with aRuntimePermission("org.jboss.security.accessContextInfo", "set")
permission to ensure it's ok to access context information. If not, aSecurityException
will 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)
-
-