public OperationResult RefreshAccessToken(string refreshToken, string clientID, string clientSecret)
        {
            //Check first if the registered application with specified clientid and clientsecret exists
            IFindRegisteredApplicationRepositoryExt registeredAppRepo = (IFindRegisteredApplicationRepositoryExt)RepositoryFactory.Create("Find.Tools.OAuthServerManager.RegisteredApplication");
            List <RegisteredApplication>            list = registeredAppRepo.FindByClientIDAndClientSecret(clientID, clientSecret);

            //If exists
            if (list != null && list.Count > 0)
            {
                //Check if the application has been authorized before by checking the access token previous existence
                IFindAccessTokenRepository accessTokenRepo = (IFindAccessTokenRepository)RepositoryFactory.Create("Find.Tools.OAuthServerManager.AccessToken");
                List <AccessToken>         accessTokenList = accessTokenRepo.FindByClientID(clientID);
                if (accessTokenList.Count == 0)
                {
                    return(new OperationResult(false, null, "Access token for client ID " + clientID + " does not exists. The application had never asked for authorization!"));
                }
                else
                {
                    AccessToken     newAccessToken = (AccessToken)CreateNewAccessToken(refreshToken, clientID, clientSecret).Data;
                    OperationResult result         = SaveNewccessToken(newAccessToken);
                    if (result.Result)
                    {
                        return(new OperationResult(true, newAccessToken, "New access token is created successfully!"));
                    }
                    else
                    {
                        return(result);
                    }
                }
            }
            else
            {
                return(new OperationResult(false, null, "Application for client ID " + clientID + " does not exists. Application is not registered!"));
            }
        }
Exemplo n.º 2
0
        public OperationResult CheckClientIDAndClientSecret(string clientID, string clientSecret)
        {
            IFindRegisteredApplicationRepositoryExt bs   = (IFindRegisteredApplicationRepositoryExt)RepositoryFactory.Create("Find.Tools.OAuthServerManager.RegisteredApplication");
            List <RegisteredApplication>            apps = bs.FindByClientIDAndClientSecret(clientID, clientSecret);

            if (apps.Count > 0)
            {
                return(new OperationResult(true));
            }
            else
            {
                return(new OperationResult(false));
            }
        }