use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-security-oauth by spring-projects.
the class ClientScopeVoterTests method init.
@Before
public void init() {
AuthorizationRequest authorizationRequest = new AuthorizationRequest();
authorizationRequest.setClientId("client");
authorizationRequest.setScope(Arrays.asList("read", "write"));
authentication = new OAuth2Authentication(authorizationRequest.createOAuth2Request(), userAuthentication);
InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService();
client = new BaseClientDetails("client", "source", "read,write", "authorization_code,client_credentials", "read");
clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", client));
voter.setClientDetailsService(clientDetailsService);
}
use of org.springframework.security.oauth2.provider.client.BaseClientDetails in project spring-boot by spring-projects.
the class OAuth2AutoConfigurationTests method testAuthorizationServerOverride.
@Test
public void testAuthorizationServerOverride() {
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "security.oauth2.resourceId:resource-id");
this.context.register(AuthorizationAndResourceServerConfiguration.class, CustomAuthorizationServer.class, MinimalSecureWebApplication.class);
this.context.refresh();
BaseClientDetails config = new BaseClientDetails();
config.setClientId("client");
config.setClientSecret("secret");
config.setResourceIds(Arrays.asList("resource-id"));
config.setAuthorizedGrantTypes(Arrays.asList("password"));
config.setAuthorities(AuthorityUtils.commaSeparatedStringToAuthorityList("USER"));
config.setScope(Arrays.asList("read"));
assertThat(countBeans(AUTHORIZATION_SERVER_CONFIG)).isEqualTo(0);
assertThat(countBeans(RESOURCE_SERVER_CONFIG)).isEqualTo(1);
verifyAuthentication(config);
}
Aggregations