Java Code Examples for org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails#getClientId()
The following examples show how to use
org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails#getClientId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuth2Util.java From DAFramework with MIT License | 6 votes |
public static Filter wechat(AuthorizationCodeResourceDetails client, ResourceServerProperties resourceServerProperties, String path, OAuth2ClientContext oauth2ClientContext) { OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(path); OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client, oauth2ClientContext); AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider(); accessTokenProvider.setAuthorizationRequestEnhancer((request, resource, form, headers) -> { form.set("appid", resource.getClientId()); form.set("secret", resource.getClientSecret()); form.set("scope", "snsapi_userinfo"); form.set("response_type", "code"); form.set("#wechat_redirect", ""); }); accessTokenProvider.setMessageConverters(converters()); oAuth2RestTemplate.setAccessTokenProvider(accessTokenProvider); oAuth2RestTemplate.setRetryBadAccessTokens(true); oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate); UserInfoTokenServices tokenServices = new UserInfoTokenServices(resourceServerProperties.getUserInfoUri(), client.getClientId()); tokenServices.setRestTemplate(oAuth2RestTemplate); oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices); return oAuth2ClientAuthenticationFilter; }
Example 2
Source File: OAuth2Util.java From DAFramework with MIT License | 6 votes |
public static Filter general(AuthorizationCodeResourceDetails client, ResourceServerProperties resourceServerProperties, String path, OAuth2ClientContext oauth2ClientContext) { OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(path){ protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { super.successfulAuthentication(request, response, chain, authResult); OAuth2AccessToken accessToken = restTemplate.getAccessToken(); log.warn(new Gson().toJson(authResult)); log.warn(new Gson().toJson(accessToken)); } }; OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client, oauth2ClientContext); oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate); UserInfoTokenServices tokenServices = new UserInfoTokenServices(resourceServerProperties.getUserInfoUri(), client.getClientId()); tokenServices.setRestTemplate(oAuth2RestTemplate); oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices); return oAuth2ClientAuthenticationFilter; }
Example 3
Source File: MyAuthorizationCodeAccessTokenProvider.java From springboot-security-wechat with Apache License 2.0 | 4 votes |
protected UserApprovalRequiredException getUserApprovalSignal(AuthorizationCodeResourceDetails resource, AccessTokenRequest request) { String message = String.format("Do you approve the client '%s' to access your resources with scope=%s", new Object[]{resource.getClientId(), resource.getScope()}); return new UserApprovalRequiredException(resource.getUserAuthorizationUri(), Collections.singletonMap("user_oauth_approval", message), resource.getClientId(), resource.getScope()); }