Search in sources :

Example 1 with IdentityZoneConfigurationBootstrap

use of org.cloudfoundry.identity.uaa.impl.config.IdentityZoneConfigurationBootstrap in project uaa by cloudfoundry.

the class IdentityZoneConfigurationBootstrapTests method configureProvisioning.

@BeforeEach
public void configureProvisioning(@Autowired JdbcTemplate jdbcTemplate) {
    TestUtils.cleanAndSeedDb(jdbcTemplate);
    provisioning = new JdbcIdentityZoneProvisioning(jdbcTemplate);
    bootstrap = new IdentityZoneConfigurationBootstrap(provisioning);
    GeneralMfaProviderValidator mfaProviderValidator = new GeneralMfaProviderValidator();
    MfaProviderProvisioning mfaProvisoning = new JdbcMfaProviderProvisioning(jdbcTemplate, mfaProviderValidator);
    MfaProvider<GoogleMfaProviderConfig> provider = new MfaProvider<>();
    provider.setName("testProvider");
    provider.setType(MfaProvider.MfaProviderType.GOOGLE_AUTHENTICATOR);
    provider.setConfig(new GoogleMfaProviderConfig());
    provider.setIdentityZoneId("uaa");
    mfaProvisoning.create(provider, "uaa");
    MfaConfigValidator mfaConfigValidator = new MfaConfigValidator(mfaProvisoning);
    GeneralIdentityZoneConfigurationValidator configValidator = new GeneralIdentityZoneConfigurationValidator(mfaConfigValidator);
    validator = new GeneralIdentityZoneValidator(configValidator);
    bootstrap.setValidator(validator);
    // For the SamlTestUtils keys we are using.
    Security.addProvider(new BouncyCastleProvider());
}
Also used : MfaProvider(org.cloudfoundry.identity.uaa.mfa.MfaProvider) JdbcMfaProviderProvisioning(org.cloudfoundry.identity.uaa.mfa.JdbcMfaProviderProvisioning) IdentityZoneConfigurationBootstrap(org.cloudfoundry.identity.uaa.impl.config.IdentityZoneConfigurationBootstrap) GeneralIdentityZoneConfigurationValidator(org.cloudfoundry.identity.uaa.zone.GeneralIdentityZoneConfigurationValidator) MfaProviderProvisioning(org.cloudfoundry.identity.uaa.mfa.MfaProviderProvisioning) JdbcMfaProviderProvisioning(org.cloudfoundry.identity.uaa.mfa.JdbcMfaProviderProvisioning) GeneralIdentityZoneValidator(org.cloudfoundry.identity.uaa.zone.GeneralIdentityZoneValidator) GoogleMfaProviderConfig(org.cloudfoundry.identity.uaa.mfa.GoogleMfaProviderConfig) JdbcIdentityZoneProvisioning(org.cloudfoundry.identity.uaa.zone.JdbcIdentityZoneProvisioning) MfaConfigValidator(org.cloudfoundry.identity.uaa.zone.MfaConfigValidator) GeneralMfaProviderValidator(org.cloudfoundry.identity.uaa.mfa.GeneralMfaProviderValidator) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with IdentityZoneConfigurationBootstrap

use of org.cloudfoundry.identity.uaa.impl.config.IdentityZoneConfigurationBootstrap in project uaa by cloudfoundry.

the class BootstrapTests method xlegacyTestDeprecatedProperties.

@Test
void xlegacyTestDeprecatedProperties() {
    context = getServletContext(null, "test/bootstrap/deprecated_properties_still_work.yml");
    ScimGroupProvisioning scimGroupProvisioning = context.getBean("scimGroupProvisioning", ScimGroupProvisioning.class);
    List<ScimGroup> scimGroups = scimGroupProvisioning.retrieveAll(IdentityZoneHolder.get().getId());
    assertThat(scimGroups, PredicateMatcher.has(g -> g.getDisplayName().equals("pony") && "The magic of friendship".equals(g.getDescription())));
    assertThat(scimGroups, PredicateMatcher.has(g -> g.getDisplayName().equals("cat") && "The cat".equals(g.getDescription())));
    IdentityZoneConfigurationBootstrap zoneBootstrap = context.getBean(IdentityZoneConfigurationBootstrap.class);
    assertEquals("https://deprecated.home_redirect.com", zoneBootstrap.getHomeRedirect());
    IdentityZone defaultZone = context.getBean(IdentityZoneProvisioning.class).retrieve("uaa");
    IdentityZoneConfiguration defaultConfig = defaultZone.getConfig();
    assertTrue(defaultConfig.getSamlConfig().getKeys().containsKey(SamlConfig.LEGACY_KEY_ID), "Legacy SAML keys should be available");
    assertEquals(SamlLoginServerKeyManagerTests.CERTIFICATE.trim(), defaultConfig.getSamlConfig().getCertificate().trim());
    assertEquals(SamlLoginServerKeyManagerTests.KEY.trim(), defaultConfig.getSamlConfig().getPrivateKey().trim());
    assertEquals(SamlLoginServerKeyManagerTests.PASSWORD.trim(), defaultConfig.getSamlConfig().getPrivateKeyPassword().trim());
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) SAMLDefaultLogger(org.springframework.security.saml.log.SAMLDefaultLogger) Arrays(java.util.Arrays) IdentityZoneProvisioning(org.cloudfoundry.identity.uaa.zone.IdentityZoneProvisioning) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) SamlIdentityProviderDefinition(org.cloudfoundry.identity.uaa.provider.SamlIdentityProviderDefinition) Scanner(java.util.Scanner) ResourceEntityResolver(org.springframework.beans.factory.xml.ResourceEntityResolver) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) IdentityZoneConfigurationBootstrap(org.cloudfoundry.identity.uaa.impl.config.IdentityZoneConfigurationBootstrap) ScimGroupProvisioning(org.cloudfoundry.identity.uaa.scim.ScimGroupProvisioning) IdentityZoneHolder(org.cloudfoundry.identity.uaa.zone.IdentityZoneHolder) ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) SpringProfileCleanupExtension(org.cloudfoundry.identity.uaa.extensions.SpringProfileCleanupExtension) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) YamlServletProfileInitializer(org.cloudfoundry.identity.uaa.impl.config.YamlServletProfileInitializer) MockServletContext(org.springframework.mock.web.MockServletContext) ViewResolver(org.springframework.web.servlet.ViewResolver) PollutionPreventionExtension(org.cloudfoundry.identity.uaa.extensions.PollutionPreventionExtension) IdentityZoneConfiguration(org.cloudfoundry.identity.uaa.zone.IdentityZoneConfiguration) XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) MockRequestDispatcher(org.springframework.mock.web.MockRequestDispatcher) RequestDispatcher(javax.servlet.RequestDispatcher) Set(java.util.Set) BeansException(org.springframework.beans.BeansException) BootstrapSamlIdentityProviderData(org.cloudfoundry.identity.uaa.provider.saml.BootstrapSamlIdentityProviderData) AbstractRefreshableWebApplicationContext(org.springframework.web.context.support.AbstractRefreshableWebApplicationContext) Collectors(java.util.stream.Collectors) File(java.io.File) PredicateMatcher(org.cloudfoundry.identity.uaa.util.PredicateMatcher) Test(org.junit.jupiter.api.Test) EventListener(java.util.EventListener) List(java.util.List) IdentityZone(org.cloudfoundry.identity.uaa.zone.IdentityZone) BeforeAllCallback(org.junit.jupiter.api.extension.BeforeAllCallback) AfterAllCallback(org.junit.jupiter.api.extension.AfterAllCallback) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) NonNull(org.springframework.lang.NonNull) MockServletConfig(org.springframework.mock.web.MockServletConfig) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) SamlConfig(org.cloudfoundry.identity.uaa.zone.SamlConfig) StringUtils(org.springframework.util.StringUtils) IdentityZone(org.cloudfoundry.identity.uaa.zone.IdentityZone) IdentityZoneProvisioning(org.cloudfoundry.identity.uaa.zone.IdentityZoneProvisioning) IdentityZoneConfigurationBootstrap(org.cloudfoundry.identity.uaa.impl.config.IdentityZoneConfigurationBootstrap) ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup) ScimGroupProvisioning(org.cloudfoundry.identity.uaa.scim.ScimGroupProvisioning) IdentityZoneConfiguration(org.cloudfoundry.identity.uaa.zone.IdentityZoneConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

IdentityZoneConfigurationBootstrap (org.cloudfoundry.identity.uaa.impl.config.IdentityZoneConfigurationBootstrap)2 File (java.io.File)1 Arrays (java.util.Arrays)1 EventListener (java.util.EventListener)1 List (java.util.List)1 Scanner (java.util.Scanner)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)1 PollutionPreventionExtension (org.cloudfoundry.identity.uaa.extensions.PollutionPreventionExtension)1 SpringProfileCleanupExtension (org.cloudfoundry.identity.uaa.extensions.SpringProfileCleanupExtension)1 YamlServletProfileInitializer (org.cloudfoundry.identity.uaa.impl.config.YamlServletProfileInitializer)1 GeneralMfaProviderValidator (org.cloudfoundry.identity.uaa.mfa.GeneralMfaProviderValidator)1 GoogleMfaProviderConfig (org.cloudfoundry.identity.uaa.mfa.GoogleMfaProviderConfig)1 JdbcMfaProviderProvisioning (org.cloudfoundry.identity.uaa.mfa.JdbcMfaProviderProvisioning)1 MfaProvider (org.cloudfoundry.identity.uaa.mfa.MfaProvider)1 MfaProviderProvisioning (org.cloudfoundry.identity.uaa.mfa.MfaProviderProvisioning)1 SamlIdentityProviderDefinition (org.cloudfoundry.identity.uaa.provider.SamlIdentityProviderDefinition)1 BootstrapSamlIdentityProviderData (org.cloudfoundry.identity.uaa.provider.saml.BootstrapSamlIdentityProviderData)1