Ejemplo n.º 1
0
 public NonceService(
     INonceRepository nonceRepository,
     IOptions <ServerOptions> options)
     : base(options)
 {
     NonceRepository = nonceRepository
                       ?? throw new ArgumentNullException(nameof(nonceRepository));
 }
 internal BewitTokenValidatorAccessor(
     ICryptographyService cryptographyService,
     IVariablesProvider variablesProvider,
     INonceRepository nonceRepository) :
     base(new BewitPayloadContext(typeof(T))
          .SetCryptographyService(() => cryptographyService)
          .SetVariablesProvider(() => variablesProvider)
          .SetRepository(() => nonceRepository))
 {
 }
Ejemplo n.º 3
0
        public BewitTokenValidator(BewitPayloadContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _cryptographyService = context.CreateCryptographyService?.Invoke()
                                   ?? throw new ArgumentNullException(nameof(BewitPayloadContext.CreateCryptographyService));
            _variablesProvider = context.CreateVariablesProvider?.Invoke()
                                 ?? throw new ArgumentNullException(nameof(BewitPayloadContext.CreateVariablesProvider));
            _repository = context.CreateRepository?.Invoke()
                          ?? throw new ArgumentNullException(nameof(BewitPayloadContext.CreateRepository));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RequestsSignatureValidationService"/> class.
 /// </summary>
 /// <param name="options">The <see cref="RequestsSignatureOptions"/>.</param>
 /// <param name="signatureBodySourceBuilder">The <see cref="ISignatureBodySourceBuilder"/>.</param>
 /// <param name="signatureBodySigner">The <see cref="ISignatureBodySigner"/>.</param>
 /// <param name="clock">The <see cref="ISystemClock"/> instance for time retrieval. Defaults to <see cref="SystemClock"/>.</param>
 /// <param name="nonceRepository">The <see cref="INonceRepository"/> to use. Defaults to <see cref="NullNonceRepository"/>.</param>
 /// <param name="logger">The <see cref="ILogger"/> to use. Defaults to <see cref="NullLogger"/>.</param>
 public RequestsSignatureValidationService(
     IOptionsMonitor <RequestsSignatureOptions> options,
     ISignatureBodySourceBuilder signatureBodySourceBuilder,
     ISignatureBodySigner signatureBodySigner,
     ISystemClock clock = null,
     INonceRepository nonceRepository = null,
     ILogger <RequestsSignatureValidationService> logger = null)
 {
     _optionsMonitor             = options ?? throw new ArgumentNullException(nameof(options));
     _signatureBodySourceBuilder = signatureBodySourceBuilder ?? throw new ArgumentNullException(nameof(signatureBodySourceBuilder));
     _signatureBodySigner        = signatureBodySigner ?? throw new ArgumentNullException(nameof(signatureBodySigner));
     _clock           = clock ?? new SystemClock();
     _nonceRepository = nonceRepository ?? NullNonceRepository.Instance;
     _logger          = (ILogger)logger ?? NullLogger.Instance;
     _optionsMonitor.OnChange(OnOptionsChange);
     OnOptionsChange(_optionsMonitor.CurrentValue);
 }
Ejemplo n.º 5
0
        public BewitTokenGenerator(
            BewitOptions options,
            BewitPayloadContext context)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _tokenDuration       = options.TokenDuration;
            _cryptographyService = context.CreateCryptographyService?.Invoke()
                                   ?? throw new ArgumentNullException(nameof(BewitPayloadContext.CreateCryptographyService));
            _variablesProvider = context.CreateVariablesProvider?.Invoke()
                                 ?? throw new ArgumentNullException(nameof(BewitPayloadContext.CreateVariablesProvider));
            _repository = context.CreateRepository?.Invoke()
                          ?? throw new ArgumentNullException(nameof(BewitPayloadContext.CreateRepository));
        }