com.ibm.jarm.api.util

Class RMUserContext

  • java.lang.Object
    • com.ibm.jarm.api.util.RMUserContext


  • public class RMUserContext
    extends java.lang.Object
    This class manages per-thread user locale and authentication information.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static javax.security.auth.Subject createSubject(DomainConnection conn, java.lang.String username, java.lang.String password, java.lang.String stanzaName)
      Performs standard JAAS authentication and returns a JAAS javax.security.auth.Subject instance.
      static RMUserContext get()
      Returns the RMUserContext instance that is associated with the current thread.
      java.util.Locale getLocale()
      Returns the Locale associated with this user context.
      static java.lang.String getPrincipals(javax.security.auth.Subject subject)
      Returns a string containing a list of java.security.Principal instances for the given javax.security.auth.Subject instance.
      javax.security.auth.Subject getSubject() 
      static void set(RMUserContext uc)
      Associates the specified RMUserContext instance with the current thread.
      void setLocale(java.util.Locale locale)
      Sets the Locale for this user context.
      void setSubject(javax.security.auth.Subject subject)
      Associates a JAAS javax.security.auth.Subject instance on this user context for the current thread.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setLocale

        public void setLocale(java.util.Locale locale)
        Sets the Locale for this user context.
        Parameters:
        locale - the Locale instance to associate with this user context. This entry can be null, in which case the default Locale for the JVM is used.
      • getLocale

        public java.util.Locale getLocale()
        Returns the Locale associated with this user context. If no Locale has been previously set, then the default Locale for the JVM is returned.
        Returns:
        A Locale instance.
      • setSubject

        public void setSubject(javax.security.auth.Subject subject)
        Associates a JAAS javax.security.auth.Subject instance on this user context for the current thread. For a P8 Content Engine environment, the createSubject(DomainConnection, String, String, String) method can be used to create a javax.security.auth.Subject instance for use by this method.
        Parameters:
        subject - the javax.security.auth.Subject instance to associate with the current thread. This entry can be null to remove any previously established javax.security.auth.Subject.
      • getSubject

        public javax.security.auth.Subject getSubject()
        Returns:
        The JAAS javax.security.auth.Subject instance currently associated with this user context. This entry can be null.
      • createSubject

        public static javax.security.auth.Subject createSubject(DomainConnection conn,
                                                java.lang.String username,
                                                java.lang.String password,
                                                java.lang.String stanzaName)
        Performs standard JAAS authentication and returns a JAAS javax.security.auth.Subject instance. The client must be property configured for JAAS. The calling code can optionally provide a JAAS configuration stanza name or pass in a null value, in which case default stanza name is used based upon the Domain type (for example, for P8 Content Engine: "FileNetP8"). The returned javax.security.auth.Subject instance has no association with the current user context. It is up to the caller to either set this javax.security.auth.Subject instance on the RMUserContent instance, or use the JAAS Subject.doAs method.
        Parameters:
        conn - the DomainConnection to authenticate with.
        username - the username String to use for authentication.
        password - the password String to use for authentication.
        stanzaName - optional JAAS authentication stanza name String. This entry can be null, in which case a domain-type specific default value is used. P8_STANZA_EJB and P8_STANZA_WSI are provided as convenience constants for P8CE domain environments.
        Returns:
        A JAAS javax.security.auth.Subject instance.
      • get

        public static RMUserContext get()
        Returns the RMUserContext instance that is associated with the current thread. If no user context has been set on this thread, then a default instance is established based upon the JVM default Locale.
        Returns:
        The RMUserContext associated with the current thread.
      • set

        public static void set(RMUserContext uc)
        Associates the specified RMUserContext instance with the current thread. This method replaces any previous RMUserContext instance for the current thread.
        Parameters:
        uc - The RMUserContext instance to associate with the current thread. This entry can be null, in which case any existing RMUserContext instance on the current thread is replaced by the default instance.
      • getPrincipals

        public static java.lang.String getPrincipals(javax.security.auth.Subject subject)
        Returns a string containing a list of java.security.Principal instances for the given javax.security.auth.Subject instance. This entry is intended for tracing use only.
        Parameters:
        subject - The java.security.Principal in question.
        Returns:
        returns a semicolon delineated list of principals or an empty String if the subject is null or has no principals associated with it.

© Copyright IBM Corp. 2010, 2013. All Rights Reserved.