예제 #1
0
 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");
 }
예제 #2
0
        public ServerAccessGrant TryGetToken(HttpContextBase context)
        {
            Arguments.NotNull(context, "context");

            var accessToken = MessageUtility.ParseAccessToken(context.Request);

            if (!String.IsNullOrEmpty(accessToken))
            {
                return(GetServerAccessGrant(accessToken));
            }
            return(null);
        }
예제 #3
0
        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);
        }
예제 #4
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");
        }
예제 #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();
            }
        }
예제 #6
0
        public AuthCodeRequest Authorize(HttpContextBase context)
        {
            Arguments.NotNull(context, "context");

            var codeRequest = MessageUtility.ParseAuthCodeRequest(context.Request);
            var client      = GetClientAuth(codeRequest.ClientId);

            if (client == null)
            {
                OAuthError(AccessTokenRequestErrorCode.InvoidClient, "client id invalid.");
            }
            if (client.Status != ClientAuthStatus.Enabled)
            {
                OAuthError(AccessTokenRequestErrorCode.UnauthorizedClient, "client unauthorized", 401);
            }

            client.ValidateCallbackUri(codeRequest.RedirectUri);
            return(codeRequest);
        }
예제 #7
0
 public virtual void Parse(HttpRequestBase request)
 {
     ClientId     = MessageUtility.GetInt32(request, Protocal.CLIENT_ID);
     ClientSecret = MessageUtility.GetString(request, Protocal.CLIENT_SECRET);
 }
예제 #8
0
 public override void Parse(HttpRequestBase request)
 {
     base.Parse(request);
     Code        = MessageUtility.GetString(request, Protocal.CODE);
     RedirectUri = new Uri(MessageUtility.GetString(request, Protocal.REDIRECT_URI));
 }
예제 #9
0
 public override void Parse(HttpRequestBase request)
 {
     base.Parse(request);
     UserName = MessageUtility.GetString(request, Protocal.USER_NAME);
     Password = MessageUtility.GetString(request, Protocal.PASSWORD);
 }