Ejemplo n.º 1
0
 /// <summary>
 ///     The variables provider can be exchanged as long as the variables are not yet initialized
 /// </summary>
 public virtual void SetVariablesProvider(IVariablesProvider variablesProvider)
 {
     if (variables != null)
     {
         // already initialized
     }
     VariablesProvider = variablesProvider;
 }
 internal BewitTokenValidatorAccessor(
     ICryptographyService cryptographyService,
     IVariablesProvider variablesProvider,
     INonceRepository nonceRepository) :
     base(new BewitPayloadContext(typeof(T))
          .SetCryptographyService(() => cryptographyService)
          .SetVariablesProvider(() => variablesProvider)
          .SetRepository(() => nonceRepository))
 {
 }
Ejemplo n.º 3
0
 public BewitTokenGeneratorAccessor(
     TimeSpan tokenDuration,
     ICryptographyService cryptographyService,
     IVariablesProvider variablesProvider)
     : base(new BewitOptions {
     TokenDuration = tokenDuration
 },
            new BewitPayloadContext(typeof(T))
            .SetCryptographyService(() => cryptographyService)
            .SetVariablesProvider(() => variablesProvider)
            .SetRepository(() => new DefaultNonceRepository()))
 {
 }
Ejemplo n.º 4
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.º 5
0
        internal static TestServer CreateServer <T>(BewitOptions options)
        {
            NonceRepository   = new DefaultNonceRepository();
            VariablesProvider = new MockedVariablesProvider();

            IWebHostBuilder hostBuilder = new WebHostBuilder()
                                          .ConfigureServices(services =>
            {
                services.AddMvc();
                services
                .AddTransient <BewitAttribute>()
                .AddSingleton(options)
                .AddBewitValidation(options, b => b.AddPayload <T>()
                                    .SetVariablesProvider(() => VariablesProvider));
            })
                                          .Configure(app => app.UseRouting().UseEndpoints(c => c.MapControllers()));
            var server = new TestServer(hostBuilder);

            return(server);
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
 public WorkspaceVariableCompletionProvider(IVariablesProvider provider, IImageService imageService)
 {
     _variablesProvider = provider;
     _functionGlyph     = imageService.GetImage(ImageType.Method);
     _variableGlyph     = imageService.GetImage(ImageType.Variable);
 }
 public WorkspaceVariableCompletionProvider(IVariablesProvider provider, IGlyphService glyphService) {
     _variablesProvider = provider;
     _glyphService = glyphService;
 }
 public WorkspaceVariableCompletionProvider(IVariablesProvider provider, IGlyphService glyphService)
 {
     _variablesProvider = provider;
     _glyphService      = glyphService;
 }
Ejemplo n.º 10
0
 public VariableStore(IVariablesProvider provider, params IVariableStoreObserver[] observers)
 {
     VariablesProvider = provider;
     Observers         = new List <IVariableStoreObserver>();
     Observers.AddRange(observers);
 }
Ejemplo n.º 11
0
 public WorkspaceVariableCompletionProvider(ICoreShell shell, IVariablesProvider provider)
 {
     _shell             = shell;
     _variablesProvider = provider;
 }