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 AbstractDefaultTokenServicesTests method testClientSpecificRefreshTokenExpiry.
@Test
public void testClientSpecificRefreshTokenExpiry() throws Exception {
getTokenServices().setRefreshTokenValiditySeconds(1000);
getTokenServices().setClientDetailsService(new ClientDetailsService() {
public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
BaseClientDetails client = new BaseClientDetails();
client.setRefreshTokenValiditySeconds(100);
client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "refresh_token"));
return client;
}
});
OAuth2AccessToken accessToken = getTokenServices().createAccessToken(createAuthentication());
DefaultExpiringOAuth2RefreshToken refreshToken = (DefaultExpiringOAuth2RefreshToken) accessToken.getRefreshToken();
Date expectedExpiryDate = new Date(System.currentTimeMillis() + 102 * 1000L);
assertTrue(expectedExpiryDate.after(refreshToken.getExpiration()));
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class AbstractDefaultTokenServicesTests method testClientSpecificTokenExpiry.
@Test
public void testClientSpecificTokenExpiry() throws Exception {
getTokenServices().setAccessTokenValiditySeconds(1000);
getTokenServices().setClientDetailsService(new ClientDetailsService() {
public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
BaseClientDetails client = new BaseClientDetails();
client.setAccessTokenValiditySeconds(100);
return client;
}
});
OAuth2AccessToken accessToken = getTokenServices().createAccessToken(createAuthentication());
assertTrue(100 >= accessToken.getExpiresIn());
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class AbstractDefaultTokenServicesTests method testClientInvalidated.
@Test(expected = InvalidTokenException.class)
public void testClientInvalidated() throws Exception {
final AtomicBoolean deleted = new AtomicBoolean();
getTokenServices().setClientDetailsService(new ClientDetailsService() {
public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
if (deleted.get()) {
throw new ClientRegistrationException("No such client: " + clientId);
}
BaseClientDetails client = new BaseClientDetails();
client.setRefreshTokenValiditySeconds(100);
client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "refresh_token"));
return client;
}
});
OAuth2AccessToken token = getTokenServices().createAccessToken(createAuthentication());
deleted.set(true);
OAuth2Authentication authentication = getTokenServices().loadAuthentication(token.getValue());
assertNotNull(authentication.getOAuth2Request());
}
Aggregations