Class IXConnFactory

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

public class IXConnFactory extends 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 Details

    • PROP_URL

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

      public static final 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:
    • PROP_TIMEOUT_SECONDS

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

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

      public static final 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:
    • connProps

      protected Properties connProps
      Connection properties.
    • createNewIxClient

      protected 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 Properties sessOpts
      Session options.
      See Also:
    • tpool

      protected ExecutorService tpool
      Thread pool for HTTP requests.
    • CONST

      protected IXServicePortC CONST
      Constants
  • Constructor Details

    • IXConnFactory

      public IXConnFactory(Properties props, 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:
    • IXConnFactory

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

    • createConnProps

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

      public static Properties createConnProps(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:
    • createSessionOptions

      public static Properties createSessionOptions(String appName, 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:
    • getConnProperties

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

      public 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(String userName, String userPwd, String computerName, 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, String userName, String userPwd, String computerName, 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
    • internalCreateWithPassword

      protected IXConnection internalCreateWithPassword(ClientInfo ci, String userName, String userPwd, String computerName, String runAs, EAuthenticationType authType) throws byps.RemoteException
      Create a connection for name/password authentication.
      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.
      authType - Authentication type
      Returns:
      IXConnection object.
      Throws:
      byps.RemoteException
    • internalCreateConnection

      protected void internalCreateConnection(IXAuthentication auth, 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
    • getTransportFactory

      protected byps.http.HTransportFactoryClient getTransportFactory(int nbOfReverseConnections, IXConnFactory.MyWireClient wire)
    • internalCreateIXConnectionObject

      protected IXConnection internalCreateIXConnectionObject(IXConnFactory connFact, de.elo.ix.client.BClient_Indexserver bclient, IXAuthentication auth, String url, Properties connProps, 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, 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, String realm, String kdc, String servicePrincipal, 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(String userName, String userPwd, String computerName, 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, String userName, String userPwd, String computerName, 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()
      Initialize this object. Extracts the connection properties from the properties collection an instanciates an IXClient object.
    • done

      public void done()
    • createSso

      public IXConnection createSso(ClientInfo ci, 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(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(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, 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

      @Deprecated public String getVersion()
      Deprecated.
      Get Indexserver version.
      Returns:
      Indexserver version (without build number) EIX-2519: Declared as deprecated to avoid to show protected information on status page. Use IXConnectionIF.getVersion().
      See Also:
    • getMajorVersion

      @Deprecated public int getMajorVersion()
      Deprecated.
      Returns:
      MajorVersion as int EIX-2519: Declared as deprecated to avoid to show protected information on status page.
      See Also:
    • readStatusPageProperty

      @Deprecated public static String readStatusPageProperty(String ixUrl, String propertyName)
      Deprecated.
      Helper function used to read the Indexserver version numbers.
      Parameters:
      ixUrl - Indexserver URL
      propertyName - Property name
      Returns:
      Property value EIX-2519: Declared as deprecated to avoid to show protected information on status page.
    • readStatusPageProperties

      @Deprecated public static Properties readStatusPageProperties(String ixUrl)
      Deprecated.
      Helper function used retrieve all properties of the ix status page
      Parameters:
      ixUrl - Indexserver URL
      Returns:
      Properties EIX-2519: Declared as deprecated to avoid to show protected information on status page.
    • toString

      public String toString()
      Overrides:
      toString in class Object