Esempio n. 1
0
        public static List <OAuth.Parameter> getParameters(HttpRequest request)
        {
            List <OAuth.Parameter> list = new List <OAuth.Parameter>();

            foreach (String header in request.Headers.GetValues("Authorization"))
            {
                foreach (OAuth.Parameter parameter in OAuthMessage.decodeAuthorization(header))
                {
                    if (!parameter.Key.ToLower().Equals("realm"))
                    {
                        list.Add(parameter);
                    }
                }
            }
            for (int i = 0; i < request.QueryString.Count; i++)
            {
                String name = request.QueryString.GetKey(i);
                foreach (String value in request.QueryString.GetValues(i))
                {
                    list.Add(new OAuth.Parameter(name, value));
                }
            }
            for (int i = 0; i < request.Form.Count; i++)
            {
                String name = request.Form.GetKey(i);
                foreach (String value in request.Form.GetValues(i))
                {
                    list.Add(new OAuth.Parameter(name, value));
                }
            }
            return(list);
        }
Esempio n. 2
0
        /**
         * Parse OAuth WWW-Authenticate header and either add them to an existing
         * message or create a new message.
         *
         * @param msg
         * @param resp
         * @return the updated message.
         */
        private static OAuthMessage parseAuthHeader(OAuthMessage msg, sResponse resp)
        {
            if (msg == null)
            {
                msg = new OAuthMessage(null, null, null);
            }

            foreach (String auth in resp.getHeaders("WWW-Authenticate"))
            {
                msg.addParameters(OAuthMessage.decodeAuthorization(auth));
            }

            return(msg);
        }