congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
OAuth2AuthorizedClientArgumentResolver.resolveArgument
Code IndexAdd Tabnine to your IDE (free)

How to use
resolveArgument
method
in
org.springframework.security.oauth2.client.web.method.annotation.OAuth2AuthorizedClientArgumentResolver

Best Java code snippets using org.springframework.security.oauth2.client.web.method.annotation.OAuth2AuthorizedClientArgumentResolver.resolveArgument (Showing top 6 results out of 315)

origin: spring-projects/spring-security

@Test
public void resolveArgumentWhenRegistrationIdEmptyAndNotOAuth2AuthenticationThenThrowIllegalArgumentException() {
  MethodParameter methodParameter = this.getMethodParameter("registrationIdEmpty", OAuth2AuthorizedClient.class);
  assertThatThrownBy(() -> this.argumentResolver.resolveArgument(methodParameter, null, null, null))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Unable to resolve the Client Registration Identifier. It must be provided via @RegisteredOAuth2AuthorizedClient(\"client1\") or @RegisteredOAuth2AuthorizedClient(registrationId = \"client1\").");
}
origin: spring-projects/spring-security

@Test
public void resolveArgumentWhenAuthorizedClientNotFoundForAuthorizationCodeClientThenThrowClientAuthorizationRequiredException() {
  when(this.authorizedClientRepository.loadAuthorizedClient(anyString(), any(), any(HttpServletRequest.class)))
      .thenReturn(null);
  MethodParameter methodParameter = this.getMethodParameter("paramTypeAuthorizedClient", OAuth2AuthorizedClient.class);
  assertThatThrownBy(() -> this.argumentResolver.resolveArgument(methodParameter, null, new ServletWebRequest(this.request), null))
      .isInstanceOf(ClientAuthorizationRequiredException.class);
}
origin: spring-projects/spring-security

@Test
public void resolveArgumentWhenRegistrationIdEmptyAndOAuth2AuthenticationThenResolves() throws Exception {
  OAuth2AuthenticationToken authentication = mock(OAuth2AuthenticationToken.class);
  when(authentication.getAuthorizedClientRegistrationId()).thenReturn("client1");
  SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
  securityContext.setAuthentication(authentication);
  SecurityContextHolder.setContext(securityContext);
  MethodParameter methodParameter = this.getMethodParameter("registrationIdEmpty", OAuth2AuthorizedClient.class);
  assertThat(this.argumentResolver.resolveArgument(
      methodParameter, null, new ServletWebRequest(this.request), null)).isSameAs(this.authorizedClient1);
}
origin: spring-projects/spring-security

@SuppressWarnings("unchecked")
@Test
public void resolveArgumentWhenAuthorizedClientNotFoundForClientCredentialsClientThenResolvesFromTokenResponseClient() throws Exception {
  OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> clientCredentialsTokenResponseClient =
      mock(OAuth2AccessTokenResponseClient.class);
  this.argumentResolver.setClientCredentialsTokenResponseClient(clientCredentialsTokenResponseClient);
  OAuth2AccessTokenResponse accessTokenResponse = OAuth2AccessTokenResponse
      .withToken("access-token-1234")
      .tokenType(OAuth2AccessToken.TokenType.BEARER)
      .expiresIn(3600)
      .build();
  when(clientCredentialsTokenResponseClient.getTokenResponse(any())).thenReturn(accessTokenResponse);
  when(this.authorizedClientRepository.loadAuthorizedClient(anyString(), any(), any(HttpServletRequest.class)))
      .thenReturn(null);
  MethodParameter methodParameter = this.getMethodParameter("clientCredentialsClient", OAuth2AuthorizedClient.class);
  OAuth2AuthorizedClient authorizedClient = (OAuth2AuthorizedClient) this.argumentResolver.resolveArgument(
      methodParameter, null, new ServletWebRequest(this.request), null);
  assertThat(authorizedClient).isNotNull();
  assertThat(authorizedClient.getClientRegistration()).isSameAs(this.registration2);
  assertThat(authorizedClient.getPrincipalName()).isEqualTo(this.principalName);
  assertThat(authorizedClient.getAccessToken()).isSameAs(accessTokenResponse.getAccessToken());
  verify(this.authorizedClientRepository).saveAuthorizedClient(
      eq(authorizedClient), eq(this.authentication), any(HttpServletRequest.class), eq(null));
}
origin: spring-projects/spring-security

@Test
public void resolveArgumentWhenAuthorizedClientFoundThenResolves() throws Exception {
  MethodParameter methodParameter = this.getMethodParameter("paramTypeAuthorizedClient", OAuth2AuthorizedClient.class);
  assertThat(this.argumentResolver.resolveArgument(
      methodParameter, null, new ServletWebRequest(this.request), null)).isSameAs(this.authorizedClient1);
}
origin: spring-projects/spring-security

@Test
public void resolveArgumentWhenRegistrationIdInvalidThenDoesNotResolve() throws Exception {
  MethodParameter methodParameter = this.getMethodParameter("registrationIdInvalid", OAuth2AuthorizedClient.class);
  assertThat(this.argumentResolver.resolveArgument(
      methodParameter, null, new ServletWebRequest(this.request), null)).isNull();
}
org.springframework.security.oauth2.client.web.method.annotationOAuth2AuthorizedClientArgumentResolverresolveArgument

Popular methods of OAuth2AuthorizedClientArgumentResolver

  • <init>
  • authorizeClientCredentialsClient
  • resolveClientRegistrationId
  • setClientCredentialsTokenResponseClient
    Sets the client used when requesting an access token credential at the Token Endpoint for the client
  • supportsParameter

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • getContentResolver (Context)
  • getSystemService (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now