Example #1
0
        /// <summary>
        /// Is the token valid
        /// </summary>
        /// <param name="uniqueIdentifier">The unique client identifier.</param>
        /// <param name="serviceName">The service name the client is connected to.</param>
        /// <param name="token">The token to validate.</param>
        /// <param name="callback">The callback handler when a result is retured, a client web response.</param>
        /// <param name="actionName">The current action callback name.</param>
        /// <param name="state">The state callback handler object.</param>
        /// <exception cref="System.Exception"></exception>
        /// <exception cref="System.ArgumentNullException"></exception>
        public async void IsValid(string uniqueIdentifier, string serviceName, string token, Action <bool, Nequeo.Security.IPermission, object> callback, string actionName = "", object state = null)
        {
            Exception exec      = null;
            var       tokenData = await Nequeo.Threading.AsyncOperationResult <bool> .
                                  RunTask <bool>(() =>
            {
                try
                {
                    return(TokenReader.IsValid(uniqueIdentifier, serviceName, token, _tokenData));
                }
                catch (Exception ex)
                {
                    exec = ex;
                    return(false);
                }
            });

            var permission = await Nequeo.Threading.AsyncOperationResult <bool> .
                             RunTask <Nequeo.Security.IPermission>(() =>
            {
                try
                {
                    return(TokenReader.GetPermission(uniqueIdentifier, serviceName, _tokenData));
                }
                catch (Exception ex)
                {
                    exec = ex;
                    return(null);
                }
            });

            if (exec != null)
            {
                if (_callback_Exception != null)
                {
                    _callback_Exception("IsValid", exec);
                }
            }
            if (callback != null)
            {
                callback(tokenData, permission, state);
            }
        }