org.jboss.security
Class SecurityContextUtil

java.lang.Object
  extended by org.jboss.security.SecurityContextUtil

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
protected  SecurityContext securityContext
           
 
Constructor Summary
SecurityContextUtil()
           
 
Method Summary
 void addIdentity(Identity id)
          Add an Identity to the Security Context
 void clearIdentities(Class<?> clazz)
          Clear Identities of a particular type
 void createSubjectInfo(Identity identity, Subject theSubject)
          Create a SubjectInfo
 void createSubjectInfo(Principal principal, Object credential, Subject subject)
          Create SubjectInfo and set it in the current security context
abstract
<T> T
get(String key)
          Return an object from the Security Context
abstract  Object getCredential()
          Get the credential
 Set<Identity> getIdentities(Class<?> clazz)
          Get a set of identities of a particular type
abstract  RoleGroup getRoles()
          Get the Roles associated with the user for the current security context
abstract  SecurityIdentity getSecurityIdentity()
          Get a holder of subject, runAs and caller RunAs
abstract  Subject getSubject()
          Get the subject the security context
abstract  String getUserName()
          Get the username from the security context
abstract  Principal getUserPrincipal()
          Get the user principal the security context
abstract
<T> T
remove(String key)
          Remove an object represented by the key from the security context
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)
 void setIdentities(Set<Identity> idSet)
          Set the Identities into the Security Context
abstract  void setRoles(RoleGroup roles)
          Set the roles for the user for the current security context
 void 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

securityContext

protected SecurityContext securityContext
Constructor Detail

SecurityContextUtil

public SecurityContextUtil()
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

Type Parameters:
T -
Returns:

setRoles

public abstract void setRoles(RoleGroup roles)
Set the roles for the user for the current security context

Type Parameters:
T -
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:
sc - Security Context Object
key - Key representing the object being set
obj -

get

public abstract <T> T get(String key)
Return an object from the Security Context

Type Parameters:
T -
Parameters:
sc - Security Context Object
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:
sc - Security Context Object
key - key identifies the type of object we are requesting
Returns:
the removed object


Copyright © 2009 JBoss Inc.. All Rights Reserved.