Exemplo n.º 1
0
        public UmaFilter(IIdentityServerClientFactory identityServerClientFactory, IIdentityServerUmaClientFactory identityServerUmaClientFactory,
                         IDataProtectionProvider dataProtectionProvider, IHierarchicalResourceClientFactory resourceManagerClientFactory, IJwsParser jwsParser, UmaFilterOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

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

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

            _options = options;
            _identityServerClientFactory    = identityServerClientFactory;
            _identityServerUmaClientFactory = identityServerUmaClientFactory;
            _resourceManagerClientFactory   = resourceManagerClientFactory;
            _dataProtector = dataProtectionProvider.CreateProtector("UmaFilter");
            _jwsParser     = jwsParser;
        }
        public static IServiceCollection AddUmaFilter(this IServiceCollection services, UmaFilterOptions options)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

            services.AddSingleton(options);
            services.AddTransient <UmaFilter>();
            return(services);
        }