Exemplo n.º 1
0
        public Stream UserInfo()
        {
            OperationResult resultAccessToken = CheckAccessTokenHeader();

            if (resultAccessToken.Result)
            {
                AccessToken accestoken = (AccessToken)resultAccessToken.Data;

                IOAuthLoginBusinessService businessService = (IOAuthLoginBusinessService)BusinessFactory.Create("Tools.OAuthServerManager.OAuthLogin");
                OperationResult            result          = businessService.GetAuthenticationServer(accestoken.ClientID);
                string authserver = (string)result.Data;

                resultAccessToken = businessService.QueryAuthenticationServerAskForUserInfo(authserver, accestoken.UserID);
            }

            return(resultAccessToken.ToJsonStream());
        }
Exemplo n.º 2
0
        public Stream HandleOAuthLogin(OAuthLoginForm loginForm)
        {
            IOAuthLoginBusinessService businessService = (IOAuthLoginBusinessService)BusinessFactory.Create("Tools.OAuthServerManager.OAuthLogin");
            OperationResult            result          = businessService.CheckAuthenticationSession(loginForm);

            if (result.Result)
            {
                result = businessService.GetAuthenticationServer(loginForm.ClientID);
                if (result.Result)
                {
                    //RegisteredApplication app = (RegisteredApplication)result.Data;
                    result = businessService.QueryAuthenticationServer((string)result.Data, loginForm.Username, loginForm.Password);
                    if (result.Result)
                    {
                        result = businessService.GenerateAuthorizationCode(result, loginForm.Username, loginForm.ClientID, loginForm.AuthorizationSessionID);
                        businessService.SaveAuthorizationCode((AuthenticationCode)result.Data);
                        result = businessService.CallCallbackUrlWithAuthorizationResult(loginForm.ClientID, ((AuthenticationCode)result.Data).AuthenticationCodeString);
                    }
                }
            }

            return(result.ToJsonStream());
        }