use of org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl in project uaa by cloudfoundry.
the class ScimUserEndpointsTests method setUpAfterSeeding.
void setUpAfterSeeding(final IdentityZone identityZone) {
this.identityZone = identityZone;
identityZoneManager.setCurrentIdentityZone(this.identityZone);
this.identityZone.getConfig().getUserConfig().setDefaultGroups(Collections.singletonList("uaa.user"));
this.mockApprovalStore = mock(ApprovalStore.class);
jdbcScimUserProvisioning.setQueryConverter(filterConverter);
mockJdbcIdentityProviderProvisioning = mock(JdbcIdentityProviderProvisioning.class);
mockJdbcUserGoogleMfaCredentialsProvisioning = mock(JdbcUserGoogleMfaCredentialsProvisioning.class);
mockPasswordValidator = mock(PasswordValidator.class);
ApplicationEventPublisher mockApplicationEventPublisher = mock(ApplicationEventPublisher.class);
doThrow(new InvalidPasswordException("Password must be at least 1 characters in length.")).when(mockPasswordValidator).validate(null);
doThrow(new InvalidPasswordException("Password must be at least 1 characters in length.")).when(mockPasswordValidator).validate(eq(""));
jdbcScimGroupProvisioning.createOrGet(new ScimGroup(null, "uaa.user", identityZone.getId()), identityZone.getId());
joel = jdbcScimUserProvisioning.createUser(joel, "password", identityZone.getId());
dale = jdbcScimUserProvisioning.createUser(dale, "password", identityZone.getId());
spiedScimGroupMembershipManager = spy(scimGroupMembershipManager);
scimUserEndpoints = new ScimUserEndpoints(new IdentityZoneManagerImpl(), new IsSelfCheck(null), jdbcScimUserProvisioning, mockJdbcIdentityProviderProvisioning, null, statuses, mockPasswordValidator, null, mockJdbcUserGoogleMfaCredentialsProvisioning, mockApprovalStore, spiedScimGroupMembershipManager, 5);
}
use of org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl 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.zone.beans.IdentityZoneManagerImpl 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.zone.beans.IdentityZoneManagerImpl in project uaa by cloudfoundry.
the class DeprecatedUaaTokenServicesTests method useIZMIforAccessToken.
private static void useIZMIforAccessToken(UaaTokenServices tokenServices) {
TokenValidityResolver accessTokenValidityResolver = (TokenValidityResolver) ReflectionTestUtils.getField(tokenServices, "accessTokenValidityResolver");
ClientTokenValidity clientTokenValidity = (ClientTokenValidity) ReflectionTestUtils.getField(accessTokenValidityResolver, "clientTokenValidity");
ReflectionTestUtils.setField(clientTokenValidity, "identityZoneManager", new IdentityZoneManagerImpl());
}
use of org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl in project uaa by cloudfoundry.
the class DeprecatedUaaTokenServicesTests method useIZMIforRefreshToken.
private static void useIZMIforRefreshToken(UaaTokenServices tokenServices) {
RefreshTokenCreator refreshTokenCreator = (RefreshTokenCreator) ReflectionTestUtils.getField(tokenServices, "refreshTokenCreator");
TokenValidityResolver refreshTokenValidityResolver = (TokenValidityResolver) ReflectionTestUtils.getField(refreshTokenCreator, "refreshTokenValidityResolver");
ClientTokenValidity clientTokenValidity = (ClientTokenValidity) ReflectionTestUtils.getField(refreshTokenValidityResolver, "clientTokenValidity");
ReflectionTestUtils.setField(clientTokenValidity, "identityZoneManager", new IdentityZoneManagerImpl());
}
Aggregations