Search in sources :

Example 1 with DefaultPasswordTokenResponseClient

use of org.springframework.security.oauth2.client.endpoint.DefaultPasswordTokenResponseClient in project spring-security by spring-projects.

the class OAuth2AuthorizedClientProviderBuilderTests method setup.

@SuppressWarnings("unchecked")
@BeforeEach
public void setup() {
    OAuth2AccessTokenResponse accessTokenResponse = TestOAuth2AccessTokenResponses.accessTokenResponse().build();
    this.accessTokenClient = mock(RestOperations.class);
    given(this.accessTokenClient.exchange(any(RequestEntity.class), eq(OAuth2AccessTokenResponse.class))).willReturn(new ResponseEntity(accessTokenResponse, HttpStatus.OK));
    this.refreshTokenTokenResponseClient = new DefaultRefreshTokenTokenResponseClient();
    this.refreshTokenTokenResponseClient.setRestOperations(this.accessTokenClient);
    this.clientCredentialsTokenResponseClient = new DefaultClientCredentialsTokenResponseClient();
    this.clientCredentialsTokenResponseClient.setRestOperations(this.accessTokenClient);
    this.passwordTokenResponseClient = new DefaultPasswordTokenResponseClient();
    this.passwordTokenResponseClient.setRestOperations(this.accessTokenClient);
    this.principal = new TestingAuthenticationToken("principal", "password");
}
Also used : OAuth2AccessTokenResponse(org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse) ResponseEntity(org.springframework.http.ResponseEntity) DefaultPasswordTokenResponseClient(org.springframework.security.oauth2.client.endpoint.DefaultPasswordTokenResponseClient) RestOperations(org.springframework.web.client.RestOperations) RequestEntity(org.springframework.http.RequestEntity) DefaultClientCredentialsTokenResponseClient(org.springframework.security.oauth2.client.endpoint.DefaultClientCredentialsTokenResponseClient) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) DefaultRefreshTokenTokenResponseClient(org.springframework.security.oauth2.client.endpoint.DefaultRefreshTokenTokenResponseClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BeforeEach (org.junit.jupiter.api.BeforeEach)1 RequestEntity (org.springframework.http.RequestEntity)1 ResponseEntity (org.springframework.http.ResponseEntity)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1 DefaultClientCredentialsTokenResponseClient (org.springframework.security.oauth2.client.endpoint.DefaultClientCredentialsTokenResponseClient)1 DefaultPasswordTokenResponseClient (org.springframework.security.oauth2.client.endpoint.DefaultPasswordTokenResponseClient)1 DefaultRefreshTokenTokenResponseClient (org.springframework.security.oauth2.client.endpoint.DefaultRefreshTokenTokenResponseClient)1 OAuth2AccessTokenResponse (org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse)1 RestOperations (org.springframework.web.client.RestOperations)1