org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties Java Examples
The following examples show how to use
org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigCommands.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
private ClientHttpRequestInterceptor bearerTokenResolvingInterceptor( OAuth2ClientProperties properties, String username, String password, String clientRegistrationId) { ClientRegistrationRepository shellClientRegistrationRepository = shellClientRegistrationRepository(properties); OAuth2AuthorizedClientService shellAuthorizedClientService = shellAuthorizedClientService(shellClientRegistrationRepository); OAuth2AuthorizedClientManager authorizedClientManager = authorizedClientManager( shellClientRegistrationRepository, shellAuthorizedClientService); if (properties.getRegistration() != null && properties.getRegistration().size() == 1) { // if we have only one, use that clientRegistrationId = properties.getRegistration().entrySet().iterator().next().getKey(); } OAuth2AuthorizeRequest authorizeRequest = OAuth2AuthorizeRequest.withClientRegistrationId(clientRegistrationId) .principal(DEFAULT_PRINCIPAL) .attribute(OAuth2AuthorizationContext.USERNAME_ATTRIBUTE_NAME, username) .attribute(OAuth2AuthorizationContext.PASSWORD_ATTRIBUTE_NAME, password) .build(); return (request, body, execution) -> { OAuth2AuthorizedClient authorizedClient = authorizedClientManager.authorize(authorizeRequest); request.getHeaders().setBearerAuth(authorizedClient.getAccessToken().getTokenValue()); return execution.execute(request, body); }; }
Example #2
Source File: DataFlowClientAutoConfiguration.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
private ClientHttpRequestInterceptor bearerTokenResolvingInterceptor( OAuth2ClientProperties properties, String username, String password, String clientRegistrationId) { ClientRegistrationRepository shellClientRegistrationRepository = shellClientRegistrationRepository(properties); OAuth2AuthorizedClientService shellAuthorizedClientService = shellAuthorizedClientService(shellClientRegistrationRepository); OAuth2AuthorizedClientManager authorizedClientManager = authorizedClientManager( shellClientRegistrationRepository, shellAuthorizedClientService); if (properties.getRegistration() != null && properties.getRegistration().size() == 1) { // if we have only one, use that clientRegistrationId = properties.getRegistration().entrySet().iterator().next().getKey(); } OAuth2AuthorizeRequest authorizeRequest = OAuth2AuthorizeRequest.withClientRegistrationId(clientRegistrationId) .principal(DEFAULT_PRINCIPAL) .attribute(OAuth2AuthorizationContext.USERNAME_ATTRIBUTE_NAME, username) .attribute(OAuth2AuthorizationContext.PASSWORD_ATTRIBUTE_NAME, password) .build(); return (request, body, execution) -> { OAuth2AuthorizedClient authorizedClient = authorizedClientManager.authorize(authorizeRequest); request.getHeaders().setBearerAuth(authorizedClient.getAccessToken().getTokenValue()); return execution.execute(request, body); }; }
Example #3
Source File: CredHubTemplateAutoConfigurationTests.java From spring-credhub with Apache License 2.0 | 5 votes |
@Bean AuthorizedClientServiceOAuth2AuthorizedClientManager clientManager(OAuth2ClientProperties properties) { List<ClientRegistration> registrations = new ArrayList<>( OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values()); ClientRegistrationRepository clientRegistrationRepository = new InMemoryClientRegistrationRepository( registrations); OAuth2AuthorizedClientService authorizedClientService = new InMemoryOAuth2AuthorizedClientService( clientRegistrationRepository); return new AuthorizedClientServiceOAuth2AuthorizedClientManager(clientRegistrationRepository, authorizedClientService); }
Example #4
Source File: CredHubTemplateAutoConfigurationTests.java From spring-credhub with Apache License 2.0 | 5 votes |
@Bean AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager reactiveClientManager( OAuth2ClientProperties properties) { List<ClientRegistration> registrations = new ArrayList<>( OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values()); ReactiveClientRegistrationRepository clientRegistrationRepository = new InMemoryReactiveClientRegistrationRepository( registrations); ReactiveOAuth2AuthorizedClientService authorizedClientService = new InMemoryReactiveOAuth2AuthorizedClientService( clientRegistrationRepository); return new AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager(clientRegistrationRepository, authorizedClientService); }
Example #5
Source File: SecurityConfiguration.java From microservices-dashboard with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean @Conditional(ClientsConfiguredCondition.class) public ReactiveClientRegistrationRepository clientRegistrationRepository(OAuth2ClientProperties properties) { List<ClientRegistration> registrations = new ArrayList<>( OAuth2ClientPropertiesRegistrationAdapter .getClientRegistrations(properties).values()); return new InMemoryReactiveClientRegistrationRepository(registrations); }
Example #6
Source File: CredHubOAuth2AutoConfiguration.java From spring-credhub with Apache License 2.0 | 4 votes |
CredHubOAuth2AutoConfiguration(OAuth2ClientProperties properties) { this.properties = properties; }
Example #7
Source File: ConfigCommands.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
private ClientRegistrationRepository shellClientRegistrationRepository(OAuth2ClientProperties properties) { List<ClientRegistration> registrations = new ArrayList<>( OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values()); return new InMemoryClientRegistrationRepository(registrations); }
Example #8
Source File: DataFlowClientAutoConfiguration.java From spring-cloud-dataflow with Apache License 2.0 | 4 votes |
private ClientRegistrationRepository shellClientRegistrationRepository(OAuth2ClientProperties properties) { List<ClientRegistration> registrations = new ArrayList<>( OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values()); return new InMemoryClientRegistrationRepository(registrations); }