protected internal abstract void Add(ExtendedAuthenticationBuilder authenticationBuilder, IBankIdBuilder bankIdBuilder, string name, SchemeRegistrationOptions schemeRegistrationOptions);
Exemple #2
0
 public ExtendedAuthenticationScheme(string displayName, Type handlerType, string name, SchemeRegistrationOptions options) : base(name, displayName, handlerType)
 {
     this.Options = options;
 }
        public override void Add(ExtendedAuthenticationBuilder authenticationBuilder, string name, SchemeRegistrationOptions schemeRegistrationOptions)
        {
            base.Add(authenticationBuilder, name, schemeRegistrationOptions);

            authenticationBuilder.AddBankId(builder =>
            {
                var bankIdConfiguration = this.GetConfigurationOptions(authenticationBuilder, schemeRegistrationOptions);

                //builder.Configure(options => { this.Bind(configuration, options, schemeRegistrationOptions); });

                if (bankIdConfiguration.Environment == ActiveLoginEnvironment.Simulated)
                {
                    new BankIdBuilderWrapper(builder).UseSimulatedEnvironment(bankIdConfiguration.SimulatedPerson);
                }
                else
                {
                    if (bankIdConfiguration.Environment == ActiveLoginEnvironment.Test)
                    {
                        builder.UseTestEnvironment();
                    }
                    else
                    {
                        builder.UseProductionEnvironment();
                    }

                    this.ClientCertificate = this.GetCertificate(authenticationBuilder, bankIdConfiguration.ClientCertificate);
                    this.RootCertificate   = this.GetCertificate(authenticationBuilder, bankIdConfiguration.RootCertificate);

                    builder.UseClientCertificate(() => this.ClientCertificate);
                    builder.UseRootCaCertificate(() => this.RootCertificate);
                }

                builder.UseQrCoderQrCodeGenerator();

                this.Add(authenticationBuilder, builder, name, schemeRegistrationOptions);
            });
        }
        public override void Add(ExtendedAuthenticationBuilder authenticationBuilder, string name, SchemeRegistrationOptions schemeRegistrationOptions)
        {
            if (authenticationBuilder == null)
            {
                throw new ArgumentNullException(nameof(authenticationBuilder));
            }

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

            authenticationBuilder.AddCookie(name, schemeRegistrationOptions.DisplayName, options => { this.Bind(authenticationBuilder, options, schemeRegistrationOptions); });
        }
Exemple #5
0
        public override void Add(ExtendedAuthenticationBuilder authenticationBuilder, string name, SchemeRegistrationOptions schemeRegistrationOptions)
        {
            if (authenticationBuilder == null)
            {
                throw new ArgumentNullException(nameof(authenticationBuilder));
            }

            authenticationBuilder.Services.Configure <IISOptions>(options =>
            {
                options.AuthenticationDisplayName = schemeRegistrationOptions.DisplayName;
                options.AutomaticAuthentication   = false;

                this.Bind(authenticationBuilder, options, schemeRegistrationOptions);
            });

            authenticationBuilder.Services.Configure <IISServerOptions>(options =>
            {
                options.AuthenticationDisplayName = schemeRegistrationOptions.DisplayName;
                options.AutomaticAuthentication   = false;

                this.Bind(authenticationBuilder, options, schemeRegistrationOptions);
            });
        }
Exemple #6
0
 protected internal override void Add(ExtendedAuthenticationBuilder authenticationBuilder, IGrandIdBuilder grandIdBuilder, string name, SchemeRegistrationOptions schemeRegistrationOptions)
 {
     // ReSharper disable AssignNullToNotNullAttribute
     grandIdBuilder.AddBankIdSameDevice(name, schemeRegistrationOptions?.DisplayName, options => { this.Bind(authenticationBuilder, options, schemeRegistrationOptions); });
     // ReSharper restore AssignNullToNotNullAttribute
 }
        public override void Add(ExtendedAuthenticationBuilder authenticationBuilder, string name, SchemeRegistrationOptions schemeRegistrationOptions)
        {
            base.Add(authenticationBuilder, name, schemeRegistrationOptions);

            authenticationBuilder.AddGrandId(builder =>
            {
                var grandIdConfiguration = this.GetConfigurationOptions(authenticationBuilder, schemeRegistrationOptions);

                // ReSharper disable ConvertIfStatementToSwitchStatement
                if (grandIdConfiguration.Environment == ActiveLoginEnvironment.Simulated)
                {
                    new GrandIdBuilderWrapper(builder).UseSimulatedEnvironment(grandIdConfiguration.SimulatedPerson);
                }
                else
                {
                    if (grandIdConfiguration.Environment == ActiveLoginEnvironment.Test)
                    {
                        builder.UseTestEnvironment(environmentConfiguration => this.Bind(authenticationBuilder, environmentConfiguration, schemeRegistrationOptions));
                    }
                    else
                    {
                        builder.UseProductionEnvironment(environmentConfiguration => this.Bind(authenticationBuilder, environmentConfiguration, schemeRegistrationOptions));
                    }
                }
                // ReSharper restore ConvertIfStatementToSwitchStatement

                this.Add(authenticationBuilder, builder, name, schemeRegistrationOptions);
            });
        }
 public abstract void Add(ExtendedAuthenticationBuilder authenticationBuilder, string name, SchemeRegistrationOptions schemeRegistrationOptions);
        protected internal virtual void Bind(ExtendedAuthenticationBuilder authenticationBuilder, object instance, SchemeRegistrationOptions schemeRegistrationOptions)
        {
            if (authenticationBuilder == null)
            {
                throw new ArgumentNullException(nameof(authenticationBuilder));
            }

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

            foreach (var path in schemeRegistrationOptions.CommonOptionsPaths)
            {
                authenticationBuilder.Configuration.GetSection(path)?.Bind(instance);
            }

            schemeRegistrationOptions.Options?.Bind(instance);
        }
Exemple #10
0
        public override void Add(ExtendedAuthenticationBuilder authenticationBuilder, string name, SchemeRegistrationOptions schemeRegistrationOptions)
        {
            if (authenticationBuilder == null)
            {
                throw new ArgumentNullException(nameof(authenticationBuilder));
            }

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

            //authenticationBuilder.Services.Configure<CertificateAuthenticationOptions>(name, options => { this.Bind(configuration, options, schemeRegistrationOptions); });

            authenticationBuilder.AddCertificate(name, schemeRegistrationOptions.DisplayName, options => { this.Bind(authenticationBuilder, options, schemeRegistrationOptions); });
        }