Exemplo n.º 1
0
        public static BankIdAuthenticationBuilder AddBankIdProdEnvironment(this BankIdAuthenticationBuilder builder)
        {
            builder.AddBankIdEnvironmentConfiguration(configuration =>
            {
                configuration.ApiBaseUrl = BankIdUrls.ProdApiBaseUrl;
            });

            return(builder);
        }
        public static AuthenticationBuilder AddBankId(this AuthenticationBuilder builder, Action <IBankIdAuthenticationBuilder> bankId)
        {
            builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton <IPostConfigureOptions <BankIdAuthenticationOptions>, BankIdAuthenticationPostConfigureOptions>());

            var bankIdAuthenticationBuilder = new BankIdAuthenticationBuilder(builder);

            bankIdAuthenticationBuilder.AddDefaultServices();
            bankId(bankIdAuthenticationBuilder);

            return(builder);
        }
Exemplo n.º 3
0
        public static BankIdAuthenticationBuilder AddBankIdRootCaCertificate(this BankIdAuthenticationBuilder builder, Func <X509Certificate2> configureRootCaCertificate)
        {
            builder.ConfigureBankIdHttpClientHandler(httpClientHandler =>
            {
                var rootCaCertificate = configureRootCaCertificate();
                var validator         = new X509CertificateChainValidator(rootCaCertificate);
                httpClientHandler.ServerCertificateCustomValidationCallback = validator.Validate;
            });

            return(builder);
        }
Exemplo n.º 4
0
        public static BankIdAuthenticationBuilder AddBankIdClientCertificate(this BankIdAuthenticationBuilder builder, Func <X509Certificate2> configureClientCertificate)
        {
            builder.ConfigureBankIdHttpClientHandler(httpClientHandler =>
            {
                var clientCertificate = configureClientCertificate();
                httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
                httpClientHandler.ClientCertificates.Add(clientCertificate);
            });

            return(builder);
        }
Exemplo n.º 5
0
        public static BankIdAuthenticationBuilder AddBankIdEnvironmentConfiguration(this BankIdAuthenticationBuilder builder, Action <BankIdEnvironmentConfiguration> configureBankIdEnvironment)
        {
            var configuration = new BankIdEnvironmentConfiguration();

            configureBankIdEnvironment(configuration);

            builder.ConfigureBankIdHttpClient(httpClient =>
            {
                httpClient.BaseAddress = configuration.ApiBaseUrl;
            });

            return(builder);
        }
Exemplo n.º 6
0
        public static BankIdAuthenticationBuilder AddBankIdRootCaCertificate(this BankIdAuthenticationBuilder builder, string certificateFilePath)
        {
            builder.AddBankIdRootCaCertificate(() => new X509Certificate2(certificateFilePath));

            return(builder);
        }