public WsTrustTokenValidationParametersFactory(
     IdentityProviderProvider identityProviders,
     RelyingPartyProvider relyingParties,
     IHttpContextAccessor httpContextAccessor,
     ILogger <WsTrustTokenValidationParametersFactory> logger,
     IOptionsMonitor <WsTrustOptions> monitor)
 {
     _identityProviders   = identityProviders;
     _relyingParties      = relyingParties;
     _httpContextAccessor = httpContextAccessor;
     _logger             = logger;
     _options            = monitor.CurrentValue;
     _optionsChangeToken = monitor.OnChange((options, _) => _options = options);
 }
コード例 #2
0
 protected WsTrustService(
     ILogger logger,
     SecurityTokenServiceFactory stsFactory,
     ISoapContextAccessor soapContextAccessor,
     WsTrustSerializerFactory serializerFactory,
     IOptionsMonitor <WsTrustOptions> monitor
     )
 {
     _logger              = logger;
     _stsFactory          = stsFactory;
     _soapContextAccessor = soapContextAccessor;
     _serializerFactory   = serializerFactory;
     _options             = monitor.CurrentValue;
 }
コード例 #3
0
        private void UpdateSecurityTokenHandlers(WsTrustOptions options)
        {
            var handlersByTokenTypeIdentifier = new Dictionary <string, SecurityTokenHandler>();
            var handlersByType = new Dictionary <Type, SecurityTokenHandler>();

            foreach (var descriptor in options.SecurityTokenHandlers)
            {
                var handler = descriptor.Factory(_services);
                if (!(handler is AsyncSecurityTokenHandler))
                {
                    // TODO: Remove wrapper if/when our PR for CanWriteSecurityToken default implementation gets accepted and released.
                    // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/pull/1438
                    handler = new SecurityTokenHandlerWrapper(handler);
                }
                handlersByType.Add(handler.TokenType, handler);
                foreach (var identifier in descriptor.TokenTypeIdentifiers)
                {
                    handlersByTokenTypeIdentifier.Add(identifier, handler);
                }
            }

            _handlersByType = new ReadOnlyDictionary <Type, SecurityTokenHandler>(handlersByType);
            _handlersByTokenTypeIdentifier = new ReadOnlyDictionary <string, SecurityTokenHandler>(handlersByTokenTypeIdentifier);
        }