@Bean(name = "githubOAuth2Resource") public OAuth2ProtectedResourceDetails geoServerOAuth2Resource() { return super.geoServerOAuth2Resource(); }
/** Must have "session" scope */ @Bean(name = "githubOauth2RestTemplate") @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS) public OAuth2RestTemplate geoServerOauth2RestTemplate() { OAuth2RestTemplate template = super.geoServerOauth2RestTemplate(); List<HttpMessageConverter<?>> messageConverters = template.getMessageConverters(); messageConverters.add(new MappingJackson2HttpMessageConverter()); return template; } }
@Override public void open() throws Exception { configuration = new GoogleOAuth2SecurityConfiguration(); configuration.setAccessTokenRequest(accessTokenRequest); resource = (AuthorizationCodeResourceDetails) configuration.geoServerOAuth2Resource(); assertNotNull(resource); resource.setTokenName("bearer_token"); restTemplate = configuration.geoServerOauth2RestTemplate(); assertNotNull(restTemplate); request = mock(ClientHttpRequest.class); headers = new HttpHeaders(); when(request.getHeaders()).thenReturn(headers); ClientHttpResponse response = mock(ClientHttpResponse.class); HttpStatus statusCode = HttpStatus.OK; when(response.getStatusCode()).thenReturn(statusCode); when(request.execute()).thenReturn(response); }
@Override public void open() throws Exception { configuration = new GitHubOAuth2SecurityConfiguration(); configuration.setAccessTokenRequest(accessTokenRequest); resource = (AuthorizationCodeResourceDetails) configuration.geoServerOAuth2Resource(); assertNotNull(resource); resource.setTokenName("bearer_token"); restTemplate = configuration.geoServerOauth2RestTemplate(); assertNotNull(restTemplate); request = mock(ClientHttpRequest.class); headers = new HttpHeaders(); when(request.getHeaders()).thenReturn(headers); ClientHttpResponse response = mock(ClientHttpResponse.class); HttpStatus statusCode = HttpStatus.OK; when(response.getStatusCode()).thenReturn(statusCode); when(request.execute()).thenReturn(response); }
@Override public void open() throws Exception { configuration = new OpenIdConnectSecurityConfiguration(); configuration.setAccessTokenRequest(accessTokenRequest); resource = (AuthorizationCodeResourceDetails) configuration.geoServerOAuth2Resource(); assertNotNull(resource); resource.setTokenName("bearer_token"); restTemplate = configuration.geoServerOauth2RestTemplate(); assertNotNull(restTemplate); request = mock(ClientHttpRequest.class); headers = new HttpHeaders(); when(request.getHeaders()).thenReturn(headers); ClientHttpResponse response = mock(ClientHttpResponse.class); HttpStatus statusCode = HttpStatus.OK; when(response.getStatusCode()).thenReturn(statusCode); when(request.execute()).thenReturn(response); }