Search in sources :

Example 1 with IdentityZoneManagerImpl

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);
}
Also used : IdentityZoneManagerImpl(org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl) JdbcUserGoogleMfaCredentialsProvisioning(org.cloudfoundry.identity.uaa.mfa.JdbcUserGoogleMfaCredentialsProvisioning) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) ApprovalStore(org.cloudfoundry.identity.uaa.approval.ApprovalStore) PasswordValidator(org.cloudfoundry.identity.uaa.scim.validate.PasswordValidator) InvalidPasswordException(org.cloudfoundry.identity.uaa.scim.exception.InvalidPasswordException) IsSelfCheck(org.cloudfoundry.identity.uaa.security.IsSelfCheck) ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup) JdbcIdentityProviderProvisioning(org.cloudfoundry.identity.uaa.provider.JdbcIdentityProviderProvisioning)

Example 2 with IdentityZoneManagerImpl

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());
}
Also used : TimeServiceImpl(org.cloudfoundry.identity.uaa.util.TimeServiceImpl) JdbcPagingListFactory(org.cloudfoundry.identity.uaa.resources.jdbc.JdbcPagingListFactory) JdbcScimGroupMembershipManager(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupMembershipManager) IdentityZoneManagerImpl(org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl) JdbcScimGroupProvisioning(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupProvisioning) IsSelfCheck(org.cloudfoundry.identity.uaa.security.IsSelfCheck) JdbcScimUserProvisioning(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning) ScimUserEndpoints(org.cloudfoundry.identity.uaa.scim.endpoints.ScimUserEndpoints) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with IdentityZoneManagerImpl

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());
}
Also used : JdbcScimGroupExternalMembershipManager(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupExternalMembershipManager) TimeServiceImpl(org.cloudfoundry.identity.uaa.util.TimeServiceImpl) JdbcPagingListFactory(org.cloudfoundry.identity.uaa.resources.jdbc.JdbcPagingListFactory) JdbcUaaUserDatabase(org.cloudfoundry.identity.uaa.user.JdbcUaaUserDatabase) JdbcScimGroupMembershipManager(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupMembershipManager) IdentityZoneManagerImpl(org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) JdbcScimGroupProvisioning(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupProvisioning) TimeService(org.cloudfoundry.identity.uaa.util.TimeService) JdbcScimUserProvisioning(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning) IdentityProvider(org.cloudfoundry.identity.uaa.provider.IdentityProvider) ScimGroupProvisioning(org.cloudfoundry.identity.uaa.scim.ScimGroupProvisioning) JdbcScimGroupProvisioning(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupProvisioning) JdbcIdentityProviderProvisioning(org.cloudfoundry.identity.uaa.provider.JdbcIdentityProviderProvisioning) WebSSOProfileConsumer(org.springframework.security.saml.websso.WebSSOProfileConsumer) ScimUserBootstrap(org.cloudfoundry.identity.uaa.scim.bootstrap.ScimUserBootstrap) SAMLCredential(org.springframework.security.saml.SAMLCredential) SamlIdentityProviderDefinition(org.cloudfoundry.identity.uaa.provider.SamlIdentityProviderDefinition) ServletContext(javax.servlet.ServletContext) ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with IdentityZoneManagerImpl

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());
}
Also used : IdentityZoneManagerImpl(org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl)

Example 5 with 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());
}
Also used : IdentityZoneManagerImpl(org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl) RefreshTokenCreator(org.cloudfoundry.identity.uaa.oauth.refresh.RefreshTokenCreator)

Aggregations

IdentityZoneManagerImpl (org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManagerImpl)5 JdbcIdentityProviderProvisioning (org.cloudfoundry.identity.uaa.provider.JdbcIdentityProviderProvisioning)2 JdbcPagingListFactory (org.cloudfoundry.identity.uaa.resources.jdbc.JdbcPagingListFactory)2 ScimGroup (org.cloudfoundry.identity.uaa.scim.ScimGroup)2 JdbcScimGroupMembershipManager (org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupMembershipManager)2 JdbcScimGroupProvisioning (org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupProvisioning)2 JdbcScimUserProvisioning (org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning)2 IsSelfCheck (org.cloudfoundry.identity.uaa.security.IsSelfCheck)2 TimeServiceImpl (org.cloudfoundry.identity.uaa.util.TimeServiceImpl)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ServletContext (javax.servlet.ServletContext)1 ApprovalStore (org.cloudfoundry.identity.uaa.approval.ApprovalStore)1 JdbcUserGoogleMfaCredentialsProvisioning (org.cloudfoundry.identity.uaa.mfa.JdbcUserGoogleMfaCredentialsProvisioning)1 RefreshTokenCreator (org.cloudfoundry.identity.uaa.oauth.refresh.RefreshTokenCreator)1 IdentityProvider (org.cloudfoundry.identity.uaa.provider.IdentityProvider)1 SamlIdentityProviderDefinition (org.cloudfoundry.identity.uaa.provider.SamlIdentityProviderDefinition)1 ScimGroupProvisioning (org.cloudfoundry.identity.uaa.scim.ScimGroupProvisioning)1 ScimUserBootstrap (org.cloudfoundry.identity.uaa.scim.bootstrap.ScimUserBootstrap)1 ScimUserEndpoints (org.cloudfoundry.identity.uaa.scim.endpoints.ScimUserEndpoints)1 InvalidPasswordException (org.cloudfoundry.identity.uaa.scim.exception.InvalidPasswordException)1