Class IXConnFactory

java.lang.Object
de.elo.ix.client.IXConnFactory
Direct Known Subclasses:
IXConnFactoryEventHandler

public class IXConnFactory
extends java.lang.Object

This class is used to create IXConnection objects that represent sessions to Indexserver. Use one of the create methods to instanciate an IXConnection object.

The connection to the Indexserver is internally hold by an IXClient object. Its initial parameters are supplied by a Properties collection given in the constructor of IXConnFactory. A reference to the IXClient object is passed to each IXConnection object created by one of the create functions.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.util.Properties connProps
    Connection properties.
    protected IXServicePortC CONST
    Constants
    protected java.util.concurrent.atomic.AtomicBoolean createNewIxClient
    Remember to create a new IXClient object for the next IXConnection object.
    static java.lang.String NB_OF_REVERSE_CNNS
    Number of reverse connections.
    static java.lang.String PROP_NB_OF_CNNS
    Property name for the number of connections to Indexserver used in the connection pool: "connection.nbOfCnns".
    static java.lang.String PROP_TEMP_DIR
    Property name for a temporary directory: "connection.tempDir".
    static java.lang.String PROP_TIMEOUT_SECONDS
    Property name for connection timeout: "connection.timeoutSeconds" in seconds.
    static java.lang.String PROP_URL
    Property name for Indexserver URL: "connection.url".
    protected java.util.Properties sessOpts
    Session options.
    protected java.util.concurrent.ExecutorService tpool
    Thread pool for HTTP requests.
  • Constructor Summary

    Constructors 
    Constructor Description
    IXConnFactory​(java.lang.String url, java.lang.String appName, java.lang.String appVersion)
    Constructor.
    IXConnFactory​(java.util.Properties props, java.util.Properties sessOpts)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    IXConnection create​(ClientInfo ciAdmin, java.lang.String runAs)
    Create a connection for the given Run-As-user for an existent ticket
    IXConnection create​(ClientInfo ci, java.lang.String userName, java.lang.String userPwd, java.lang.String computerName, java.lang.String runAs)
    Create aconnection for the given user.
    IXConnection create​(java.lang.String userName, java.lang.String userPwd, java.lang.String computerName, java.lang.String runAs)
    Create a connection for the given user.
    IXConnection createAdmin​(ClientInfo ci, java.lang.String userName, java.lang.String userPwd, java.lang.String computerName, java.lang.String reportAs)
    Create aconnection for the given user.
    IXConnection createAdmin​(java.lang.String userName, java.lang.String userPwd, java.lang.String computerName, java.lang.String reportAs)
    Create a connection for the given user.
    static java.util.Properties createConnProps​(java.lang.String url)
    Create a connection properties object.
    static java.util.Properties createConnProps​(java.lang.String url, int nbOfCnns, int timeoutSeconds)
    Create a connection properties object.
    protected IXConnection createForConstants()  
    IXConnection createFromCookie​(ClientInfo ci, java.net.HttpCookie sessionCookie)
    Create a connection from a httpSession cookie supplied in the connection properties of IXConnFactory.
    IXConnection createFromTicket​(ClientInfo ci)
    Create a connection from any valid AM ticket.
    IXConnection createFromTicketForRelogin​(java.util.function.Supplier<ClientInfo> clientInfoFnct)
    Create a connection from any valid AM ticket provided by a supplier function.
    IXConnection createKrb​(ClientInfo ci, java.lang.String realm, java.lang.String kdc, java.lang.String servicePrincipal, java.lang.String computerName)
    Create a session for the current Windows OS user via Kerberos authentication.
    IXConnection createOffline()
    RESERVED.
    static java.util.Properties createSessionOptions​(java.lang.String appName, java.lang.String appVersion)
    Creates a property collection that contains session options.
    IXConnection createSso​(ClientInfo ci, java.lang.String computerName)
    Create connection for the current user of the operating system.
    IXConnection createSso​(java.lang.String computerName)
    Create connection for the current user of the operating system.
    void done()  
    java.util.Properties getConnProperties()
    Get connection properties.
    IXServicePortC getCONST()
    Returns the constants object.
    int getMajorVersion()  
    java.util.Properties getSessionOptions()
    Get session options.
    java.lang.String getVersion()
    Get Indexserver version.
    protected void init()
    Initialize this object.
    protected void internalCreateConnection​(IXAuthentication auth, java.net.HttpCookie sessionCookie, byps.BAsyncResult<IXConnection> asyncResult)
    Create a connection with the given authentication object and optional HTTP session cookie.
    protected IXConnection internalCreateIXConnectionObject​(IXConnFactory connFact, de.elo.ix.client.BClient_Indexserver bclient, IXAuthentication auth, java.lang.String url, java.util.Properties connProps, java.util.Properties sessOpts)
    Create IXConnection object.
    ClientInfo makeDefaultClientInfo()
    Creates a ClientInfo object and assigns the language, country from the default values of the Java VM.
    static java.util.Properties readStatusPageProperties​(java.lang.String ixUrl)
    Helper function used retrieve all properties of the ix status page
    static java.lang.String readStatusPageProperty​(java.lang.String ixUrl, java.lang.String propertyName)
    Helper function used to read the Indexserver version numbers.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • PROP_URL

      public static final java.lang.String PROP_URL
      Property name for Indexserver URL: "connection.url". This value is required. Example: http://server:8080/ix-Archive/ix.
      See Also:
      Constant Field Values
    • PROP_NB_OF_CNNS

      public static final java.lang.String PROP_NB_OF_CNNS
      Property name for the number of connections to Indexserver used in the connection pool: "connection.nbOfCnns". This value should be 2 for applications that use only one session to Indexserver. It should be set to the estimated number of concurrent calls for applications that use more sessions simultanously. This value is optional and defaults to 10.
      See Also:
      Constant Field Values
    • PROP_TIMEOUT_SECONDS

      public static final java.lang.String PROP_TIMEOUT_SECONDS
      Property name for connection timeout: "connection.timeoutSeconds" in seconds. This value is optional and defaults to 120 seconds.
      See Also:
      Constant Field Values
    • PROP_TEMP_DIR

      public static final java.lang.String PROP_TEMP_DIR
      Property name for a temporary directory: "connection.tempDir". This value is optional and is currently not used.
      See Also:
      Constant Field Values
    • NB_OF_REVERSE_CNNS

      public static final java.lang.String NB_OF_REVERSE_CNNS
      Number of reverse connections. This is the number of long-polls opened to the server in order to receive events.
      See Also:
      Constant Field Values
    • connProps

      protected java.util.Properties connProps
      Connection properties.
    • createNewIxClient

      protected java.util.concurrent.atomic.AtomicBoolean createNewIxClient
      Remember to create a new IXClient object for the next IXConnection object. Each IXConnection object gets its own IXClient object. When the first IXConnection is created, it gets the IXClient object created in the constructor of the IXConnFactory. For the following IXConnection objects, new IXClient objects have to be created. This member is true, if the first IXConnection object has been created and the current IXClient object must be cloned for the next IXConnection.
    • sessOpts

      protected java.util.Properties sessOpts
      Session options.
      See Also:
      SessionOptions
    • tpool

      protected java.util.concurrent.ExecutorService tpool
      Thread pool for HTTP requests.
    • CONST

      protected IXServicePortC CONST
      Constants
  • Constructor Details

    • IXConnFactory

      public IXConnFactory​(java.util.Properties props, java.util.Properties sessOpts) throws byps.RemoteException
      Constructor. The supplied connection properties are used to create the internal IXClient object. They are passed to each IXConnection object created by one of the create function. The given session options are passed to the IXConnLogin objects instanciated in the create functions. The functions createConnProperties and createSessionOptions can help to create the properties collections.
      Parameters:
      props - Connection properties.
      sessOpts - Session options.
      Throws:
      byps.RemoteException - E.g. if the connection cannot be established.
      See Also:
      createConnProps, createSessionOptions
    • IXConnFactory

      public IXConnFactory​(java.lang.String url, java.lang.String appName, java.lang.String appVersion)
      Constructor.
      Parameters:
      url - Indexserver URL
      appName - Application name
      appVersion - Application version
      Throws:
      java.lang.IllegalStateException - E.g. if the connection cannot be established.
  • Method Details

    • createConnProps

      public static java.util.Properties createConnProps​(java.lang.String url)
      Create a connection properties object.
      Parameters:
      url - URL to Indexserver
      Returns:
      Properties object.
      See Also:
      PROP_URL
    • createConnProps

      public static java.util.Properties createConnProps​(java.lang.String url, int nbOfCnns, int timeoutSeconds)
      Create a connection properties object.
      Parameters:
      url - URL to Indexserver
      nbOfCnns - Size of connection pool with connections to Indexserver.
      timeoutSeconds -
      Returns:
      Properties object.
      See Also:
      PROP_URL, PROP_NB_OF_CNNS, PROP_TIMEOUT_SECONDS
    • createSessionOptions

      public static java.util.Properties createSessionOptions​(java.lang.String appName, java.lang.String appVersion)
      Creates a property collection that contains session options. The client application type property (SessionOptionsC.CLIENT_APP_TYPE) is set to SessionOptionsC.TYPE_PARTNER_APPLICATION.
      Parameters:
      appName - Application name.
      appVersion - Application version.
      Returns:
      Properties object.
      See Also:
      SessionOptions
    • getConnProperties

      public java.util.Properties getConnProperties()
      Get connection properties.
      Returns:
      Connection properties.
    • getSessionOptions

      public java.util.Properties getSessionOptions()
      Get session options.
      Returns:
      Session options.
    • getCONST

      public IXServicePortC getCONST() throws byps.RemoteException
      Returns the constants object.
      Returns:
      Constants object.
      Throws:
      byps.RemoteException
    • makeDefaultClientInfo

      public ClientInfo makeDefaultClientInfo()
      Creates a ClientInfo object and assigns the language, country from the default values of the Java VM. The timezone member is initialized with UTC.
      Returns:
      ClientInfo object.
    • createOffline

      public IXConnection createOffline() throws byps.RemoteException
      RESERVED.
      Returns:
      IXConnection object.
      Throws:
      byps.RemoteException
    • create

      public IXConnection create​(java.lang.String userName, java.lang.String userPwd, java.lang.String computerName, java.lang.String runAs) throws byps.RemoteException
      Create a connection for the given user. The required ClientInfo object with language, country and timezone is created by makeDefaultClientInfo.
      Parameters:
      userName - User name.
      userPwd - Plain text user password.
      computerName - Computer name.
      runAs - User name or ID if this should be a run-as connection.
      Returns:
      IXConnection object.
      Throws:
      byps.RemoteException
    • create

      public IXConnection create​(ClientInfo ci, java.lang.String userName, java.lang.String userPwd, java.lang.String computerName, java.lang.String runAs) throws byps.RemoteException
      Create aconnection for the given user.
      Parameters:
      ci - ClientInfo object with language, country and timezone
      userName - User name.
      userPwd - Plain text user password.
      computerName - Computer name.
      runAs - User name or ID if this should be a run-as connection.
      Returns:
      IXConnection object.
      Throws:
      byps.RemoteException
    • internalCreateConnection

      protected void internalCreateConnection​(IXAuthentication auth, java.net.HttpCookie sessionCookie, byps.BAsyncResult<IXConnection> asyncResult)
      Create a connection with the given authentication object and optional HTTP session cookie.
      Parameters:
      auth - Authentication handler
      sessionCookie - Optional HTTP session cookie. At least domain, path, secure and httpOnly should be set in the given cookie.
      asyncResult - Result handler
    • internalCreateIXConnectionObject

      protected IXConnection internalCreateIXConnectionObject​(IXConnFactory connFact, de.elo.ix.client.BClient_Indexserver bclient, IXAuthentication auth, java.lang.String url, java.util.Properties connProps, java.util.Properties sessOpts)
      Create IXConnection object. Can be overloaded in subclasses to create a customized connection object.
      Parameters:
      connFact -
      bclient -
      auth -
      url -
      connProps -
      sessOpts -
      Returns:
      IXConnection object
    • create

      public IXConnection create​(ClientInfo ciAdmin, java.lang.String runAs) throws byps.RemoteException
      Create a connection for the given Run-As-user for an existent ticket
      Parameters:
      ciAdmin - ClientInfo object with language, country and timezone with valid ticket of an administrator.
      runAs - User name or ID if this should be a run-as connection.
      Returns:
      IXConnection object.
      Throws:
      byps.RemoteException
    • createKrb

      public IXConnection createKrb​(ClientInfo ci, java.lang.String realm, java.lang.String kdc, java.lang.String servicePrincipal, java.lang.String computerName) throws byps.RemoteException
      Create a session for the current Windows OS user via Kerberos authentication. Note: Function is not supported by API calls anymore, but might sill be needed for support (EIX-1195)
      Parameters:
      ci - ClientInfo object with language, country and timezone.
      realm - Kerberos Realm, Windows Domain, e.g. ELO.local.
      kdc - Key Distribution Center, Active Directory computer name, e.g. negril.elo.local.
      servicePrincipal - Account name used to generate the keytab file for AM, e.g. krb_NEGRIL.
      computerName - Client computer name for reporting.
      Returns:
      IXConnection object.
      Throws:
      byps.RemoteException
    • createAdmin

      public IXConnection createAdmin​(java.lang.String userName, java.lang.String userPwd, java.lang.String computerName, java.lang.String reportAs) throws byps.RemoteException
      Create a connection for the given user. The required ClientInfo object with language, country and timezone is created by makeDefaultClientInfo.
      Parameters:
      userName - User name.
      userPwd - Plain text user password.
      computerName - Computer name.
      reportAs - User name or ID used in reporting and as owner ID.
      Returns:
      IXConnection object.
      Throws:
      byps.RemoteException
    • createAdmin

      public IXConnection createAdmin​(ClientInfo ci, java.lang.String userName, java.lang.String userPwd, java.lang.String computerName, java.lang.String reportAs) throws byps.RemoteException
      Create aconnection for the given user.
      Parameters:
      ci - ClientInfo object with language, country and timezone
      userName - User name.
      userPwd - Plain text user password.
      computerName - Computer name.
      reportAs - User name or ID used in reporting and as owner ID.
      Returns:
      IXConnection object.
      Throws:
      byps.RemoteException
    • init

      protected void init() throws byps.RemoteException
      Initialize this object. Extracts the connection properties from the properties collection an instanciates an IXClient object.
      Throws:
      java.io.IOException
      byps.RemoteException
    • done

      public void done()
    • createSso

      public IXConnection createSso​(ClientInfo ci, java.lang.String computerName) throws byps.RemoteException
      Create connection for the current user of the operating system. A HTTP-GET request is sent to the server ixlogin. The current credentials from CredentialsCache are supplied to the request. The server has to check the credentials.
      Parameters:
      ci - ClientInfo
      computerName - Client computer name
      Returns:
      Connection
      Throws:
      byps.RemoteException
    • createSso

      public IXConnection createSso​(java.lang.String computerName) throws byps.RemoteException
      Create connection for the current user of the operating system. A HTTP-GET request is sent to the server ixlogin. The current credentials from CredentialsCache are supplied to the request. The server has to check the credentials. The ClientInfo object is created by makeDefaultClientInfo.
      Parameters:
      computerName - Client computer name
      Returns:
      Connection
      Throws:
      byps.RemoteException
    • createFromTicket

      public IXConnection createFromTicket​(ClientInfo ci) throws byps.RemoteException
      Create a connection from any valid AM ticket.
      Parameters:
      ci - ci.ticket contains the AM ticket
      Returns:
      IXConnection object
      Throws:
      byps.RemoteException
    • createFromTicketForRelogin

      public IXConnection createFromTicketForRelogin​(java.util.function.Supplier<ClientInfo> clientInfoFnct) throws byps.RemoteException
      Create a connection from any valid AM ticket provided by a supplier function.
      Parameters:
      clientInfoFnct - Function that provides a ClientInfo. Called on initial connect and subsequent re-connects.
      Returns:
      IXConnection object
      Throws:
      byps.RemoteException
    • createFromCookie

      public IXConnection createFromCookie​(ClientInfo ci, java.net.HttpCookie sessionCookie) throws byps.RemoteException
      Create a connection from a httpSession cookie supplied in the connection properties of IXConnFactory. To create a connection for an existing JSESSIONID known by Indexserver, do as follows:
      
       String jsessionId = ...
       String domain = ... server name or Internet address, e.g. localhost
       String path = ... cookie path, e.g. /ix-elo200
       boolean secure = ... true if this cookie should be sent only over HTTPS. 
       boolean httpOnly = true;
       
       Create a HttpCookie object for the JSESSION cookie.
       HttpCookie sessionCookie = new HttpCookie(HConstants.HTTP_COOKIE_JSESSIONID, jsessionId);
       sessionCookie.setDomain(domain);
       sessionCookie.setPath(path);
       sessionCookie.setSecure(secure);
       sessionCookie.setHttpOnly(httpOnly);
       
       IXConnFactory connFact = new IXConnFactory(...);
       try (IXConnection conn = connFact.createFromCookie(new ClientInfo(), sessionCookie)) {
         ...
       }
       connFact.done();
       
      Parameters:
      ci - ClientInfo object with language, country, timezone, etc.
      sessionCookie - HTTP server session cookie. At least domain, path, secure and httpOnly should be set in the given cookie.
      Returns:
      IXConnection object
      Throws:
      byps.RemoteException
      Since:
      20.00.000.009
    • createForConstants

      protected IXConnection createForConstants() throws byps.RemoteException
      Throws:
      byps.RemoteException
    • getVersion

      public java.lang.String getVersion()
      Get Indexserver version.
      Returns:
      Indexserver version (without build number)
    • getMajorVersion

      public int getMajorVersion()
      Returns:
      MajorVersion as int
    • readStatusPageProperty

      public static java.lang.String readStatusPageProperty​(java.lang.String ixUrl, java.lang.String propertyName)
      Helper function used to read the Indexserver version numbers.
      Parameters:
      ixUrl - Indexserver URL
      propertyName - Property name
      Returns:
      Property value
    • readStatusPageProperties

      public static java.util.Properties readStatusPageProperties​(java.lang.String ixUrl)
      Helper function used retrieve all properties of the ix status page
      Parameters:
      ixUrl - Indexserver URL
      Returns:
      Properties
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object