use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class SparklrUserApprovalHandler method checkForPreApproval.
/**
* Allows automatic approval for a white list of clients in the implicit grant case.
*
* @param authorizationRequest The authorization request.
* @param userAuthentication the current user authentication
*
* @return An updated request if it has already been approved by the current user.
*/
@Override
public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizationRequest, Authentication userAuthentication) {
boolean approved = false;
// If we are allowed to check existing approvals this will short circuit the decision
if (useApprovalStore) {
authorizationRequest = super.checkForPreApproval(authorizationRequest, userAuthentication);
approved = authorizationRequest.isApproved();
} else {
if (clientDetailsService != null) {
Collection<String> requestedScopes = authorizationRequest.getScope();
try {
ClientDetails client = clientDetailsService.loadClientByClientId(authorizationRequest.getClientId());
for (String scope : requestedScopes) {
if (client.isAutoApprove(scope)) {
approved = true;
break;
}
}
} catch (ClientRegistrationException e) {
}
}
}
authorizationRequest.setApproved(approved);
return authorizationRequest;
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class AuthorizationServerEndpointsConfigurer method getDefaultTokenGranters.
private List<TokenGranter> getDefaultTokenGranters() {
ClientDetailsService clientDetails = clientDetailsService();
AuthorizationServerTokenServices tokenServices = tokenServices();
AuthorizationCodeServices authorizationCodeServices = authorizationCodeServices();
OAuth2RequestFactory requestFactory = requestFactory();
List<TokenGranter> tokenGranters = new ArrayList<TokenGranter>();
tokenGranters.add(new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetails, requestFactory));
tokenGranters.add(new RefreshTokenGranter(tokenServices, clientDetails, requestFactory));
ImplicitTokenGranter implicit = new ImplicitTokenGranter(tokenServices, clientDetails, requestFactory);
tokenGranters.add(implicit);
tokenGranters.add(new ClientCredentialsTokenGranter(tokenServices, clientDetails, requestFactory));
if (authenticationManager != null) {
tokenGranters.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetails, requestFactory));
}
return tokenGranters;
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class InMemoryClientDetailsServiceBuilder method performBuild.
@Override
protected ClientDetailsService performBuild() {
InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService();
clientDetailsService.setClientDetailsStore(clientDetails);
return clientDetailsService;
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class JdbcClientDetailsServiceBuilder method performBuild.
@Override
protected ClientDetailsService performBuild() {
Assert.state(dataSource != null, "You need to provide a DataSource");
JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
if (passwordEncoder != null) {
// This is used to encode secrets as they are added to the database (if it isn't set then the user has top
// pass in pre-encoded secrets)
clientDetailsService.setPasswordEncoder(passwordEncoder);
}
for (ClientDetails client : clientDetails) {
clientDetailsService.addClientDetails(client);
}
return clientDetailsService;
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class ResourceServerSecurityConfigurer method tokenServices.
private ResourceServerTokenServices tokenServices(HttpSecurity http) {
if (resourceTokenServices != null) {
return resourceTokenServices;
}
DefaultTokenServices tokenServices = new DefaultTokenServices();
tokenServices.setTokenStore(tokenStore());
tokenServices.setSupportRefreshToken(true);
tokenServices.setClientDetailsService(clientDetails());
this.resourceTokenServices = tokenServices;
return tokenServices;
}
Aggregations