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

The following examples show how to use org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository. These examples are extracted from open source projects. 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 Project: OAuth-2.0-Cookbook   Source File: SecurityConfiguration.java    License: 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())
        .jwkSetUri(properties.getJwkSetUri())
        .authorizationGrantType(properties.getAuthorizedGrantType())
        .userInfoUri(properties.getUserInfoUri())
        .build();

    return new InMemoryClientRegistrationRepository(Arrays.asList(registration));
}
 
Example 2
Source Project: OAuth-2.0-Cookbook   Source File: SecurityConfiguration.java    License: 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
@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 4
/**
 * 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 5
@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 6
@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 7
@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 8
Source Project: tutorials   Source File: SecurityConfig.java    License: 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 9
Source Project: tutorials   Source File: CustomRequestSecurityConfig.java    License: 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 10
@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(Collections.singletonList(getClientRegistration()));
}
 
Example 11
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example 12
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example 13
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example 14
Source Project: OAuth-2.0-Cookbook   Source File: SecurityConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(Arrays.asList(
        createGoogleRegistration(),
        createMicrosoftRegistration()));
}
 
Example 15
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example 16
@Bean
ClientRegistrationRepository clientRegistrationRepository() {
    return new InMemoryClientRegistrationRepository(clientRegistration);
}
 
Example 17
Source Project: spring-cloud-dataflow   Source File: ConfigCommands.java    License: 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 18
private ClientRegistrationRepository shellClientRegistrationRepository(OAuth2ClientProperties properties) {
	List<ClientRegistration> registrations = new ArrayList<>(
			OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values());
	return new InMemoryClientRegistrationRepository(registrations);
}