Package org.jboss.security
Class SecurityContextUtil
- java.lang.Object
-
- org.jboss.security.SecurityContextUtil
-
- Direct Known Subclasses:
JBossSecurityContextUtil
public abstract class SecurityContextUtil extends Object
General Utility methods for dealing with the SecurityContext- Since:
- Jan 5, 2007
- Version:
- $Revision$
- Author:
- Anil Saldhana
-
-
Field Summary
Fields Modifier and Type Field Description protected SecurityContext
securityContext
-
Constructor Summary
Constructors Constructor Description SecurityContextUtil()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addIdentity(Identity id)
Add an Identity to the Security Contextvoid
clearIdentities(Class<?> clazz)
Clear Identities of a particular typevoid
createSubjectInfo(Principal principal, Object credential, Subject subject)
Create SubjectInfo and set it in the current security contextvoid
createSubjectInfo(Identity identity, Subject theSubject)
Create a SubjectInfoabstract <T> T
get(String key)
Return an object from the Security Contextabstract Object
getCredential()
Get the credentialSet<Identity>
getIdentities(Class<?> clazz)
Get a set of identities of a particular typeabstract RoleGroup
getRoles()
Get the Roles associated with the user for the current security contextabstract SecurityIdentity
getSecurityIdentity()
Get a holder of subject, runAs and caller RunAsabstract Subject
getSubject()
Get the subject the security contextabstract String
getUserName()
Get the username from the security contextabstract Principal
getUserPrincipal()
Get the user principal the security contextabstract <T> T
remove(String key)
Remove an object represented by the key from the security contextabstract <T> void
set(String key, T obj)
Set an object on the Security Context The context implementation may place the object in its internal data structures (like the Data Map)void
setIdentities(Set<Identity> idSet)
Set the Identities into the Security Contextabstract void
setRoles(RoleGroup roles)
Set the roles for the user for the current security contextvoid
setSecurityContext(SecurityContext sc)
abstract void
setSecurityIdentity(SecurityIdentity si)
Inject subject, runAs and callerRunAs into the security context Mainly used by integration code base to cache the security identity and put back to the security context
-
-
-
Field Detail
-
securityContext
protected SecurityContext securityContext
-
-
Method Detail
-
setSecurityContext
public void setSecurityContext(SecurityContext sc)
-
getUserName
public abstract String getUserName()
Get the username from the security context- Returns:
- username
-
getUserPrincipal
public abstract Principal getUserPrincipal()
Get the user principal the security context- Returns:
- user principal
-
getCredential
public abstract Object getCredential()
Get the credential- Returns:
-
getSubject
public abstract Subject getSubject()
Get the subject the security context- Returns:
-
getSecurityIdentity
public abstract SecurityIdentity getSecurityIdentity()
Get a holder of subject, runAs and caller RunAs- Returns:
-
setSecurityIdentity
public abstract void setSecurityIdentity(SecurityIdentity si)
Inject subject, runAs and callerRunAs into the security context Mainly used by integration code base to cache the security identity and put back to the security context- Parameters:
si
- The SecurityIdentity Object
-
getRoles
public abstract RoleGroup getRoles()
Get the Roles associated with the user for the current security context- Returns:
-
setRoles
public abstract void setRoles(RoleGroup roles)
Set the roles for the user for the current security context- Parameters:
roles
-
-
createSubjectInfo
public void createSubjectInfo(Principal principal, Object credential, Subject subject)
Create SubjectInfo and set it in the current security context- Parameters:
principal
-credential
-subject
-
-
createSubjectInfo
public void createSubjectInfo(Identity identity, Subject theSubject)
Create a SubjectInfo- Parameters:
identity
-theSubject
- The AuthenticatedSubject(can be null)
-
addIdentity
public void addIdentity(Identity id)
Add an Identity to the Security Context- Parameters:
id
-
-
clearIdentities
public void clearIdentities(Class<?> clazz)
Clear Identities of a particular type- Parameters:
clazz
-
-
getIdentities
public Set<Identity> getIdentities(Class<?> clazz)
Get a set of identities of a particular type- Parameters:
clazz
-- Returns:
-
setIdentities
public void setIdentities(Set<Identity> idSet)
Set the Identities into the Security Context- Parameters:
idSet
-
-
set
public abstract <T> void set(String key, T obj)
Set an object on the Security Context The context implementation may place the object in its internal data structures (like the Data Map)- Type Parameters:
T
- Generic Type- Parameters:
key
- Key representing the object being setobj
-
-
get
public abstract <T> T get(String key)
Return an object from the Security Context- Type Parameters:
T
-- Parameters:
key
- key identifies the type of object we are requesting- Returns:
-
remove
public abstract <T> T remove(String key)
Remove an object represented by the key from the security context- Type Parameters:
T
-- Parameters:
key
- key identifies the type of object we are requesting- Returns:
- the removed object
-
-