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);
        }
 public virtual void Parse(HttpRequestBase request)
 {
     ClientId    = MessageUtility.GetInt32(request, Protocal.CLIENT_ID);;
     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");
     Browser     = MessageUtility.TryGetString(request, "browser");
     IpAddress   = MessageUtility.TryGetString(request, "ipaddress");
     ExtendField = MessageUtility.TryGetString(request, "extendfield");
 }
        public static string GetAccessToken(HttpRequestBase request)
        {
            var accessToken = MessageUtility.TryGetString(request, Protocal.ACCESS_TOKEN);

            if (String.IsNullOrEmpty(accessToken))
            {
                accessToken = MessageUtility.TryGetString(request, Protocal.ACCESSTOKEN);
            }

            if (String.IsNullOrEmpty(accessToken))
            {
                throw new OAuthException(AccessTokenRequestErrorCode.InvalidRequest, Protocal.ACCESS_TOKEN, 400);
            }

            return(accessToken);
        }
        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");
        }
Example #5
0
        public override void Parse(HttpRequestBase request)
        {
            base.Parse(request);

            PlatCode    = MessageUtility.GetInt64(request, "platcode");
            Browser     = MessageUtility.TryGetString(request, "browser");
            IpAddress   = MessageUtility.TryGetString(request, "ipaddress");
            ExtendField = MessageUtility.TryGetString(request, "extendfield");

            if (String.IsNullOrEmpty(Browser))
            {
                Browser = GetBrowser(request);
            }
            if (String.IsNullOrEmpty(IpAddress))
            {
                IpAddress = Projects.Tool.Http.IpAddress.GetIP();
            }
        }