Search in sources :

Example 1 with JdbcRevocableTokenProvisioning

use of org.cloudfoundry.identity.uaa.oauth.token.JdbcRevocableTokenProvisioning in project uaa by cloudfoundry.

the class TokenRevocationEndpointTests method setupForTokenRevocation.

@BeforeEach
void setupForTokenRevocation() {
    String zoneId = IdentityZoneHolder.get().getId();
    RandomValueStringGenerator generator = new RandomValueStringGenerator();
    String clientId = generator.generate().toLowerCase();
    client = new BaseClientDetails(clientId, "", "some.scopes", "client_credentials", "authorities");
    client.addAdditionalInformation(TOKEN_SALT, "pre-salt");
    IdentityZoneManager mockIdentityZoneManager = mock(IdentityZoneManager.class);
    when(mockIdentityZoneManager.getCurrentIdentityZoneId()).thenReturn(IdentityZone.getUaaZoneId());
    clientService = spy(new MultitenantJdbcClientDetailsService(jdbcTemplate, mockIdentityZoneManager, passwordEncoder));
    clientService.addClientDetails(client, zoneId);
    ScimUserProvisioning userProvisioning = new JdbcScimUserProvisioning(jdbcTemplate, new JdbcPagingListFactory(jdbcTemplate, limitSqlAdapter), passwordEncoder);
    JdbcRevocableTokenProvisioning provisioning = spy(new JdbcRevocableTokenProvisioning(jdbcTemplate, limitSqlAdapter, new TimeServiceImpl()));
    endpoint = spy(new TokenRevocationEndpoint(clientService, userProvisioning, provisioning));
    ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class);
    endpoint.setApplicationEventPublisher(publisher);
    SecurityContextHolder.getContext().setAuthentication(new UaaOauth2Authentication("token-value", zoneId, mock(OAuth2Request.class), new UaaAuthentication(new UaaPrincipal("id", "username", "username@test.com", OriginKeys.UAA, "", zoneId), Collections.emptyList(), mock(UaaAuthenticationDetails.class))));
    provisioning.create(new RevocableToken().setClientId(client.getClientId()).setTokenId("token-id").setUserId(null).setResponseType(RevocableToken.TokenType.ACCESS_TOKEN).setValue("value").setIssuedAt(System.currentTimeMillis()), zoneId);
}
Also used : BaseClientDetails(org.springframework.security.oauth2.provider.client.BaseClientDetails) TimeServiceImpl(org.cloudfoundry.identity.uaa.util.TimeServiceImpl) MultitenantJdbcClientDetailsService(org.cloudfoundry.identity.uaa.zone.MultitenantJdbcClientDetailsService) JdbcRevocableTokenProvisioning(org.cloudfoundry.identity.uaa.oauth.token.JdbcRevocableTokenProvisioning) JdbcPagingListFactory(org.cloudfoundry.identity.uaa.resources.jdbc.JdbcPagingListFactory) UaaAuthenticationDetails(org.cloudfoundry.identity.uaa.authentication.UaaAuthenticationDetails) JdbcScimUserProvisioning(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning) ScimUserProvisioning(org.cloudfoundry.identity.uaa.scim.ScimUserProvisioning) JdbcScimUserProvisioning(org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning) UaaAuthentication(org.cloudfoundry.identity.uaa.authentication.UaaAuthentication) UaaPrincipal(org.cloudfoundry.identity.uaa.authentication.UaaPrincipal) RevocableToken(org.cloudfoundry.identity.uaa.oauth.token.RevocableToken) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) RandomValueStringGenerator(org.springframework.security.oauth2.common.util.RandomValueStringGenerator) IdentityZoneManager(org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

UaaAuthentication (org.cloudfoundry.identity.uaa.authentication.UaaAuthentication)1 UaaAuthenticationDetails (org.cloudfoundry.identity.uaa.authentication.UaaAuthenticationDetails)1 UaaPrincipal (org.cloudfoundry.identity.uaa.authentication.UaaPrincipal)1 JdbcRevocableTokenProvisioning (org.cloudfoundry.identity.uaa.oauth.token.JdbcRevocableTokenProvisioning)1 RevocableToken (org.cloudfoundry.identity.uaa.oauth.token.RevocableToken)1 JdbcPagingListFactory (org.cloudfoundry.identity.uaa.resources.jdbc.JdbcPagingListFactory)1 ScimUserProvisioning (org.cloudfoundry.identity.uaa.scim.ScimUserProvisioning)1 JdbcScimUserProvisioning (org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimUserProvisioning)1 TimeServiceImpl (org.cloudfoundry.identity.uaa.util.TimeServiceImpl)1 MultitenantJdbcClientDetailsService (org.cloudfoundry.identity.uaa.zone.MultitenantJdbcClientDetailsService)1 IdentityZoneManager (org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManager)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)1 RandomValueStringGenerator (org.springframework.security.oauth2.common.util.RandomValueStringGenerator)1 BaseClientDetails (org.springframework.security.oauth2.provider.client.BaseClientDetails)1