Beispiel #1
0
        /// <summary>
        /// Authenticate a user with the EJS.
        /// If authentication is successful a new Session Token
        /// is returned.
        /// </summary>
        /// <param name="userName">User Name to validate.</param>
        /// <param name="password">Password to validate.</param>
        /// <param name="sourceHostId">A uniqe string that identifies this client's host. This string is per session.</param>
        /// <returns>A Token that contains the negotiated login data.</returns>
        public static ejsSessionToken AuthenticateUser(
            string userName, string password, Guid sourceHostId)
        {
            EjsPublicServiceClient _client = null;

            try
            {
                _client = new EjsPublicServiceClient();
                _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress);
                ejsSessionToken newToken = _client.Authenticate(userName, password, sourceHostId);
                return(newToken);
            }
            catch (FaultException <ejsFailureReport> ex)
            {
                throw new ApplicationException(ex.Detail._header + "\n" + ex.Detail._originalException.Message);
            }
            catch (Exception)
            {
                throw new ApplicationException("EJSと接続する際に失敗しました。");
            }
            finally
            {
                if (_client != null)
                {
                    _client.Close();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Authenticate a user with the EJS.
        /// If authentication is successful a new Session Token
        /// is returned.
        /// </summary>
        /// <param name="userName">User Name to validate.</param>
        /// <param name="password">Password to validate.</param>
        /// <param name="sourceHostId">A uniqe string that identifies this client's host. This string is per session.</param>
        /// <returns></returns>
        public static ejsSessionToken AuthenticateUser(
            string userName, string password, Guid sourceHostId)
        {
            EjsPublicServiceClient _client = null;

            try
            {
                _client = new EjsPublicServiceClient();
                _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress);
                ejsSessionToken newToken = _client.Authenticate(userName, password, sourceHostId);
                return(newToken);
            }
            catch (FaultException <ejsFailureReport> ex)
            {
                throw new ApplicationException(ex.Detail._header + "\n" + ex.Detail._message);
            }
            //	[shiniwa] We just do NOT need this. Let's do NOT translate arbitrary exceptions to ApplicationException
            //catch (Exception)
            //{
            //	throw new ApplicationException(Properties.Resources.EX_EjsConnectionFailed);
            //}
            finally
            {
                if (_client != null)
                {
                    _client.Close();
                }
            }
        }