// This method demonstrates loading configuration programmatically. // This is useful if you wish to store configuration in a custom database, for example. // Alternatively, configuration is loaded automatically from the saml.config file in the application's directory. private static void LoadSAMLConfigurationProgrammatically() { SAMLConfiguration samlConfiguration = new SAMLConfiguration(); samlConfiguration.IdentityProviderConfiguration = new IdentityProviderConfiguration() { Name = "urn:componentspace:ExampleIdentityProvider", CertificateFile = "idp.pfx", CertificatePassword = "******" }; samlConfiguration.AddPartnerServiceProvider( new PartnerServiceProviderConfiguration() { Name = "urn:componentspace:ExampleServiceProvider", WantAuthnRequestSigned = false, SignSAMLResponse = true, SignAssertion = false, EncryptAssertion = false, AssertionConsumerServiceUrl = "http://localhost/ExampleServiceProvider/SAML/AssertionConsumerService.aspx", SingleLogoutServiceUrl = "http://localhost/ExampleServiceProvider/SAML/SLOService.aspx", CertificateFile = "sp.cer" }); SAMLConfiguration.Current = samlConfiguration; }
// This method demonstrates loading configuration programmatically. // This is useful if you wish to store configuration in a custom database, for example. // Alternatively, configuration is loaded automatically from the saml.config file in the application's directory. private static void LoadSAMLConfigurationProgrammatically() { SAMLConfiguration samlConfiguration = new SAMLConfiguration(); samlConfiguration.IdentityProviderConfiguration = new IdentityProviderConfiguration() { Name = "urn:componentspace:ExampleIdentityProvider", CertificateFile = "idp.pfx", CertificatePassword = "******" }; samlConfiguration.AddPartnerServiceProvider( new PartnerServiceProviderConfiguration() { Name = "urn:componentspace:ExampleServiceProvider", WantAuthnRequestSigned = false, SignSAMLResponse = true, SignAssertion = false, EncryptAssertion = false, AssertionConsumerServiceUrl = "http://localhost/ExampleServiceProvider/SAML/AssertionConsumerService.aspx", SingleLogoutServiceUrl = "http://localhost/ExampleServiceProvider/SAML/SLOService.aspx", CertificateFile = "sp.cer" }); SAMLConfiguration.Current = samlConfiguration; }
// This method demonstrates loading configuration programmatically by calling the SAML configuration API. // Alternatively, configuration may be loaded programmatically by implementing the ISAMLConfigurationResolver interface. // Either of these approaches may be used if you wish to store configuration in a custom database, for example. // If not configured programmatically, configuration is loaded automatically from the saml.config file // in the application's directory. private static void LoadSAMLConfigurationProgrammatically() { SAMLConfiguration samlConfiguration = new SAMLConfiguration() { LocalIdentityProviderConfiguration = new LocalIdentityProviderConfiguration() { Name = "http://ExampleIdentityProvider", LocalCertificateFile = @"certificates\idp.pfx", LocalCertificatePassword = "******" } }; samlConfiguration.AddPartnerServiceProvider( new PartnerServiceProviderConfiguration() { Name = "http://ExampleServiceProvider", WantAuthnRequestSigned = true, SignSAMLResponse = true, AssertionConsumerServiceUrl = "http://*****:*****@"certificates\sp.cer" }); SAMLController.Configuration = samlConfiguration; }
// 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", LocalIdentityProviderConfiguration = new LocalIdentityProviderConfiguration() { Name = "http://ExampleIdentityProvider", LocalCertificates = new List <CertificateConfiguration>() { new CertificateConfiguration() { FileName = @"certificates\idp.pfx", Password = "******" } } } }; samlConfiguration.AddPartnerServiceProvider( new PartnerServiceProviderConfiguration() { Name = "http://ExampleServiceProvider", WantAuthnRequestSigned = true, SignSAMLResponse = true, AssertionConsumerServiceUrl = "http://*****:*****@"certificates\sp.cer" } } }); samlConfigurations.AddConfiguration(samlConfiguration); samlConfiguration = new SAMLConfiguration() { ID = "tenant2", LocalIdentityProviderConfiguration = new LocalIdentityProviderConfiguration() { Name = "http://ExampleIdentityProvider2", LocalCertificates = new List <CertificateConfiguration>() { new CertificateConfiguration() { FileName = @"certificates\idp2.pfx", Password = "******" } } } }; samlConfiguration.AddPartnerServiceProvider( new PartnerServiceProviderConfiguration() { Name = "http://ExampleServiceProvider2", WantAuthnRequestSigned = true, SignSAMLResponse = true, AssertionConsumerServiceUrl = "http://*****:*****@"certificates\sp2.cer" } } }); samlConfigurations.AddConfiguration(samlConfiguration); SAMLController.Configurations = samlConfigurations; }