org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository Java Examples

The following examples show how to use org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository. 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: SecurityConfiguration.java    From OAuth-2.0-Cookbook with MIT License 8 votes vote down vote up
@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
    ClientRegistration registration = new ClientRegistration.Builder(properties.getClientId())
        .authorizationUri(properties.getAuthorizationUri())
        .clientSecret(properties.getClientSecret())
        .tokenUri(properties.getTokenUri())
        .redirectUri(properties.getRedirectUri())
        .scope(properties.getScopes().split(","))
        .clientName(properties.getClientName())
        .clientAlias(properties.getClientAlias())
        .jwkSetUri(properties.getJwkSetUri())
        .authorizationGrantType(properties.getAuthorizedGrantType())
        .userInfoUri(properties.getUserInfoUri())
        .build();

    return new InMemoryClientRegistrationRepository(Arrays.asList(registration));
}
 
Example #2
Source File: SecurityConfiguration.java    From OAuth-2.0-Cookbook with MIT License 6 votes vote down vote up
@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
    ClientRegistration registration = new ClientRegistration.Builder(properties.getClientId())
            .authorizationUri(properties.getAuthorizationUri())
            .clientSecret(properties.getClientSecret())
            .tokenUri(properties.getTokenUri())
            .redirectUri(properties.getRedirectUri())
            .scope(properties.getScopes().split(","))
            .clientName(properties.getClientName())
            .clientAlias(properties.getClientAlias())
            .authorizationGrantType(properties.getAuthorizedGrantType())
            .userInfoUri(properties.getUserInfoUri())
            .clientAuthenticationMethod(new ClientAuthenticationMethod("get"))
            .build();

    return new InMemoryClientRegistrationRepository(Arrays.asList(registration));
}
 
Example #3
Source File: CredHubTemplateAutoConfigurationTests.java    From spring-credhub with Apache License 2.0 5 votes vote down vote up
@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: CustomRequestSecurityConfig.java    From tutorials with MIT License 5 votes vote down vote up
public ClientRegistrationRepository clientRegistrationRepository() {
    List<ClientRegistration> registrations = clients.stream()
        .map(c -> getRegistration(c))
        .filter(registration -> registration != null)
        .collect(Collectors.toList());

    return new InMemoryClientRegistrationRepository(registrations);
}
 
Example #5
Source File: SecurityConfig.java    From tutorials with MIT License 5 votes vote down vote up
public ClientRegistrationRepository clientRegistrationRepository() {
    List<ClientRegistration> registrations = clients.stream()
        .map(c -> getRegistration(c))
        .filter(registration -> registration != null)
        .collect(Collectors.toList());

    return new InMemoryClientRegistrationRepository(registrations);
}
 
Example #6
Source File: DataFlowConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Bean
public InMemoryClientRegistrationRepository clientRegistrationRepository(
		ComposedTaskProperties properties) {
	final ClientRegistration clientRegistration = ClientRegistration
			.withRegistrationId("default")
			.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
			.tokenUri(properties.getOauth2ClientCredentialsTokenUri())
			.clientId(properties.getOauth2ClientCredentialsClientId())
			.clientSecret(properties.getOauth2ClientCredentialsClientSecret())
			.scope(properties.getOauth2ClientCredentialsScopes())
			.build();
	return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example #7
Source File: DataFlowClientAutoConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Bean
public InMemoryClientRegistrationRepository clientRegistrationRepository(
	DataFlowClientProperties properties) {
	ClientRegistration clientRegistration = ClientRegistration
		.withRegistrationId(DEFAULT_REGISTRATION_ID)
		.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
		.tokenUri(properties.getAuthentication().getTokenUri())
		.clientId(properties.getAuthentication().getClientId())
		.clientSecret(properties.getAuthentication().getClientSecret())
		.scope(properties.getAuthentication().getScope())
		.build();
	return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example #8
Source File: CredHubOAuth2AutoConfiguration.java    From spring-credhub with Apache License 2.0 5 votes vote down vote up
/**
 * Create a {@code ClientRegistrationRepository} bean for use with an OAuth2-enabled
 * {@code CredHubTemplate}.
 * @return the {@code ClientRegistrationRepository}
 */
@Bean
@ConditionalOnMissingBean
@ConditionalOnClass(name = "javax.servlet.http.HttpServletRequest")
public ClientRegistrationRepository credHubClientRegistrationRepository() {
	List<ClientRegistration> registrations = new ArrayList<>(
			OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(this.properties).values());
	return new InMemoryClientRegistrationRepository(registrations);
}
 
Example #9
Source File: DataFlowConfiguration.java    From composed-task-runner with Apache License 2.0 5 votes vote down vote up
@Bean
public InMemoryClientRegistrationRepository clientRegistrationRepository(
		ComposedTaskProperties properties) {
	final ClientRegistration clientRegistration = ClientRegistration
			.withRegistrationId("default")
			.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
			.tokenUri(properties.getOauth2ClientCredentialsTokenUri())
			.clientId(properties.getOauth2ClientCredentialsClientId())
			.clientSecret(properties.getOauth2ClientCredentialsClientSecret())
			.scope(properties.getOauth2ClientCredentialsScopes())
			.build();
	return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example #10
Source File: SecurityConfiguration.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(Arrays.asList(
        createGoogleRegistration(),
        createMicrosoftRegistration()));
}
 
Example #11
Source File: UndertowSpringSecurityAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(Collections.singletonList(getClientRegistration()));
}
 
Example #12
Source File: UaaTestSecurityConfiguration.java    From jhipster-registry with Apache License 2.0 4 votes vote down vote up
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example #13
Source File: TestSecurityConfiguration.java    From jhipster-registry with Apache License 2.0 4 votes vote down vote up
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example #14
Source File: ConfigCommands.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
private ClientRegistrationRepository shellClientRegistrationRepository(OAuth2ClientProperties properties) {
	List<ClientRegistration> registrations = new ArrayList<>(
			OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values());
	return new InMemoryClientRegistrationRepository(registrations);
}
 
Example #15
Source File: DataFlowClientAutoConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
private ClientRegistrationRepository shellClientRegistrationRepository(OAuth2ClientProperties properties) {
	List<ClientRegistration> registrations = new ArrayList<>(
			OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values());
	return new InMemoryClientRegistrationRepository(registrations);
}
 
Example #16
Source File: TestSecurityConfiguration.java    From java-microservices-examples with Apache License 2.0 4 votes vote down vote up
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example #17
Source File: TestSecurityConfiguration.java    From java-microservices-examples with Apache License 2.0 4 votes vote down vote up
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example #18
Source File: TestSecurityConfiguration.java    From java-microservices-examples with Apache License 2.0 4 votes vote down vote up
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}