use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.
the class ApprovalStoreUserApprovalHandlerTests method testAutoapprovedScopes.
@Test
public void testAutoapprovedScopes() {
handler.setClientDetailsService(clientDetailsService);
BaseClientDetails client = new BaseClientDetails("client", null, "read", "authorization_code", null);
client.setAutoApproveScopes(new HashSet<String>(Arrays.asList("read")));
clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", client));
AuthorizationRequest authorizationRequest = new AuthorizationRequest("client", Arrays.asList("read"));
AuthorizationRequest result = handler.checkForPreApproval(authorizationRequest, userAuthentication);
assertTrue(result.isApproved());
}
use of org.springframework.security.oauth2.provider.client.BaseClientDetails 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"));
}
use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.
the class BaseClientDetailsTests method testBaseClientDetailsNoAutoApprove.
@Test
public void testBaseClientDetailsNoAutoApprove() {
BaseClientDetails details = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER");
details.setAutoApproveScopes(StringUtils.commaDelimitedListToSet("none"));
assertFalse(details.isAutoApprove("read"));
}
use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.
the class BaseClientDetailsTests method testJsonSerializeAdditionalInformation.
@Test
public void testJsonSerializeAdditionalInformation() throws Exception {
BaseClientDetails details = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER");
details.setClientId("foo");
details.setAdditionalInformation(Collections.singletonMap("foo", "bar"));
String value = new ObjectMapper().writeValueAsString(details);
assertTrue(value.contains("\"foo\":\"bar\""));
}
use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.
the class BaseClientDetailsTests method testJsonSerialize.
@Test
public void testJsonSerialize() throws Exception {
BaseClientDetails details = new BaseClientDetails("foo", "", "foo,bar", "authorization_code", "ROLE_USER");
details.setClientId("foo");
details.setClientSecret("bar");
String value = new ObjectMapper().writeValueAsString(details);
assertTrue(value.contains("client_id"));
assertTrue(value.contains("client_secret"));
assertTrue(value.contains("authorized_grant_types"));
assertTrue(value.contains("[\"ROLE_USER\"]"));
}
Aggregations