org.springframework.security.oauth2.config.annotation.builders.ClientDetailsServiceBuilder Java Examples

The following examples show how to use org.springframework.security.oauth2.config.annotation.builders.ClientDetailsServiceBuilder. 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: OAuth2AuthorizationServerConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
	ClientDetailsServiceBuilder<InMemoryClientDetailsServiceBuilder>.ClientBuilder builder = clients.inMemory()
			.withClient(this.details.getClientId());
	builder.secret(this.details.getClientSecret())
			.resourceIds(this.details.getResourceIds().toArray(new String[0]))
			.authorizedGrantTypes(this.details.getAuthorizedGrantTypes().toArray(new String[0]))
			.authorities(
					AuthorityUtils.authorityListToSet(this.details.getAuthorities()).toArray(new String[0]))
			.scopes(this.details.getScope().toArray(new String[0]));

	if (this.details.getAutoApproveScopes() != null) {
		builder.autoApprove(this.details.getAutoApproveScopes().toArray(new String[0]));
	}
	if (this.details.getAccessTokenValiditySeconds() != null) {
		builder.accessTokenValiditySeconds(this.details.getAccessTokenValiditySeconds());
	}
	if (this.details.getRefreshTokenValiditySeconds() != null) {
		builder.refreshTokenValiditySeconds(this.details.getRefreshTokenValiditySeconds());
	}
	if (this.details.getRegisteredRedirectUri() != null) {
		builder.redirectUris(this.details.getRegisteredRedirectUri().toArray(new String[0]));
	}
}
 
Example #2
Source File: Oauth2AuthorizationServerConfig.java    From spring-security-oauth2-demo with GNU General Public License v3.0 5 votes vote down vote up
private void configClient(ClientDetailsServiceConfigurer clients) throws Exception {
    InMemoryClientDetailsServiceBuilder builder = clients.inMemory();
    for (BaseClientDetails client : clientDetails.getClient()) {
        ClientDetailsServiceBuilder<InMemoryClientDetailsServiceBuilder>.ClientBuilder clientBuilder =
                builder.withClient(client.getClientId());
        clientBuilder
                .secret(client.getClientSecret())
                .resourceIds(client.getResourceIds().toArray(new String[0]))
                .authorizedGrantTypes(client.getAuthorizedGrantTypes().toArray(new String[0]))
                .authorities(
                        AuthorityUtils.authorityListToSet(client.getAuthorities())
                                .toArray(new String[0]))
                .scopes(client.getScope().toArray(new String[0]));
        if (client.getAutoApproveScopes() != null) {
            clientBuilder.autoApprove(
                    client.getAutoApproveScopes().toArray(new String[0]));
        }
        if (client.getAccessTokenValiditySeconds() != null) {
            clientBuilder.accessTokenValiditySeconds(
                    client.getAccessTokenValiditySeconds());
        }
        if (client.getRefreshTokenValiditySeconds() != null) {
            clientBuilder.refreshTokenValiditySeconds(
                    client.getRefreshTokenValiditySeconds());
        }
        if (client.getRegisteredRedirectUri() != null) {
            clientBuilder.redirectUris(
                    client.getRegisteredRedirectUri().toArray(new String[0]));
        }
    }
}
 
Example #3
Source File: AuthServerConfig.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(final ClientDetailsServiceConfigurer clients) throws Exception {
	ClientDetailsServiceBuilder<InMemoryClientDetailsServiceBuilder>.ClientBuilder builder = clients
			.inMemory().withClient(this.details.getClientId());
	builder.secret(this.details.getClientSecret())
			.resourceIds(this.details.getResourceIds().toArray(new String[0]))
			.authorizedGrantTypes(
					this.details.getAuthorizedGrantTypes().toArray(new String[0]))
			.authorities(AuthorityUtils
					.authorityListToSet(this.details.getAuthorities())
					.toArray(new String[0]))
			.scopes(this.details.getScope().toArray(new String[0]));

	if (this.details.getAutoApproveScopes() != null) {
		builder.autoApprove(
				this.details.getAutoApproveScopes().toArray(new String[0]));
	}
	if (this.details.getAccessTokenValiditySeconds() != null) {
		builder.accessTokenValiditySeconds(
				this.details.getAccessTokenValiditySeconds());
	}
	if (this.details.getRefreshTokenValiditySeconds() != null) {
		builder.refreshTokenValiditySeconds(
				this.details.getRefreshTokenValiditySeconds());
	}
	if (this.details.getRegisteredRedirectUri() != null) {
		builder.redirectUris(
				this.details.getRegisteredRedirectUri().toArray(new String[0]));
	}
}
 
Example #4
Source File: AuthServerConfig.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(final ClientDetailsServiceConfigurer clients) throws Exception {
	ClientDetailsServiceBuilder<InMemoryClientDetailsServiceBuilder>.ClientBuilder builder = clients
			.inMemory().withClient(this.details.getClientId());
	builder.secret(this.details.getClientSecret())
			.resourceIds(this.details.getResourceIds().toArray(new String[0]))
			.authorizedGrantTypes(
					this.details.getAuthorizedGrantTypes().toArray(new String[0]))
			.authorities(AuthorityUtils
					.authorityListToSet(this.details.getAuthorities())
					.toArray(new String[0]))
			.scopes(this.details.getScope().toArray(new String[0]));

	if (this.details.getAutoApproveScopes() != null) {
		builder.autoApprove(
				this.details.getAutoApproveScopes().toArray(new String[0]));
	}
	if (this.details.getAccessTokenValiditySeconds() != null) {
		builder.accessTokenValiditySeconds(
				this.details.getAccessTokenValiditySeconds());
	}
	if (this.details.getRefreshTokenValiditySeconds() != null) {
		builder.refreshTokenValiditySeconds(
				this.details.getRefreshTokenValiditySeconds());
	}
	if (this.details.getRegisteredRedirectUri() != null) {
		builder.redirectUris(
				this.details.getRegisteredRedirectUri().toArray(new String[0]));
	}
}
 
Example #5
Source File: AuthorizationServerConfiguration.java    From lolibox with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
    // TODO Add JPA Builder
    JdbcClientDetailsServiceBuilder builder = clients
            .jdbc(ds);
    if (this.clients != null) {
        FinalValueHolder<ClientDetailsServiceBuilder> detailHolder = new FinalValueHolder<>(builder);
        this.clients.forEach(c -> detailHolder.setValue(detailHolder.getValue().withClient(c.getName()).secret(c.getSecret())
                .authorizedGrantTypes("password")
                .authorities("ROLE_CLIENT")
                .scopes("read", "write")
                .resourceIds("oauth2-resource")
                .accessTokenValiditySeconds(Integer.MAX_VALUE).and()));
    }
}