示例#1
0
        public static StoredGrant CreateRefreshTokenHandle(string subject, Client client, Application application, IEnumerable <Claim> claims, IEnumerable <Scope> scopes, DateTime expiration)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }
            if (claims == null)
            {
                throw new ArgumentNullException("claims");
            }
            if (scopes == null)
            {
                throw new ArgumentNullException("scopes");
            }

            return(new StoredGrant
            {
                Type = StoredGrantType.RefreshTokenIdentifier,
                Subject = subject,
                Client = client,
                Application = application,
                ResourceOwner = claims.ToStoredGrantClaims().ToList(),
                Scopes = scopes.ToList(),
                Created = DateTime.UtcNow,
                Expiration = expiration
            });
        }
        public static StoredGrant CreateRefreshTokenHandle(
            string subject,
            Client client,
            Application application,
            IEnumerable<Claim> claims,
            IEnumerable<Scope> scopes,
            DateTime expiration,
            bool createRefreshToken = false)
        {
            if (client == null) throw new ArgumentNullException("client");
            if (application == null) throw new ArgumentNullException("application");
            if (claims == null) throw new ArgumentNullException("claims");
            if (scopes == null) throw new ArgumentNullException("scopes");

            return new StoredGrant
            {
                Type = StoredGrantType.RefreshTokenIdentifier,
                Subject = subject,
                Client = client,
                Application = application,
                ResourceOwner = claims.ToStoredGrantClaims().ToList(),
                Scopes = scopes.ToList(),
                Created = DateTime.UtcNow,
                Expiration = expiration,
                CreateRefreshToken = createRefreshToken
            };
        }
示例#3
0
        public static StoredGrant CreateAuthorizationCode(
            Client client,
            Application application,
            string redirectUri,
            IEnumerable <Claim> claims,
            IEnumerable <Scope> scopes,
            bool createRefreshToken,
            DateTime?refreshTokenExpiration = null,
            DateTime?expiration             = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }
            if (claims == null)
            {
                throw new ArgumentNullException("claims");
            }
            if (scopes == null)
            {
                throw new ArgumentNullException("scopes");
            }

            return(new StoredGrant
            {
                Type = StoredGrantType.AuthorizationCode,
                Client = client,
                Application = application,
                RedirectUri = redirectUri,
                ResourceOwner = claims.ToStoredGrantClaims().ToList(),
                Scopes = scopes.ToList(),
                Created = DateTime.UtcNow,
                Expiration = DateTime.UtcNow.AddHours(1),
                CreateRefreshToken = createRefreshToken,
                RefreshTokenExpiration = refreshTokenExpiration
            });
        }
        public static StoredGrant CreateAuthorizationCode(
            Client client, 
            Application application, 
            string redirectUri, 
            IEnumerable<Claim> claims, 
            IEnumerable<Scope> scopes, 
            bool createRefreshToken,
            DateTime? refreshTokenExpiration = null,
            DateTime? expiration = null)
        {
            if (client == null) throw new ArgumentNullException("client");
            if (application == null) throw new ArgumentNullException("application");
            if (claims == null) throw new ArgumentNullException("claims");
            if (scopes == null) throw new ArgumentNullException("scopes");

            return new StoredGrant
            {
                Type = StoredGrantType.AuthorizationCode,
                Client = client,
                Application = application,
                RedirectUri = redirectUri,
                ResourceOwner = claims.ToStoredGrantClaims().ToList(),
                Scopes = scopes.ToList(),
                Created = DateTime.UtcNow,
                Expiration = DateTime.UtcNow.AddHours(1),
                CreateRefreshToken = createRefreshToken,
                RefreshTokenExpiration = createRefreshToken ? refreshTokenExpiration : null
            };
        }