예제 #1
0
        public static void AddAuthenticator(this IServiceCollection services, AuthenticatorServiceOptions configureOptions)
        {
            configureOptions.CheckArgumentNull(nameof(configureOptions));

            services.TryAddSingleton(Options.Create(configureOptions));
            services.TryAddSingleton <ISystemTime, DefaultSystemTime>();
            services.TryAddSingleton <IAuthenticatorService, AuthenticatorService>();
        }
예제 #2
0
        public static void AddAuthenticator(this IServiceCollection services, Action <AuthenticatorServiceOptions> configuration)
        {
            configuration.CheckArgumentNull(nameof(configuration));

            var configureOptions = new AuthenticatorServiceOptions();

            configuration(configureOptions);

            AddAuthenticator(services, configureOptions);
        }
예제 #3
0
        public AuthenticatorService(IOptions <AuthenticatorServiceOptions> options, ISystemTime systemTime)
        {
            options.CheckArgumentNull(nameof(options));
            systemTime.CheckArgumentNull(nameof(systemTime));

            options.Value.Issuer.CheckMandatoryOption(nameof(options.Value.Issuer));

            if (options.Value.NumberOfDigits < 6 || options.Value.NumberOfDigits > 8)
            {
                throw new ArgumentException(Resources.Exception_InvalidNumberOfDigits);
            }

            if (options.Value.PeriodInSeconds < 30)
            {
                throw new ArgumentException(Resources.Exception_InvalidPeriodInSeconds);
            }

            _options    = options.Value;
            _systemTime = systemTime;
        }