Class 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
    • 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
        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 set
        obj -
      • 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