org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails Java Examples
The following examples show how to use
org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails.
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: ClientConfiguration.java From OAuth-2.0-Cookbook with MIT License | 6 votes |
@Bean public OAuth2ProtectedResourceDetails implicitResourceDetails() { ImplicitResourceDetails resourceDetails = new ImplicitResourceDetails(); //@formatter:off resourceDetails.setId("oauth2server"); resourceDetails.setTokenName("oauth_token"); resourceDetails.setClientId("clientapp"); resourceDetails.setUserAuthorizationUri("http://localhost:8080/oauth/authorize"); resourceDetails.setScope(Arrays.asList("read_profile")); resourceDetails.setPreEstablishedRedirectUri("http://localhost:9000/callback"); resourceDetails.setUseCurrentUri(false); resourceDetails.setClientAuthenticationScheme(AuthenticationScheme.query); //@formatter:on return resourceDetails; }
Example #2
Source File: CustomImplicitAccessTokenProvider.java From OAuth-2.0-Cookbook with MIT License | 6 votes |
private Map<String, String> getParametersForTokenRequest( ImplicitResourceDetails resource, AccessTokenRequest request) { Map<String, String> queryString = new HashMap<String, String>(); queryString.put("response_type", "token"); queryString.put("client_id", resource.getClientId()); if (resource.isScoped()) { queryString.put("scope", resource.getScope().stream().reduce((a, b) -> a + " " + b) .get()); } String redirectUri = resource.getRedirectUri(request); if (redirectUri == null) { throw new IllegalStateException( "No redirect URI available in request"); } queryString.put("redirect_uri", redirectUri); return queryString; }
Example #3
Source File: Oauth2ClientRestTemplate.java From spring-boot with Apache License 2.0 | 6 votes |
/** * 该方式没有实验成功,设置为 Deprecated! * <p> * 演示 grant_type=implicit 时,获取资源的方法 * * @param client_id * @param client_secret 取决于 AuthorizationServer 设置,如果 client 设置了secret,则此项参数为必需,否则可以没有 * @param authorization_uri * @param access_token_uri * @param scope * @return */ @Deprecated public OAuth2RestOperations implicitResourceRestTemplate(String client_id, String client_secret, String authorization_uri, String access_token_uri, String... scope) { // 防止 url 写错 if (!authorization_uri.contains("authorize")) throw new RuntimeException("uri is wrong : authorization_uri" + authorization_uri); ImplicitResourceDetails details = new ImplicitResourceDetails(); details.setId("2"); details.setClientId(client_id); if (client_secret != null && !client_secret.isEmpty()) details.setClientSecret(client_secret); details.setAccessTokenUri(authorization_uri); details.setClientAuthenticationScheme(AuthenticationScheme.header); details.setUseCurrentUri(true); details.setScope(Arrays.asList(scope)); // return restTemplate; return new OAuth2RestTemplate(details, oAuth2ClientContext); }
Example #4
Source File: ClientConfiguration.java From openapi-generator with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id") @ConfigurationProperties("openapipetstore.security.petstoreAuth") public ImplicitResourceDetails petstoreAuthResourceDetails() { ImplicitResourceDetails details = new ImplicitResourceDetails(); details.setUserAuthorizationUri("http://petstore.swagger.io/api/oauth/dialog"); return details; }
Example #5
Source File: ClientConfiguration.java From openapi-generator with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id") @ConfigurationProperties("openapipetstore.security.petstoreAuth") public ImplicitResourceDetails petstoreAuthResourceDetails() { ImplicitResourceDetails details = new ImplicitResourceDetails(); details.setUserAuthorizationUri("http://petstore.swagger.io/api/oauth/dialog"); return details; }
Example #6
Source File: CustomImplicitAccessTokenProvider.java From OAuth-2.0-Cookbook with MIT License | 5 votes |
@Override public OAuth2AccessToken obtainAccessToken( OAuth2ProtectedResourceDetails details, AccessTokenRequest request) throws RuntimeException { ImplicitResourceDetails resource = (ImplicitResourceDetails) details; Map<String, String> requestParameters = getParametersForTokenRequest( resource, request); UserRedirectRequiredException redirectException = new UserRedirectRequiredException( resource.getUserAuthorizationUri(), requestParameters); throw redirectException; }
Example #7
Source File: CustomImplicitAccessTokenProvider.java From OAuth-2.0-Cookbook with MIT License | 4 votes |
@Override public boolean supportsResource(OAuth2ProtectedResourceDetails resource) { return resource instanceof ImplicitResourceDetails && "implicit".equals(resource.getGrantType()); }