}                                                 //injected by IOC

        public T Authorize <T>(OAuth2.DataModels.Client Client = null, OAuth2.DataModels.ResourceOwner Owner = null, string Scope = "")
            where T : DataModels.Token, new()
        {
            T token = TokenModel.InsertToken <T>(
                TokenHelper.CreateAccessToken(), DataModels.TokenTypes.bearer, 3600, DateTime.UtcNow.GetTotalSeconds(), Client, Scope, Owner);

            if (token == null)
            {
                throw new OAuth2.DataModels.TokenRequestError(DataModels.ErrorCodes.server_error, "Unable to store access token");
            }
            return(token);
        }
 public T InsertToken <T>(string AccessToken, OAuth2.DataModels.TokenTypes TokenType, long ExpiresIn, long IssuedTime, OAuth2.DataModels.Client Client, IEnumerable <OAuth2.DataModels.Scope> Scope, OAuth2.DataModels.ResourceOwner ResourceOwner = null, string RefreshToken = null)
     where T : OAuth2.DataModels.Token, new()
 {
     return(InsertToken <T>(AccessToken, TokenType, ExpiresIn, IssuedTime, Client, Scope.ToScopeString(), ResourceOwner, RefreshToken));
 }
 public T InsertToken <T>(string AccessToken, OAuth2.DataModels.TokenTypes TokenType, long ExpiresIn, long IssuedTime, OAuth2.DataModels.Client Client, string Scope = "", OAuth2.DataModels.ResourceOwner ResourceOwner = null, string RefreshToken = null)
     where T : OAuth2.DataModels.Token, new()
 {
     return(InsertToken <T>(AccessToken, TokenType, ExpiresIn, IssuedTime, Client.id, Scope, ResourceOwner == null ? "" : ResourceOwner.id, RefreshToken));
 }
Exemple #4
0
        public T InsertToken <T>(string AccessToken, OAuth2.DataModels.TokenTypes TokenType, long ExpiresIn, long IssuedTime, OAuth2.DataModels.Client Client, IEnumerable <OAuth2.DataModels.Scope> Scope, OAuth2.DataModels.ResourceOwner ResourceOwner = null, string RefreshToken = null) where T : OAuth2.DataModels.Token, new()
        {
            if (CacheTokenModel == null && DBTokenModel == null)
            {
                return(null);
            }

            T val = null;

            if (CacheTokenModel != null)
            {
                val = CacheTokenModel.InsertToken <T>(AccessToken, TokenType, ExpiresIn, IssuedTime, Client, Scope, ResourceOwner, RefreshToken);
            }
            if (DBTokenModel != null)
            {
                val = DBTokenModel.InsertToken <T>(AccessToken, TokenType, ExpiresIn, IssuedTime, Client, Scope, ResourceOwner, RefreshToken);
            }
            return(val);
        }