org.objectweb.security.context
Class SecurityContext

java.lang.Object
  extended by org.objectweb.security.context.SecurityContext
All Implemented Interfaces:
java.io.Serializable

public class SecurityContext
extends java.lang.Object
implements java.io.Serializable

Implementation of the JOnAS Security Context CAUTION: Don't forget to modify the Marshalling class of this package used for IIOP protocol

Author:
Jeff Mesnil (initial developer), Florent Benoit
See Also:
Serialized Form

Constructor Summary
  SecurityContext()
          Constructor SecurityContext use the default principal name
  SecurityContext(java.lang.String principalName)
          Constructor SecurityContext
  SecurityContext(java.lang.String principalName, java.util.List arrayRoles)
          Constructor SecurityContext
protected SecurityContext(java.lang.String principalName, java.util.List arrayRoles, java.util.List arrayRunas, java.util.List arrayRunasPrincipal, java.util.List arrayRunasPrincipalRoles)
          Constructor SecurityContext
  SecurityContext(java.lang.String principalName, java.lang.String[] roles)
          Constructor SecurityContext
 
Method Summary
 java.security.Principal getCallerPrincipal(boolean inRunAs)
          Method getCallerPrincipal
 java.lang.String[] getCallerPrincipalRoles(boolean inRunAs)
          Return the roles of the principal
 java.lang.String getPrincipalName()
           
protected  java.lang.String getPrincipalName(boolean runningRunAs)
           
 java.lang.String[] getRoles()
           
 java.util.List getRunAsPrincipalRolesStack()
          Gets the stack which manages the roles of the current run-as principal
 java.util.List getRunAsPrincipalStack()
          Gets the stack which manages the run-as principal
 java.util.List getRunAsRoleStack()
          Gets the stack which manages the run-as
 byte[] getSignature()
          Gets the signature.
 java.lang.String peekLastRunAsPrincipal()
          Peek : Looks at the object at the top of this stack without removing it from the stack.
 java.lang.String[] peekLastRunAsPrincipalRoles()
          Peek : Looks at the object at the top of this stack without removing it from the stack.
 java.lang.String peekRunAsPrincipal()
          Peek : Looks at the object at the top of this stack without removing it from the stack.
 java.lang.String[] peekRunAsPrincipalRoles()
          Peek : Looks at the object at the top of this stack without removing it from the stack.
 java.lang.String peekRunAsRole()
          Peek : Looks at the object at the top of this stack without removing it from the stack.
 void popRunAs()
          Pop : Removes the object at the top of the run-as stack
 void pushRunAs(java.lang.String role, java.lang.String principalName, java.lang.String[] roles)
          Push : Pushes run-as items at the top of this stack.
 void setSignature(byte[] signedData)
          Sets the signature.
 java.lang.String toString()
          Method toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SecurityContext

public SecurityContext()
Constructor SecurityContext use the default principal name


SecurityContext

public SecurityContext(java.lang.String principalName,
                       java.lang.String[] roles)
Constructor SecurityContext

Parameters:
principalName - principal name
roles - the roles of the principal

SecurityContext

public SecurityContext(java.lang.String principalName,
                       java.util.List arrayRoles)
Constructor SecurityContext

Parameters:
principalName - principal name
arrayRoles - the list of the roles of the principal

SecurityContext

protected SecurityContext(java.lang.String principalName,
                          java.util.List arrayRoles,
                          java.util.List arrayRunas,
                          java.util.List arrayRunasPrincipal,
                          java.util.List arrayRunasPrincipalRoles)
Constructor SecurityContext

Parameters:
principalName - principal name
arrayRoles - the list of the roles of the principal
arrayRunas - the RunAs stack
arrayRunasPrincipal - the RunAs stack for principal of runAs
arrayRunasPrincipalRoles - the RunAs stack for roles of the principal

SecurityContext

public SecurityContext(java.lang.String principalName)
Constructor SecurityContext

Parameters:
principalName - principal name
Method Detail

getCallerPrincipal

public java.security.Principal getCallerPrincipal(boolean inRunAs)
Method getCallerPrincipal

Parameters:
inRunAs - is the caller is in a runAs case in RunAs mode this function must return the caller of the bean and not the run as identity (EJB 2.1 chapter21.2.5.1)
Returns:
the Principal in the Security Context

getSignature

public byte[] getSignature()
Gets the signature.

Returns:
signature

setSignature

public void setSignature(byte[] signedData)
Sets the signature.

Parameters:
signedData - the given data of the signature.

getCallerPrincipalRoles

public java.lang.String[] getCallerPrincipalRoles(boolean inRunAs)
Return the roles of the principal

Parameters:
inRunAs - caller is in run-as bean ?
Returns:
roles of this principal

pushRunAs

public void pushRunAs(java.lang.String role,
                      java.lang.String principalName,
                      java.lang.String[] roles)
Push : Pushes run-as items at the top of this stack.

Parameters:
role - the role to add on top of the stack
principalName - the name of the principal to add on top of the stack.
roles - list of roles of this principal.

popRunAs

public void popRunAs()
Pop : Removes the object at the top of the run-as stack


peekRunAsRole

public java.lang.String peekRunAsRole()
Peek : Looks at the object at the top of this stack without removing it from the stack.

Returns:
the role at the top of the stack

peekRunAsPrincipal

public java.lang.String peekRunAsPrincipal()
Peek : Looks at the object at the top of this stack without removing it from the stack.

Returns:
the principal at the top of the stack

peekLastRunAsPrincipal

public java.lang.String peekLastRunAsPrincipal()
Peek : Looks at the object at the top of this stack without removing it from the stack.

Returns:
the principal at the top of the stack

peekRunAsPrincipalRoles

public java.lang.String[] peekRunAsPrincipalRoles()
Peek : Looks at the object at the top of this stack without removing it from the stack.

Returns:
the principal at the top of the stack

peekLastRunAsPrincipalRoles

public java.lang.String[] peekLastRunAsPrincipalRoles()
Peek : Looks at the object at the top of this stack without removing it from the stack.

Returns:
the principal at the top of the stack

getRunAsRoleStack

public java.util.List getRunAsRoleStack()
Gets the stack which manages the run-as

Returns:
the stack which manages the run-as

getRunAsPrincipalRolesStack

public java.util.List getRunAsPrincipalRolesStack()
Gets the stack which manages the roles of the current run-as principal

Returns:
the stack which manages the roles of the current run-as principal

getRunAsPrincipalStack

public java.util.List getRunAsPrincipalStack()
Gets the stack which manages the run-as principal

Returns:
the stack which manages the run-as principal

toString

public java.lang.String toString()
Method toString

Overrides:
toString in class java.lang.Object
Returns:
String a string representation of the object

getPrincipalName

protected java.lang.String getPrincipalName(boolean runningRunAs)
Parameters:
runningRunAs - bean is currently running with run-as enabled
Returns:
the principal name.

getPrincipalName

public java.lang.String getPrincipalName()
Returns:
the principal Name.

getRoles

public java.lang.String[] getRoles()
Returns:
the roles.