Ejemplo n.º 1
0
 public RestRequestArgs(RestVerbs verbs, IParameterCollection param, IRequest request, SecureRest.TokenData tokenData)
 {
     Verbs      = verbs;
     Parameters = param;
     Request    = request;
     TokenData  = tokenData;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of <see cref="RestRequestArgs"/> with the given verbs, parameters, request, token data, and context.
 /// </summary>
 /// <param name="verbs">Verbs used in the request</param>
 /// <param name="param">Parameters used in the request</param>
 /// <param name="request">The HTTP request</param>
 /// <param name="tokenData">Token data used in the request</param>
 /// <param name="context">The HTTP context</param>
 public RestRequestArgs(RestVerbs verbs, IParameterCollection param, IRequest request, SecureRest.TokenData tokenData, IHttpContext context)
 {
     Verbs      = verbs;
     Parameters = param;
     Request    = request;
     TokenData  = tokenData;
     Context    = context;
 }
Ejemplo n.º 3
0
        public object Execute(RestVerbs verbs, IParameterCollection parameters, SecureRest.TokenData tokenData, IRequest request, IHttpContext context)
        {
            if (tokenData.Equals(SecureRest.TokenData.None))
            {
                return new RestObject("401")
                       {
                           Error = "Not authorized. The specified API endpoint requires a token."
                       }
            }
            ;

            return(callback(new RestRequestArgs(verbs, parameters, request, tokenData, context)));
        }
    }
Ejemplo n.º 4
0
        public object Execute(RestVerbs verbs, IParameterCollection parameters, SecureRest.TokenData tokenData, IRequest request, IHttpContext context)
        {
            if (tokenData.Equals(SecureRest.TokenData.None))
            {
                return new RestObject("401")
                       {
                           Error = "未验证. 指定的API端点需要验证TOKEN."
                       }
            }
            ;

            return(callback(new RestRequestArgs(verbs, parameters, request, tokenData, context)));
        }
    }
Ejemplo n.º 5
0
        private object DestroyAllTokens(RestVerbs verbs, IParameterCollection parameters, SecureRest.TokenData tokenData)
        {
            Tokens.Clear();

            return(new RestObject()
            {
                Response = "All tokens were successfully destroyed."
            });
        }
Ejemplo n.º 6
0
        private object DestroyToken(RestVerbs verbs, IParameterCollection parameters, SecureRest.TokenData tokenData)
        {
            var token = verbs["token"];

            try
            {
                Tokens.Remove(token);
            }
            catch (Exception)
            {
                return(new RestObject("400")
                {
                    Error = "The specified token queued for destruction failed to be deleted."
                });
            }
            return(new RestObject()
            {
                Response = "Requested token was successfully destroyed."
            });
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new instance of <see cref="RestRequestArgs"/> with the given verbs, parameters, request, token data, and context.
 /// </summary>
 /// <param name="verbs">Verbs used in the request</param>
 /// <param name="param">Parameters used in the request</param>
 /// <param name="request">The HTTP request</param>
 /// <param name="tokenData">Token data used in the request</param>
 /// <param name="context">The HTTP context</param>
 public RestRequestArgs(RestVerbs verbs, IParameterCollection param, IRequest request, SecureRest.TokenData tokenData, IHttpContext context)
     : this(verbs, new EscapedParameterCollection(param), request, tokenData, context)
 {
 }