Esempio n. 1
0
        /// <summary>
        /// Logins the specified user name.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <param name="notificationUrl">The notification URL.</param>
        /// <param name="protocolVersion">The protocol version.</param>
        /// <param name="effectiveProtocolVersion">[out]The effective protocol version.</param>
        /// <param name="applicationIds">The application ids.</param>
        /// <returns>The session id.</returns>
        public int login(string userName, string password, string notificationUrl, int protocolVersion, out int effectiveProtocolVersion, params string[] applicationIds)
        {
            ApplicationIdList list = new ApplicationIdList();

            list.Capacity = applicationIds.Length;
            list.AddRange(applicationIds);
            loginInputBody body    = new loginInputBody(userName, password, notificationUrl, list, protocolVersion);
            loginInput     request = new loginInput(body);

            loginOutput result = login(request);

            effectiveProtocolVersion = result.Body.effectiveProtocolVersion;
            return(result.Body.sessionId);
        }
Esempio n. 2
0
        /// <summary>
        /// Implement the Login function of T2G Identification service.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>session id 0 if user name is invalid, otherwise a valid session id.</returns>
        public loginOutput login(loginInput request)
        {
            loginOutput result = new loginOutput();

            if (request.Body.name == "admin" && request.Body.name == "admin")
            {
                lock (_sessionLock)
                {
                    result.Body = new loginOutputBody(_nextSessionId++, Math.Min(CurrentProtocolVersion, Math.Max(1, request.Body.protocolVersion)));
                    _sessions.Add(result.Body.sessionId, new SessionData(request.Body.name, request.Body.notificationURL, result.Body.effectiveProtocolVersion, request.Body.applicationIdList));
                }
            }
            else
            {
                result.Body = new loginOutputBody(0, -1);
            }

            return(result);
        }