use of org.springframework.security.oauth2.provider.client.JdbcClientDetailsService in project spring-security-oauth by spring-projects.
the class JdbcClientDetailsServiceTests method testLoadingClientIdWithSingleDetailsInCustomTable.
@Test
public void testLoadingClientIdWithSingleDetailsInCustomTable() {
jdbcTemplate.update(CUSTOM_INSERT_SQL, "clientIdWithSingleDetails", "mySecret", "myResource", "myScope", "myAuthorizedGrantType", "myRedirectUri", "myAuthority");
JdbcClientDetailsService customService = new JdbcClientDetailsService(db);
customService.setSelectClientDetailsSql("select appId, appSecret, resourceIds, scope, " + "grantTypes, redirectUrl, authorities, access_token_validity, refresh_token_validity, additionalInformation, autoApproveScopes from ClientDetails where appId = ?");
ClientDetails clientDetails = customService.loadClientByClientId("clientIdWithSingleDetails");
assertEquals("clientIdWithSingleDetails", clientDetails.getClientId());
assertTrue(clientDetails.isSecretRequired());
assertEquals("mySecret", clientDetails.getClientSecret());
assertTrue(clientDetails.isScoped());
assertEquals(1, clientDetails.getScope().size());
assertEquals("myScope", clientDetails.getScope().iterator().next());
assertEquals(1, clientDetails.getResourceIds().size());
assertEquals("myResource", clientDetails.getResourceIds().iterator().next());
assertEquals(1, clientDetails.getAuthorizedGrantTypes().size());
assertEquals("myAuthorizedGrantType", clientDetails.getAuthorizedGrantTypes().iterator().next());
assertEquals("myRedirectUri", clientDetails.getRegisteredRedirectUri().iterator().next());
assertEquals(1, clientDetails.getAuthorities().size());
assertEquals("myAuthority", clientDetails.getAuthorities().iterator().next().getAuthority());
}
use of org.springframework.security.oauth2.provider.client.JdbcClientDetailsService 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.client.JdbcClientDetailsService in project spring-security-oauth by spring-projects.
the class JdbcClientDetailsServiceTests method setUp.
@Before
public void setUp() throws Exception {
// creates a HSQL in-memory db populated from default scripts
// classpath:schema.sql and classpath:data.sql
db = new EmbeddedDatabaseBuilder().addDefaultScripts().build();
jdbcTemplate = new JdbcTemplate(db);
service = new JdbcClientDetailsService(db);
}
Aggregations