示例#1
0
        private static SAMLConfiguration LoadSAMLConfiguration()
        {
            Console.Write("SAML configuration file to export [saml.config]: ");
            string fileName = Console.ReadLine();

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = "saml.config";
            }

            if (!File.Exists(fileName))
            {
                throw new ArgumentException(string.Format("The configuration file {0} doesn't exist.", fileName));
            }

            SAMLConfigurations samlConfigurations = SAMLConfigurationFile.Load(fileName);

            if (samlConfigurations.Configurations.Count == 1)
            {
                return(samlConfigurations.Configurations[0]);
            }

            Console.Write("SAML configuration ID [None]: ");
            string configurationID = Console.ReadLine();

            return(samlConfigurations.GetConfiguration(configurationID));
        }
示例#2
0
        // This method demonstrates loading multi-tenanted configuration programmatically by calling the SAML configuration API.
        // Alternatively, configuration is loaded automatically from the multi-tenanted saml.config file in the application's directory.
        private static void LoadMultiTenantedSAMLConfigurationProgrammatically()
        {
            SAMLConfigurations samlConfigurations = new SAMLConfigurations();

            SAMLConfiguration samlConfiguration = new SAMLConfiguration()
            {
                ID = "tenant1",

                LocalServiceProviderConfiguration = new LocalServiceProviderConfiguration()
                {
                    Name = "http://ExampleServiceProvider",
                    AssertionConsumerServiceUrl = "~/SAML/AssertionConsumerService.aspx",
                    LocalCertificateFile        = @"certificates\sp.pfx",
                    LocalCertificatePassword    = "******"
                }
            };

            samlConfiguration.AddPartnerIdentityProvider(
                new PartnerIdentityProviderConfiguration()
            {
                Name                   = "http://ExampleIdentityProvider",
                SignAuthnRequest       = true,
                SingleSignOnServiceUrl = "http://*****:*****@"certificates\idp.cer"
            });

            samlConfigurations.AddConfiguration(samlConfiguration);

            samlConfiguration = new SAMLConfiguration()
            {
                ID = "tenant2",

                LocalServiceProviderConfiguration = new LocalServiceProviderConfiguration()
                {
                    Name = "http://ExampleServiceProvider2",
                    AssertionConsumerServiceUrl = "~/SAML/AssertionConsumerService.aspx",
                    LocalCertificateFile        = @"certificates\sp2.pfx",
                    LocalCertificatePassword    = "******"
                }
            };

            samlConfiguration.AddPartnerIdentityProvider(
                new PartnerIdentityProviderConfiguration()
            {
                Name                   = "http://ExampleIdentityProvider2",
                SignAuthnRequest       = true,
                SingleSignOnServiceUrl = "http://*****:*****@"certificates\idp2.cer"
            });

            samlConfigurations.AddConfiguration(samlConfiguration);

            SAMLController.Configurations = samlConfigurations;
        }