예제 #1
0
        private void provideEncrPasswords(BClient_Indexserver client, IEnumerator <String> itpwd, BAsyncResult <bool> asyncResult)
        {
            if (itpwd.MoveNext())
            {
                try
                {
                    String cryptId = itpwd.Current;
                    String pwd     = encrPasswords[cryptId];
                    String pwdEncr = encryptPassword(pwd);

                    BAsyncResult <Object> outerResult = (ignored, e) =>
                    {
                        if (e != null)
                        {
                            asyncResult(false, e);
                        }
                        else
                        {
                            provideEncrPasswords(client, itpwd, asyncResult);
                        }
                    };

                    client.IXServicePortIF.provideCryptPassword(cryptId, pwdEncr, outerResult);
                }
                catch (Exception e)
                {
                    asyncResult(false, e);
                }
            }
            else
            {
                asyncResult(false, null);
            }
        }
예제 #2
0
            /// <summary>
            /// Send the given events.
            /// </summary>
            /// <remarks>
            /// The function sets the member busId of the Event objects to the ID of this bus.
            /// </remarks>
            /// <param name="events">Array of events to be sent.</param>
            /// <returns>this object</returns>
            public Bus Send(Event[] events)
            {
                if (events != null && events.Length != 0)
                {
                    foreach (Event e in events)
                    {
                        e.busId = this.busId;
                    }
                    try
                    {
                        eventBusApi.conn.Ix.sendEvents(eventBusApi.eventBusSubsId, events);
                    }
                    catch (Exception ex)
                    {
                        BClient_Indexserver bclient = eventBusApi.bclient;
                        if (!bclient.getAuthentication().isReloginException(bclient, ex, 0))
                        {
                            throw ex;
                        }

                        BSyncResult <bool> syncResult = new BSyncResult <bool>();
                        bclient.getTransport().negotiateProtocolClient(syncResult);
                        syncResult.GetResult();

                        long subsId = eventBusApi.SubscriberId;
                        bclient.IXServicePortIF.sendEvents(subsId, events);
                    }
                }
                return(this);
            }
예제 #3
0
        internal EventBusApi(IXConnection conn, BClient_Indexserver bclient)
        {
            this.conn    = conn;
            this.bclient = bclient;

            bclient.addRemote(new MyEventBusHandler(this));
        }
예제 #4
0
        protected override void internalAuthenticate(BClient_Indexserver client, BAsyncResult <bool> asyncResult)
        {
            BAsyncResult <LoginResult> outerResult = (loginResult, ex) =>
            {
                this.setLoginResult(loginResult);
                asyncResult(false, ex);
            };

            try
            {
                String encrPwd = encryptPassword(userPwd);
                if (reportAs)
                {
                    client.IXServicePortIF.loginAdmin(userName, encrPwd, computerName, runAs, outerResult);
                }
                else
                {
                    client.IXServicePortIF.login(userName, encrPwd, computerName, runAs, outerResult);
                }
            }
            catch (Exception e)
            {
                asyncResult(false, e);
            }
        }
예제 #5
0
 protected override void internalAuthenticate(BClient_Indexserver client, BAsyncResult <bool> asyncResult)
 {
     client.IXServicePortIF.login("", "", "", runAs,
                                  (loginResult, ex) =>
     {
         this.setLoginResult(loginResult);
         asyncResult(false, ex);
     });
 }
예제 #6
0
 public BServer_Indexserver(BTransportFactory transportFactory)
     : base(
         transportFactory.createServerTransport(),
         transportFactory.createClientR(
             BClient_Indexserver.createClientR(
                 transportFactory.createClientTransport()
                 )
             )
         )
 {
 }
예제 #7
0
 public IXConnection(IXConnFactory iXConnFactory,
                     BClient_Indexserver bclient, IXAuthentication auth, string url,
                     IXProperties connProps, IXProperties sessOpts)
 {
     this.iXConnFactory     = iXConnFactory;
     this.bclient           = bclient;
     this.auth              = auth;
     this.url               = url;
     this.connPropsVal      = connProps;
     this.sessionOptionsVal = sessOpts;
     this.ixVal             = new IXCachedConnIXServicePortIF(bclient.getTransport(), connProps);
     this.disposed          = false;
 }
예제 #8
0
        protected override void internalAuthenticate(BClient_Indexserver client, BAsyncResult <bool> asyncResult)
        {
            // Do not use the session properties initialized in the constructor of IXConnFactory.
            // The options set by the application that created the ticked should not be overwritten.
            // Especially, the options ixUrlBase and docUrlBase must not be changed to a relative URL.

            IXProperties sessOpts2 = new IXProperties();

            client.IXServicePortIF.getSessionFromTicket(SessionOptionsC.SESSION_FROM_AM_ADD,
                                                        (loginResult, ex) =>
            {
                this.setLoginResult(loginResult);
                asyncResult(false, ex);
            });
        }
예제 #9
0
        private void invokeInternalAuthenticateThenSetGetServerInfo(BClient_Indexserver client, BAsyncResult <bool> asyncResult)
        {
            BAsyncResult <bool> outerResult = (ignored, e) =>
            {
                if (e != null)
                {
                    asyncResult(false, e);
                }
                else
                {
                    invokeGetServerinfoThenSetSessionOptions(client, asyncResult);
                }
            };

            internalAuthenticate(client, outerResult);
        }
예제 #10
0
        private void providePublicEncrKey(BClient_Indexserver client, BAsyncResult <bool> asyncResult)
        {
            BAsyncResult <LoginResult> asyncLogin = (lr, e) =>
            {
                if (e != null)
                {
                    asyncResult(false, e);
                }
                else
                {
                    publicKey = publicKeyFromString(lr.clientInfo.ticket);
                    asyncResult(true, null);
                }
            };

            client.IXServicePortIF.login("PUBLIC_ENCR_KEY", null, null, null, asyncLogin);
        }
예제 #11
0
        private void invokeGetServerinfoThenSetSessionOptions(BClient_Indexserver client, BAsyncResult <bool> asyncResult)
        {
            BAsyncResult <ServerInfo> outerResult = (serverInfo, e) =>
            {
                if (e != null)
                {
                    asyncResult(false, e);
                }
                else
                {
                    databaseEngine = serverInfo.databaseEngine;
                    invokeSetSessionOptionsThenProvidePasswords(client, asyncResult);
                }
            };

            client.IXServicePortIF.getServerInfo(outerResult);
        }
예제 #12
0
        private void invokeSetSessionOptionsThenProvidePasswords(BClient_Indexserver client, BAsyncResult <bool> asyncResult)
        {
            BAsyncResult <Object> outerResult = (result, e) =>
            {
                if (e != null)
                {
                    asyncResult(false, e);
                }
                else
                {
                    IEnumerator <String> itpwd = encrPasswords.Keys.GetEnumerator();
                    provideEncrPasswords(client, itpwd, asyncResult);
                }
            };

            SessionOptions opts = makeSessOptsObj();

            client.IXServicePortIF.setSessionOptions(opts, outerResult);
        }
예제 #13
0
            /// <summary>
            /// Add the given event listener.
            /// </summary>
            /// <param name="eventListener">Event listener, the member busId will be internally set for each filter.</param>
            /// <returns>Listener ID</returns>
            public long AddListener(EventListener eventListener)
            {
                long lsnId = 0;

                if (eventListener != null && eventListener.filters != null && eventListener.filters.Length != 0)
                {
                    eventBusApi.ensureSubscriber();

                    foreach (EventFilter f in eventListener.filters)
                    {
                        f.busId = busId;
                    }

                    if (eventListeners == null)
                    {
                        eventListeners = new Dictionary <long, EventListener>();
                    }

                    try
                    {
                        lsnId = eventBusApi.conn.Ix.createEventBusListener(eventBusApi.SubscriberId, eventListener);
                        eventListeners[lsnId] = eventListener;
                    }
                    catch (Exception ex)
                    {
                        BClient_Indexserver bclient = eventBusApi.bclient;
                        if (!bclient.getAuthentication().isReloginException(bclient, ex, 0))
                        {
                            throw ex;
                        }

                        BSyncResult <bool> syncResult = new BSyncResult <bool>();
                        bclient.getTransport().negotiateProtocolClient(syncResult);
                        syncResult.GetResult();

                        long subsId = eventBusApi.SubscriberId;
                        lsnId = bclient.IXServicePortIF.createEventBusListener(subsId, eventListener);
                        eventListeners[lsnId] = eventListener;
                    }
                }
                return(lsnId);
            }
예제 #14
0
        public virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                Logout();
                iXConnFactory     = null;
                auth              = null;
                url               = null;
                connPropsVal      = null;
                sessionOptionsVal = null;
                ixVal             = null;
                constVal          = null;
                eventBusApiVal    = null;
                bclient           = null;
            }
            disposed = true;
        }
예제 #15
0
        public virtual void authenticate(BClient client1, BAsyncResult <Boolean> asyncResult)
        {
            BClient_Indexserver client = (BClient_Indexserver)client1;

            BAsyncResult <bool> listenerResult = (ignored, e) =>
            {
                notifyListeners(client, e);
                asyncResult(ignored, e);
            };

            BAsyncResult <bool> outerResult = (ignored, e) =>
            {
                if (e != null)
                {
                    asyncResult(ignored, e);
                }
                else
                {
                    invokeInternalAuthenticateThenSetGetServerInfo(client, listenerResult);
                }
            };

            providePublicEncrKey(client, outerResult);
        }
예제 #16
0
        protected override void internalAuthenticate(BClient_Indexserver client, BAsyncResult <bool> asyncResult)
        {
            // Aktuelle ClientInfo bereitstellen, wg. Landessprache, Zeitzone usw.
            ClientInfo ci = getLoginResult().clientInfo;

            // Verbindungsobjekt für GET-Request
            IXWireClient wire = (IXWireClient)client.getTransport().getWire();

            HttpWebResponse resp = null;

            try
            {
                String loginServletUrl = wire.getUrlForAuthentication();

                long negotiatedVersion     = client.getTransport().getProtocol().negotiatedVersion;
                long negotiatedBypsVersion = client.getTransport().getProtocol().negotiatedBypsVersion;

                // Schreibe diese 9er Version für die Verbindung zu IX 9.0.
                // Weil bei ELO 9 ein String-Vergleich gemacht wird, wäre sonst die Version 10 kleiner als die Version 9
                loginServletUrl += "?streamversion=" + BVersioning.stringToLong("9.99.0.0");

                loginServletUrl += "&bstreamversion=" + BVersioning.longToString(negotiatedVersion);
                loginServletUrl += "&bversion=" + negotiatedBypsVersion;

                loginServletUrl += "&responseformat=byps-binary";
                if (ci.language != null)
                {
                    loginServletUrl += "&language=" + ci.language;
                }
                if (ci.timeZone != null)
                {
                    loginServletUrl += "&timezone=" + HttpUtility.UrlEncode(ci.timeZone);
                }
                if (ci.country != null)
                {
                    loginServletUrl += "&country=" + ci.country;
                }
                if (ci.callId != null)
                {
                    loginServletUrl += "&callid=" + HttpUtility.UrlEncode(ci.callId);
                }
                if (computerName != null)
                {
                    loginServletUrl += "&computerName=" + HttpUtility.UrlEncode(computerName);
                }

                // Sitzungskennung übergeben.
                // Sie wird direkt verworfen und es wird eine neue erstellt.
                loginServletUrl += "&sessionid=" + HttpUtility.UrlEncode(client.getTransport().getSessionId());

                if (WebRequest.DefaultWebProxy != null)
                {
                    WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials;
                }

                HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(loginServletUrl);
                req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

                req.Credentials = CredentialCache.DefaultCredentials;

                //http://blogs.msdn.com/buckh/archive/2004/07/28/199706.aspx

                //CredentialCache credCache = new CredentialCache();
                //credCache.Add(new Uri(loginServletUrl), "NTLM",
                //              CredentialCache.DefaultNetworkCredentials);
                //req.Credentials = credCache;

                resp = (HttpWebResponse)req.GetResponse();

                if (resp.StatusCode != HttpStatusCode.OK)
                {
                    asyncResult(false, new BException((int)resp.StatusCode, "HTTP Status " + resp.StatusCode));
                }

                Stream     responseStream = resp.GetResponseStream();
                ByteBuffer buf            = BWire.bufferFromStream(responseStream, false);

                BMessageHeader header = new BMessageHeader();
                header.read(buf);

                // Neue Sitzungs-ID übernehmen
                if (!header.targetId.isZero())
                {
                    client.getTransport().setTargetId(header.targetId);
                    client.getTransport().setSessionId(header.sessionId);
                }

                BInput      bin         = client.getTransport().getInput(header, buf);
                LoginResult loginResult = (LoginResult)bin.load();

                this.setLoginResult(loginResult);
                asyncResult(false, null);
            }
            catch (Exception e)
            {
                asyncResult(false, e);
            }
            finally
            {
                if (resp != null)
                {
                    resp.Close();
                }
            }
        }
예제 #17
0
        private void internalCreateConnection(IXAuthentication auth, BAsyncResult <IXConnection> asyncResult)
        {
            // Check version
            if (MajorVersion < 9)
            {
                BException ex = new BException(BExceptionC.CONNECTION_TO_SERVER_FAILED,
                                               "Received server version " + Version + ". At least server version 9.00.000 is required.");
                asyncResult(null, ex);
                return;
            }

            // IX-URL, e.g. http://localhost:8084/ix-elo80/ix
            String url = connProps[PROP_URL];

            // BYPS-URL, e.g. http://localhost:8084/ix-elo80/byps
            String bypsUrl = url;
            int    pos     = bypsUrl.LastIndexOf("/ix");

            if (pos >= 0)
            {
                bypsUrl = bypsUrl.Substring(0, pos) + "/byps";
                if (pos + 3 < url.Length)
                {
                    bypsUrl += url.Substring(pos + 3);
                }
            }

            // timeout
            String timeoutSecondsStr = connProps[PROP_TIMEOUT_SECONDS];
            int    timeoutSeconds    = Convert.ToInt32(timeoutSecondsStr != null && timeoutSecondsStr.Length != 0 ? timeoutSecondsStr : "120");

            // #reverse connections
            String reverseConnsStr        = connProps[NB_OF_REVERSE_CNNS];
            int    nbOfReverseConnections = Convert.ToInt32(reverseConnsStr != null && reverseConnsStr.Length != 0 ? reverseConnsStr : "1");

            // Wire, transport, client
            IXWireClient        wire             = new IXWireClient(bypsUrl, 0, timeoutSeconds);
            BTransportFactory   transportFactory = new HTransportFactoryClient(BApiDescriptor_Indexserver.instance, wire, nbOfReverseConnections);
            BClient_Indexserver bclient          = BClient_Indexserver.createClient(transportFactory);

            // Authentication
            bclient.setAuthentication(auth);

            // IXConnection
            IXConnection conn = new IXConnection(this, bclient, auth, url, connProps, sessOpts);

            BAsyncResult <bool> outerResult = (ignored, e) =>
            {
                if (e != null)
                {
                    asyncResult(conn, e);
                }
                else if (this.CONST != null)
                {
                    asyncResult(conn, e);
                }
                else
                {
                    // Read constants
                    BAsyncResult <IXServicePortC> constResult = (CONST, ex) =>
                    {
                        this.CONSTVal = CONST;
                        asyncResult(conn, ex);
                    };

                    conn.getCONST(constResult);
                }
            };

            // Start client
            bclient.start(outerResult, false);
        }
예제 #18
0
 protected abstract void internalAuthenticate(BClient_Indexserver client, BAsyncResult <bool> asyncResult);