use of org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning in project uaa by cloudfoundry.
the class ScimGroupBootstrapTests method initScimGroupBootstrapTests.
@BeforeEach
void initScimGroupBootstrapTests() {
JdbcTemplate template = jdbcTemplate;
JdbcPagingListFactory pagingListFactory = new JdbcPagingListFactory(template, limitSqlAdapter);
gDB = new JdbcScimGroupProvisioning(template, pagingListFactory);
uDB = new JdbcScimUserProvisioning(template, pagingListFactory, passwordEncoder);
mDB = new JdbcScimGroupMembershipManager(template, new TimeServiceImpl(), uDB, null);
mDB.setScimGroupProvisioning(gDB);
uDB.deleteByIdentityZone(IdentityZone.getUaaZoneId());
gDB.deleteByIdentityZone(IdentityZone.getUaaZoneId());
uDB.createUser(TestUtils.scimUserInstance("dev1"), "test", IdentityZone.getUaaZoneId());
uDB.createUser(TestUtils.scimUserInstance("dev2"), "test", IdentityZone.getUaaZoneId());
uDB.createUser(TestUtils.scimUserInstance("dev3"), "test", IdentityZone.getUaaZoneId());
uDB.createUser(TestUtils.scimUserInstance("qa1"), "test", IdentityZone.getUaaZoneId());
uDB.createUser(TestUtils.scimUserInstance("qa2"), "test", IdentityZone.getUaaZoneId());
uDB.createUser(TestUtils.scimUserInstance("mgr1"), "test", IdentityZone.getUaaZoneId());
uDB.createUser(TestUtils.scimUserInstance("hr1"), "test", IdentityZone.getUaaZoneId());
assertEquals(7, uDB.retrieveAll(IdentityZone.getUaaZoneId()).size());
assertEquals(0, gDB.retrieveAll(IdentityZone.getUaaZoneId()).size());
bootstrap = new ScimGroupBootstrap(gDB, uDB, mDB);
}
use of org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning in project uaa by cloudfoundry.
the class ScimUserBootstrapTests method init.
@BeforeEach
void init() {
JdbcPagingListFactory pagingListFactory = new JdbcPagingListFactory(jdbcTemplate, LimitSqlAdapterFactory.getLimitSqlAdapter());
jdbcScimUserProvisioning = spy(new JdbcScimUserProvisioning(jdbcTemplate, pagingListFactory, passwordEncoder));
jdbcScimGroupProvisioning = new JdbcScimGroupProvisioning(jdbcTemplate, pagingListFactory);
jdbcScimGroupMembershipManager = new JdbcScimGroupMembershipManager(jdbcTemplate, new TimeServiceImpl(), jdbcScimUserProvisioning, null);
jdbcScimGroupMembershipManager.setScimGroupProvisioning(jdbcScimGroupProvisioning);
scimUserEndpoints = new ScimUserEndpoints(new IdentityZoneManagerImpl(), new IsSelfCheck(null), jdbcScimUserProvisioning, null, null, null, null, null, null, null, jdbcScimGroupMembershipManager, 5);
IdentityZoneHolder.get().getConfig().getUserConfig().setDefaultGroups(emptyList());
}
use of org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning in project uaa by cloudfoundry.
the class PasswordChangeEndpointTests method setup.
@BeforeEach
void setup(@Autowired JdbcTemplate jdbcTemplate) {
jdbcScimUserProvisioning = new JdbcScimUserProvisioning(jdbcTemplate, new JdbcPagingListFactory(jdbcTemplate, LimitSqlAdapterFactory.getLimitSqlAdapter()), passwordEncoder);
final RandomValueStringGenerator generator = new RandomValueStringGenerator();
final String currentIdentityZoneId = "currentIdentityZoneId-" + generator.generate();
mockIdentityZoneManager = mock(IdentityZoneManager.class);
when(mockIdentityZoneManager.getCurrentIdentityZoneId()).thenReturn(currentIdentityZoneId);
mockPasswordValidator = mock(PasswordValidator.class);
mockSecurityContextAccessor = mock(SecurityContextAccessor.class);
passwordChangeEndpoint = new PasswordChangeEndpoint(mockIdentityZoneManager, mockPasswordValidator, jdbcScimUserProvisioning, mockSecurityContextAccessor);
joel = new ScimUser(null, "jdsa", "Joel", "D'sa");
joel.addEmail("jdsa@vmware.com");
dale = new ScimUser(null, "olds", "Dale", "Olds");
dale.addEmail("olds@vmware.com");
joel = jdbcScimUserProvisioning.createUser(joel, "password", currentIdentityZoneId);
dale = jdbcScimUserProvisioning.createUser(dale, "password", currentIdentityZoneId);
when(mockSecurityContextAccessor.getUserId()).thenReturn(joel.getId());
}
use of org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning 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());
}
use of org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning in project uaa by cloudfoundry.
the class SamlTestUtils method mockSsoWebProfileImpl.
private static IdpWebSsoProfileImpl mockSsoWebProfileImpl() {
IdpWebSsoProfileImpl profile = new IdpWebSsoProfileImpl();
JdbcScimUserProvisioning scimUserProvisioning = mock(JdbcScimUserProvisioning.class);
profile.setScimUserProvisioning(scimUserProvisioning);
JdbcSamlServiceProviderProvisioning samlServiceProviderProvisioning = mock(JdbcSamlServiceProviderProvisioning.class);
profile.setSamlServiceProviderProvisioning(samlServiceProviderProvisioning);
ScimUser user = new ScimUser(null, "johndoe", "John", "Doe");
SamlServiceProvider samlServiceProvider = new SamlServiceProvider();
SamlServiceProviderDefinition config = new SamlServiceProviderDefinition();
config.setAttributeMappings(new HashMap<>());
samlServiceProvider.setConfig(config);
when(scimUserProvisioning.retrieve(anyString(), anyString())).thenReturn(user);
when(samlServiceProviderProvisioning.retrieveByEntityId(any(), any())).thenReturn(samlServiceProvider);
profile.setScimUserProvisioning(scimUserProvisioning);
profile.setSamlServiceProviderProvisioning(samlServiceProviderProvisioning);
return profile;
}
Aggregations