use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class ResourceServerConfigurationTests method init.
@Before
public void init() {
token = new DefaultOAuth2AccessToken("FOO");
ClientDetails client = new BaseClientDetails("client", null, "read", "client_credentials", "ROLE_CLIENT");
authentication = new OAuth2Authentication(new TokenRequest(null, "client", null, "client_credentials").createOAuth2Request(client), null);
tokenStore.clear();
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class ClientDetailsServiceBeanDefinitionParserTests method testClientDetailsDefaultFlow.
@Test
public void testClientDetailsDefaultFlow() {
ClientDetails clientDetails = clientDetailsService.loadClientByClientId("my-client-id-default-flow");
assertNotNull(clientDetailsService);
assertEquals("my-client-id-default-flow", clientDetails.getClientId());
assertEquals(1, clientDetails.getRegisteredRedirectUri().size());
assertEquals("https://secure.mycompany.com", clientDetails.getRegisteredRedirectUri().iterator().next());
Set<String> grantTypes = clientDetails.getAuthorizedGrantTypes();
assertNotNull(grantTypes);
assertEquals(2, grantTypes.size());
assertTrue(grantTypes.contains("authorization_code"));
assertTrue(grantTypes.contains("refresh_token"));
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class ClientDetailsServiceBeanDefinitionParserTests method testClientDetailsFromNonPropertyFile.
@Test
public void testClientDetailsFromNonPropertyFile() {
// valid client details NOT from property file
ClientDetails clientDetails = clientDetailsService.loadClientByClientId("my-client-id-non-property-file");
assertNotNull(clientDetailsService);
assertEquals("my-client-id-non-property-file", clientDetails.getClientId());
assertEquals("my-client-secret-non-property-file", clientDetails.getClientSecret());
Set<String> grantTypes = clientDetails.getAuthorizedGrantTypes();
assertNotNull(grantTypes);
assertEquals(2, grantTypes.size());
assertTrue(grantTypes.contains("password"));
assertTrue(grantTypes.contains("authorization_code"));
Set<String> scopes = clientDetails.getScope();
assertNotNull(scopes);
assertEquals(2, scopes.size());
assertTrue(scopes.contains("scope1"));
assertTrue(scopes.contains("scope2"));
Collection<GrantedAuthority> authorities = clientDetails.getAuthorities();
assertNotNull(authorities);
assertEquals(2, authorities.size());
assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER"));
assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_ANONYMOUS"));
}
use of org.springframework.security.oauth2.provider.ClientDetails in project spring-security-oauth by spring-projects.
the class ApprovalStoreUserApprovalHandlerTests method init.
@Before
public void init() {
handler.setApprovalStore(store);
InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService();
Map<String, ClientDetails> map = new HashMap<String, ClientDetails>();
map.put("client", new BaseClientDetails("client", null, "read,write", "authorization_code", null));
clientDetailsService.setClientDetailsStore(map);
handler.setRequestFactory(new DefaultOAuth2RequestFactory(clientDetailsService));
userAuthentication = new UsernamePasswordAuthenticationToken("user", "N/A", AuthorityUtils.commaSeparatedStringToAuthorityList("USER"));
}
Aggregations