Class SecurityContextAssociation


  • public class SecurityContextAssociation
    extends Object
    Security Context association in a threadlocal
    Since:
    Dec 27, 2006
    Version:
    $Revision$
    Author:
    Anil Saldhana
    • 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
    • Constructor Detail

      • SecurityContextAssociation

        public SecurityContextAssociation()
    • 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's checkPermission method with a RuntimePermission("org.jboss.security.accessContextInfo", "get") permission to ensure it's ok to access context information. If not, a SecurityException 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's checkPermission method with a RuntimePermission("org.jboss.security.accessContextInfo", "set") permission to ensure it's ok to access context information. If not, a SecurityException will be thrown.
        Parameters:
        key - - the context key
        value - - 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)