public object Process(HttpContextBase context)
        {
            Arguments.NotNull(context, "context");

            AuthResponseType responseType = AuthResponseType.AccessToken;
            var responseTypeString        = MessageUtility.TryGetString(context.Request, Protocal.RESPONSE_TYPE);

            if (!String.IsNullOrEmpty(responseTypeString))
            {
                if (!AuthResponseTypeExtend.TryParse(responseTypeString, out responseType))
                {
                    throw new OAuthException(AccessTokenRequestErrorCode.InvalidRequest, "wrong response_type value", 400);
                }
            }

            var request = context.Request;

            switch (responseType)
            {
            case AuthResponseType.AccessToken:
                var tokenRequest = MessageUtility.ParseTokenRequest(request);
                tokenRequest.OAuthService = this;
                return(tokenRequest.Token());

            case AuthResponseType.AuthorizationCode:
                var authorizeRequest = MessageUtility.ParseAuthRequest(request);
                authorizeRequest.OAuthService = this;
                return(authorizeRequest.Authorize());
            }
            return(null);
        }
Esempio n. 2
0
        public void Parse(HttpRequestBase request)
        {
            ClientId = MessageUtility.GetInt32(request, Protocal.CLIENT_ID);
            AuthResponseType responseType;

            if (!AuthResponseTypeExtend.TryParse(MessageUtility.GetString(request, Protocal.RESPONSE_TYPE), out responseType))
            {
                throw new OAuthException(AuthRequestErrorCode.UnsupportedResponseType, "invalid response type", 400);
            }

            RedirectUri = new Uri(MessageUtility.GetString(request, Protocal.REDIRECT_URI));
            State       = MessageUtility.TryGetString(request, Protocal.STATE);
            Scope       = MessageUtility.TryGetString(request, Protocal.SCOPE);
            PlatCode    = MessageUtility.GetInt64(request, "platcode");
            ExtendField = MessageUtility.TryGetString(request, "extendfield");
        }