use of org.cloudfoundry.identity.uaa.provider.JdbcIdentityProviderProvisioning in project uaa by cloudfoundry.
the class CheckIdpEnabledAuthenticationManagerTest method setupAuthManager.
@BeforeEach
void setupAuthManager(@Autowired JdbcTemplate jdbcTemplate) {
TestUtils.cleanAndSeedDb(jdbcTemplate);
identityProviderProvisioning = new JdbcIdentityProviderProvisioning(jdbcTemplate);
MockUaaUserDatabase userDatabase = new MockUaaUserDatabase(u -> u.withId("id").withUsername("marissa").withEmail("test@test.org").withVerified(true).withPassword("koala"));
PasswordEncoder encoder = mock(PasswordEncoder.class);
when(encoder.matches(anyString(), anyString())).thenReturn(true);
AuthzAuthenticationManager authzAuthenticationManager = new AuthzAuthenticationManager(userDatabase, encoder, identityProviderProvisioning, null);
authzAuthenticationManager.setOrigin(OriginKeys.UAA);
AccountLoginPolicy mockAccountLoginPolicy = mock(AccountLoginPolicy.class);
when(mockAccountLoginPolicy.isAllowed(any(), any())).thenReturn(true);
authzAuthenticationManager.setAccountLoginPolicy(mockAccountLoginPolicy);
manager = new CheckIdpEnabledAuthenticationManager(authzAuthenticationManager, OriginKeys.UAA, identityProviderProvisioning);
token = new UsernamePasswordAuthenticationToken("marissa", "koala");
}
use of org.cloudfoundry.identity.uaa.provider.JdbcIdentityProviderProvisioning in project uaa by cloudfoundry.
the class IdentityProviderBootstrapTest method setup.
@BeforeEach
void setup() throws Exception {
samlIdentityProviderDefinition = new SamlIdentityProviderDefinition();
samlIdentityProviderDefinition.setAssertionConsumerIndex(0);
samlIdentityProviderDefinition.setIconUrl("iconUrl");
samlIdentityProviderDefinition.setIdpEntityAlias("alias");
samlIdentityProviderDefinition.setLinkText("text");
samlIdentityProviderDefinition.setMetaDataLocation("http://location");
samlIdentityProviderDefinition.setNameID("nameId");
samlIdentityProviderDefinition.setShowSamlLink(true);
samlIdentityProviderDefinition.setMetadataTrustCheck(true);
samlIdentityProviderDefinition1 = samlIdentityProviderDefinition.clone();
samlIdentityProviderDefinition1.setIdpEntityAlias("alias2");
samlIdentityProviderDefinition1.setMetaDataLocation("http://location2");
oauthProvider = new RawExternalOAuthIdentityProviderDefinition();
setCommonProperties(oauthProvider);
oidcProvider = new OIDCIdentityProviderDefinition();
setCommonProperties(oidcProvider);
oauthProviderConfig = new HashMap<>();
oauthProviderConfig.put(OAUTH20, oauthProvider);
oauthProviderConfig.put(OIDC10, oidcProvider);
configurator = mock(BootstrapSamlIdentityProviderData.class);
publisher = mock(ApplicationEventPublisher.class);
provisioning = new JdbcIdentityProviderProvisioning(jdbcTemplate);
environment = new MockEnvironment();
bootstrap = new IdentityProviderBootstrap(provisioning, environment);
bootstrap.setApplicationEventPublisher(publisher);
}
use of org.cloudfoundry.identity.uaa.provider.JdbcIdentityProviderProvisioning in project uaa by cloudfoundry.
the class LoginSamlAuthenticationProviderTests method configureProvider.
@BeforeEach
void configureProvider() throws SAMLException, SecurityException, DecryptionException, ValidationException {
identityZoneManager = new IdentityZoneManagerImpl();
RequestContextHolder.resetRequestAttributes();
MockHttpServletRequest request = new MockHttpServletRequest(mock(ServletContext.class));
MockHttpServletResponse response = new MockHttpServletResponse();
ServletWebRequest servletWebRequest = new ServletWebRequest(request, response);
RequestContextHolder.setRequestAttributes(servletWebRequest);
ScimGroupProvisioning groupProvisioning = new JdbcScimGroupProvisioning(jdbcTemplate, new JdbcPagingListFactory(jdbcTemplate, limitSqlAdapter));
identityZoneManager.getCurrentIdentityZone().getConfig().getUserConfig().setDefaultGroups(Collections.singletonList("uaa.user"));
groupProvisioning.createOrGet(new ScimGroup(null, "uaa.user", identityZoneManager.getCurrentIdentityZone().getId()), identityZoneManager.getCurrentIdentityZone().getId());
providerDefinition = new SamlIdentityProviderDefinition();
userProvisioning = new JdbcScimUserProvisioning(jdbcTemplate, new JdbcPagingListFactory(jdbcTemplate, limitSqlAdapter), passwordEncoder);
uaaSamlUser = groupProvisioning.create(new ScimGroup(null, UAA_SAML_USER, IdentityZone.getUaaZoneId()), identityZoneManager.getCurrentIdentityZone().getId());
uaaSamlAdmin = groupProvisioning.create(new ScimGroup(null, UAA_SAML_ADMIN, IdentityZone.getUaaZoneId()), identityZoneManager.getCurrentIdentityZone().getId());
ScimGroup uaaSamlTest = groupProvisioning.create(new ScimGroup(null, UAA_SAML_TEST, IdentityZone.getUaaZoneId()), identityZoneManager.getCurrentIdentityZone().getId());
JdbcScimGroupMembershipManager membershipManager = new JdbcScimGroupMembershipManager(jdbcTemplate, new TimeServiceImpl(), userProvisioning, null);
membershipManager.setScimGroupProvisioning(groupProvisioning);
ScimUserBootstrap bootstrap = new ScimUserBootstrap(userProvisioning, groupProvisioning, membershipManager, Collections.emptyList(), false, Collections.emptyList());
externalManager = new JdbcScimGroupExternalMembershipManager(jdbcTemplate);
externalManager.setScimGroupProvisioning(groupProvisioning);
externalManager.mapExternalGroup(uaaSamlUser.getId(), SAML_USER, OriginKeys.SAML, identityZoneManager.getCurrentIdentityZone().getId());
externalManager.mapExternalGroup(uaaSamlAdmin.getId(), SAML_ADMIN, OriginKeys.SAML, identityZoneManager.getCurrentIdentityZone().getId());
externalManager.mapExternalGroup(uaaSamlTest.getId(), SAML_TEST, OriginKeys.SAML, identityZoneManager.getCurrentIdentityZone().getId());
consumer = mock(WebSSOProfileConsumer.class);
SAMLCredential credential = getUserCredential("marissa-saml", "Marissa", "Bloggs", "marissa.bloggs@test.com", "1234567890");
when(consumer.processAuthenticationResponse(any())).thenReturn(credential);
TimeService timeService = mock(TimeService.class);
userDatabase = new JdbcUaaUserDatabase(jdbcTemplate, timeService, false, identityZoneManager);
providerProvisioning = new JdbcIdentityProviderProvisioning(jdbcTemplate);
publisher = new CreateUserPublisher(bootstrap);
authprovider = new LoginSamlAuthenticationProvider(identityZoneManager, userDatabase, providerProvisioning, externalManager);
authprovider.setApplicationEventPublisher(publisher);
authprovider.setConsumer(consumer);
authprovider.setSamlLogger(samlLogger);
provider = new IdentityProvider();
provider.setIdentityZoneId(IdentityZone.getUaaZoneId());
provider.setOriginKey(OriginKeys.SAML);
provider.setName("saml-test");
provider.setActive(true);
provider.setType(OriginKeys.SAML);
providerDefinition.setMetaDataLocation(String.format(IDP_META_DATA, OriginKeys.SAML));
providerDefinition.setIdpEntityAlias(OriginKeys.SAML);
provider.setConfig(providerDefinition);
provider = providerProvisioning.create(provider, identityZoneManager.getCurrentIdentityZone().getId());
}
Aggregations