示例#1
0
        private static void ThrowIfInvalidOptions(JwtIssuerSettings options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.ValidFor <= TimeSpan.Zero)
            {
                throw new ArgumentException("Must be a non-zero TimeSpan.", nameof(JwtIssuerSettings.ValidFor));
            }

            if (options.SigningCredentials == null)
            {
                throw new ArgumentNullException(nameof(JwtIssuerSettings.SigningCredentials));
            }

            if (options.JtiGenerator == null)
            {
                throw new ArgumentNullException(nameof(JwtIssuerSettings.JtiGenerator));
            }
        }
示例#2
0
 public JwtFactory(IJwtTokenHandler jwtTokenHandler, JwtIssuerSettings jwtIssuerSettings)
 {
     _jwtTokenHandler = jwtTokenHandler;
     _jwtOptions      = jwtIssuerSettings;
     ThrowIfInvalidOptions(_jwtOptions);
 }