psdi.util

Class MXSession

  • java.lang.Object
    • psdi.util.MXSession
  • Direct Known Subclasses:
    RMISession


    public abstract class MXSession
    extends java.lang.Object
    Coordinates a number of items that occur during an active session with the user. Looks after connect and disconnect from a MBO Server. Holds connection to a MBO Server. Maintains user and password information.
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected MXSession()
      Protected so cannot be called.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      void addMXSessionListener(MXSessionListener l)
      Register to get MXSession events from this object.
      abstract void connect()
      Connects to the server using the approprate protocol.
      void connectAsRegUser(java.lang.String forUser)
      Connect to server as the user for self-registration.
      abstract void disconnect()
      Disconnects from the server.
      java.lang.String getBaseCurrency()
      returns the base Currency.
      abstract int getBranding() 
      java.lang.String getClientAddr()
      Returns the client address.
      java.lang.String getClientHost()
      Returns the client host.
      java.lang.Object getCredential()
      Get the authentication credential.
      java.util.Date getDate()
      Gets the current date from the server.
      java.lang.String getForUser()
      Get the tenant code set to the session.
      java.lang.String getHost()
      Returns the current hostname.
      abstract java.lang.String[][] getLanguageList()
      Returns the language ID and name in corresponding language
      java.util.Locale getLocale()
      Returns the locale of the current user.
      abstract MboSetRemote getMboSet(java.lang.String name)
      Returns an empty MboSetRemote for the specified type of business object.
      abstract java.lang.String getMessage(MXException mxe)
      Returns message for the exception
      abstract java.lang.String getMessage(java.lang.String group, java.lang.String key)
      Returns the message for group and key for the mxsession langcode
      abstract java.lang.String[] getMessages(java.lang.String group, java.lang.String[] key)
      Return list of translated strings from the maxmessages table in the order specified by the array of keys passed for the mxsession langcode
      abstract MXServerRemote getMXServerRemote()
      Return the MXServer remote interface.
      static MXSession getNewSession()
      Creates a new session and returns it.
      byte[] getPassword(byte[] param)
      Returns the password of the current user.
      abstract ProfileRemote getProfile()
      Return the user's security profile.
      abstract java.lang.String getProperty(java.lang.String propName)
      Returns value of a non-secure property.
      java.lang.String getServer()
      Returns the current MXServer name.
      static MXSession getSession()
      Returns a reference to the session object.
      abstract java.lang.String getTaggedMessage(MXException mxe)
      Returns message with MessageID tagged for the exception
      java.lang.String getTenant()
      Get the tenant code set to the session.
      java.util.TimeZone getTimeZone()
      Returns the time zone for this user.
      java.lang.String getURLAsString()
      Return the URL of the host and server name as a string
      UserInfo getUserInfo()
      Returns the userinfo object.
      java.lang.String getUserName()
      Returns the current Login ID (not the userid).
      boolean hasAdminLogout()
      Sets the adminLogout flag to true if the session is marked for adminlogout in maxsession.
      boolean isConnected()
      Specifies whether the session is currently connected to a server.
      abstract ServiceRemote lookup(java.lang.String name)
      Returns the specified remote service.
      void removeMXSessionListener(MXSessionListener l)
      Unregister a listener for events
      void setClientAddr(java.lang.String cAddr)
      Set the client address (servlet request's getRemoteAddr).
      void setClientHost(java.lang.String cHost)
      Set the client host (servlet request's getRemoteHost).
      void setCredential(java.lang.Object cert)
      Set the credential to authenticate the user.
      void setForUser(java.lang.String username)
      Set the tenant code to the session.
      void setHost(java.lang.String url)
      Specifies the URL of the MboServer to connect to.
      void setInteractive(boolean value)
      Set the interactive flag.
      void setLangCode(java.lang.String lang) 
      void setLocale(java.util.Locale l)
      Sets the user's locale.
      static void setMXSessionImplFactory(MXSessionImplFactory factory)
      Set the session factory.
      void setPassword(java.lang.String pwd)
      Sets the password for the current user.
      void setTenant(java.lang.String code)
      Set the tenant code to the session.
      void setTimeZone(java.util.TimeZone tz)
      Sets the time zone for this user.
      void setUserName(java.lang.String user)
      Sets the Login ID (this variable) to the specified String.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • locale

        protected java.util.Locale locale
      • timeZone

        protected java.util.TimeZone timeZone
      • baseCurrency

        protected java.lang.String baseCurrency
      • username

        protected java.lang.String username
        This corresponds to the maxuser.loginid
      • password

        protected java.lang.String password
      • langCode

        protected java.lang.String langCode
      • hostname

        protected java.lang.String hostname
      • servername

        protected java.lang.String servername
      • connected

        protected boolean connected
      • clientHost

        protected java.lang.String clientHost
      • clientAddr

        protected java.lang.String clientAddr
      • interactive

        protected boolean interactive
      • adminLogout

        protected boolean adminLogout
      • credential

        protected java.lang.Object credential
    • Constructor Detail

      • MXSession

        protected MXSession()
        Protected so cannot be called. Call getSession() in order to get reference.
    • Method Detail

      • getSession

        public static MXSession getSession()
        Returns a reference to the session object. The MXSession class has a private constructor and so cannot be instantiated directly. To create an MXSession object, this static method is provided. To create the session, do the following:
              MXSession s = MXSession.getSession();
         

        Once a session has been instantiated, a connection to the server can be established using the methods setHost, setUserName, setPassword, and connect.

        Generally, there is only one MXSession object per JVM, so it is necessary to connect to the server only once. After a connection has been made, the previously connected MXSession object can be retrieved as follows:

              s = MXSession.getSession();
         
        Returns:
        A reference to an instance of MXSession.
        See Also:
        MXSession.setHost(String), MXSession.setUserName(String), MXSession.setPassword(String), MXSession.connect()
      • getNewSession

        public static MXSession getNewSession()
        Creates a new session and returns it.
        Returns:
        a new session
      • setMXSessionImplFactory

        public static void setMXSessionImplFactory(MXSessionImplFactory factory)
        Set the session factory. Defaults to RMISession
      • getPassword

        public byte[] getPassword(byte[] param)
        Returns the password of the current user.
        Parameters:
        param -
        Returns:
        The encrypted password of this user.
      • getBaseCurrency

        public java.lang.String getBaseCurrency()
        returns the base Currency.
      • setLangCode

        public void setLangCode(java.lang.String lang)
        Parameters:
        Set - the maximo language code.
        lang -
      • setPassword

        public void setPassword(java.lang.String pwd)
        Sets the password for the current user.
        Parameters:
        pwd - The new password.
        See Also:
        #getPassword()
      • setTenant

        public void setTenant(java.lang.String code)
        Set the tenant code to the session. It will be used when connecting to the server.
        Parameters:
        code -
      • getTenant

        public java.lang.String getTenant()
        Get the tenant code set to the session. This is the tenant code passed to the session through url or the tenant code field on login page. If not provided, this method will return null. This is not the tenant code that can be obtained by authorization using username/password.
        Parameters:
        code -
        Returns:
      • setForUser

        public void setForUser(java.lang.String username)
        Set the tenant code to the session. It will be used when connecting to the server.
        Parameters:
        code -
      • getForUser

        public java.lang.String getForUser()
        Get the tenant code set to the session. This is the tenant code passed to the session through url or the tenant code field on login page. If not provided, this method will return null. This is not the tenant code that can be obtained by authorization using username/password.
        Parameters:
        code -
        Returns:
      • getUserInfo

        public UserInfo getUserInfo()
        Returns the userinfo object.
      • setHost

        public void setHost(java.lang.String url)
        Specifies the URL of the MboServer to connect to.
        Parameters:
        url - The URL of the MboServer, in the form hostname/servername.
        • If no servername is specified, the default is used ("MXServer").
        • Url "myHost/myServer" indicates host = "myHost", server = "myServer".
        • Url "/myServer" indicates host = "", server = "myServer".
        • Url "myHost/" indicates host = "myHost", server = "MXServer" (the default).
        See Also:
        MXSession.getHost()
      • getHost

        public java.lang.String getHost()
        Returns the current hostname.
        Returns:
        The hostname, as String. This may return null.
        See Also:
        MXSession.setHost(String)
      • setClientHost

        public void setClientHost(java.lang.String cHost)
        Set the client host (servlet request's getRemoteHost).
        Parameters:
        cHost - The client host
      • getClientHost

        public java.lang.String getClientHost()
        Returns the client host.
      • setClientAddr

        public void setClientAddr(java.lang.String cAddr)
        Set the client address (servlet request's getRemoteAddr).
        Parameters:
        cHost - The client address
      • getClientAddr

        public java.lang.String getClientAddr()
        Returns the client address.
      • getServer

        public java.lang.String getServer()
        Returns the current MXServer name.
      • getLocale

        public java.util.Locale getLocale()
        Returns the locale of the current user. The locale is initialized to the default locale from the user's desktop (java.util.Locale.getDefault()), and can be overridden by setLocale().
        Returns:
        Locale, as java.util.Locale.
        See Also:
        Locale, MXSession.setLocale(Locale)
      • setLocale

        public void setLocale(java.util.Locale l)
        Sets the user's locale. Need to call only if the programmer wishes to have a different locale than the initialized value from the user's desktop (java.util.Locale.getDefault()).
        Parameters:
        l - The Locale to be set for this user.
        See Also:
        Locale, MXSession.getLocale()
      • setTimeZone

        public void setTimeZone(java.util.TimeZone tz)
        Sets the time zone for this user. The time zone is initialized to java.util.TimeZone.getDefault(), so setTimeZone() would be called only if something other than the initialized value is desired.
        Parameters:
        tz - The Time Zone to be set.
        See Also:
        TimeZone, MXSession.getTimeZone()
      • getTimeZone

        public java.util.TimeZone getTimeZone()
        Returns the time zone for this user. The time zone is initialized to java.util.TimeZone.getDefault(), and can be overridden by setTimeZone().
        Returns:
        The TimeZone, as java.util.TimeZone.
        See Also:
        TimeZone, MXSession.setTimeZone(TimeZone)
      • getURLAsString

        public java.lang.String getURLAsString()
        Return the URL of the host and server name as a string
      • addMXSessionListener

        public void addMXSessionListener(MXSessionListener l)
        Register to get MXSession events from this object.
      • removeMXSessionListener

        public void removeMXSessionListener(MXSessionListener l)
        Unregister a listener for events
      • getDate

        public java.util.Date getDate()
        Gets the current date from the server. This allows for consistent returning of the system date from one source, removing differences in clock settings. The date is time zone neutral and can be converted using the standard conversion rounties in MXFormat.
        Returns:
        The current date from the server (java.util.Date()).
        See Also:
        Date, MXFormat
      • isConnected

        public boolean isConnected()
        Specifies whether the session is currently connected to a server.
        Returns:
        boolean: True if this is connected to a server, else False.
        See Also:
        MXSession.connect(), MXSession.disconnect()
      • setInteractive

        public void setInteractive(boolean value)
        Set the interactive flag.
        Parameters:
        value -
      • getMboSet

        public abstract MboSetRemote getMboSet(java.lang.String name)
                                        throws MXException
        Returns an empty MboSetRemote for the specified type of business object. Once the set has been retrieved, the Where clause can be set via setWhere(String) and the collection assembled via reset().

        The following example retrieves a work order set:

              MXSession s = MXSession.getSession();
              MboSetRemote woSet = s.getMboSet("WORKORDER");
         
        Parameters:
        name - The name of the type of set desired, such as WORKORDER, EQUIPMENT, etc.
        Returns:
        An empty set of the desired type.
        Throws:
        MXException
        See Also:
        MXSession.getSession(), MboSet.setWhere(String)
      • getProfile

        public abstract ProfileRemote getProfile()
                                          throws MXException,
                                                 java.rmi.RemoteException
        Return the user's security profile.
        Throws:
        MXException
        java.rmi.RemoteException
      • lookup

        public abstract ServiceRemote lookup(java.lang.String name)
                                      throws java.rmi.RemoteException,
                                             MXException
        Returns the specified remote service. Throws an exception if the service is not found.
        Parameters:
        name - The name of the desired service.
        Returns:
        The service as ServiceRemote (psdi.server.ServiceRemote).
        Throws:
        java.rmi.RemoteException
        MXException
        See Also:
        ServiceRemote
      • getLanguageList

        public abstract java.lang.String[][] getLanguageList()
                                                      throws MXException,
                                                             java.rmi.RemoteException
        Returns the language ID and name in corresponding language
        Returns:
        two dimensional string array of languageid and languagename
        Throws:
        MXException
        java.rmi.RemoteException
      • getMessage

        public abstract java.lang.String getMessage(java.lang.String group,
                                                    java.lang.String key)
                                             throws MXException,
                                                    java.rmi.RemoteException
        Returns the message for group and key for the mxsession langcode
        Parameters:
        group -
        key -
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getMessages

        public abstract java.lang.String[] getMessages(java.lang.String group,
                                                       java.lang.String[] key)
                                                throws MXException,
                                                       java.rmi.RemoteException
        Return list of translated strings from the maxmessages table in the order specified by the array of keys passed for the mxsession langcode
        Parameters:
        group -
        key -
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getMessage

        public abstract java.lang.String getMessage(MXException mxe)
                                             throws MXException,
                                                    java.rmi.RemoteException
        Returns message for the exception
        Parameters:
        mxe -
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getTaggedMessage

        public abstract java.lang.String getTaggedMessage(MXException mxe)
                                                   throws MXException,
                                                          java.rmi.RemoteException
        Returns message with MessageID tagged for the exception
        Parameters:
        mxe -
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getProperty

        public abstract java.lang.String getProperty(java.lang.String propName)
                                              throws MXException,
                                                     java.rmi.RemoteException
        Returns value of a non-secure property. If the property is secure or is undefined, null is returned. If the property is non-secure and has no value, the empty string is returned.
        Parameters:
        propName - Property name
        Returns:
        Property value
        Throws:
        MXException
        java.rmi.RemoteException
      • connectAsRegUser

        public void connectAsRegUser(java.lang.String forUser)
                              throws MXException,
                                     java.rmi.RemoteException
        Connect to server as the user for self-registration. This method will only work if it is called from the same jvm as the mxserver. Before this method is called, the language code should be set.
        Throws:
        MXException
        java.rmi.RemoteException
      • setCredential

        public void setCredential(java.lang.Object cert)
        Set the credential to authenticate the user. The credential can be either X509 certificate or distinguished name. What is passed in has to be consistent to the oracle authentication mode specified in the maximo property.
        Parameters:
        cert -
      • getCredential

        public java.lang.Object getCredential()
        Get the authentication credential. The return can either be a x509 certificate object or a string of distinguished name. If not set, it returns null.
        Returns:
      • hasAdminLogout

        public boolean hasAdminLogout()
                               throws MXException,
                                      java.rmi.RemoteException
        Sets the adminLogout flag to true if the session is marked for adminlogout in maxsession. Returns the value of adminLogout.
        Returns:
        boolean was the session logged out by the admin?
        Throws:
        MXException
        java.rmi.RemoteException