Java Code Examples for org.springframework.security.oauth2.provider.implicit.ImplicitTokenGranter

The following examples show how to use org.springframework.security.oauth2.provider.implicit.ImplicitTokenGranter. These examples are extracted from open source projects. 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
protected TokenGranter getTokenGranter(String grantType) {

        if ("authorization_code".equals(grantType)) {
            return new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetailsService, this.oAuth2RequestFactory);
        } else if ("password".equals(grantType)) {
            return new ResourceOwnerPasswordTokenGranter(getAuthenticationManager(), tokenServices, clientDetailsService, this.oAuth2RequestFactory);
        } else if ("refresh_token".equals(grantType)) {
            return new RefreshTokenGranter(tokenServices, clientDetailsService, this.oAuth2RequestFactory);
        } else if ("client_credentials".equals(grantType)) {
            return new ClientCredentialsTokenGranter(tokenServices, clientDetailsService, this.oAuth2RequestFactory);
        } else if ("implicit".equals(grantType)) {
            return new ImplicitTokenGranter(tokenServices, clientDetailsService, this.oAuth2RequestFactory);
        } else {
            throw new UnsupportedGrantTypeException("Unsupport grant_type: " + grantType);
        }
    }
 
Example 2
/**
 * Return all granters within oauth2
 * Contains custom
 *
 * @return TokenGranter
 */
private List<TokenGranter> getDefaultTokenGranters() {
    ClientDetailsService clientDetails = clientDetailsService;
    AuthorizationServerTokenServices tokenServices = tokenServices();
    AuthorizationCodeServices authorizationCodeServices = authorizationCodeServices();
    OAuth2RequestFactory requestFactory = requestFactory();

    List<TokenGranter> tokenGranters = new ArrayList<TokenGranter>();
    // code
    tokenGranters.add(new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetails,
            requestFactory));

    // refresh token
    tokenGranters.add(new RefreshTokenGranter(tokenServices, clientDetails, requestFactory));

    // implicit
    ImplicitTokenGranter implicit = new ImplicitTokenGranter(tokenServices, clientDetails, requestFactory);
    tokenGranters.add(implicit);

    // client
    tokenGranters.add(new ClientCredentialsTokenGranter(tokenServices, clientDetails, requestFactory));

    // password
    if (authenticationManager != null) {
        tokenGranters.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices,
                clientDetails, requestFactory));
    }

    // have custom token granter
    if (!ObjectUtils.isEmpty(apiBootOauthTokenGranters)) {
        apiBootOauthTokenGranters.stream().forEach(apiBootOauthTokenGranter -> tokenGranters.add(new DefaultApiBootOauthTokenGranter(tokenServices, clientDetailsService, requestFactory, apiBootOauthTokenGranter)));
    }

    return tokenGranters;
}
 
Example 3
/**
 * Return all granters within oauth2
 * Contains custom
 *
 * @return TokenGranter
 */
private List<TokenGranter> getDefaultTokenGranters() {
    ClientDetailsService clientDetails = clientDetailsService;
    AuthorizationServerTokenServices tokenServices = tokenServices();
    AuthorizationCodeServices authorizationCodeServices = authorizationCodeServices();
    OAuth2RequestFactory requestFactory = requestFactory();

    List<TokenGranter> tokenGranters = new ArrayList<TokenGranter>();
    // code
    tokenGranters.add(new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetails,
            requestFactory));

    // refresh token
    tokenGranters.add(new RefreshTokenGranter(tokenServices, clientDetails, requestFactory));

    // implicit
    ImplicitTokenGranter implicit = new ImplicitTokenGranter(tokenServices, clientDetails, requestFactory);
    tokenGranters.add(implicit);

    // client
    tokenGranters.add(new ClientCredentialsTokenGranter(tokenServices, clientDetails, requestFactory));

    // password
    if (authenticationManager != null) {
        tokenGranters.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices,
                clientDetails, requestFactory));
    }

    // have custom token granter
    if (!ObjectUtils.isEmpty(apiBootOauthTokenGranters)) {
        apiBootOauthTokenGranters.stream().forEach(apiBootOauthTokenGranter -> tokenGranters.add(new DefaultApiBootOauthTokenGranter(tokenServices, clientDetailsService, requestFactory, apiBootOauthTokenGranter)));
    }

    return tokenGranters;
}
 
Example 4
Source Project: oauth2lab   Source File: OAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
public TokenGranter tokenGranter() {

    DefaultOAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientDetailsService());

    AuthorizationCodeServices codeServices = authorizationCodeServices();

    AuthorizationServerTokenServices tokenServices = tokenServices();
    List<TokenGranter> tokenGranters = Arrays.asList(
            new AuthorizationCodeTokenGranter(tokenServices, codeServices, clientDetailsService(), requestFactory),
            new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService(), requestFactory),
            new ImplicitTokenGranter(tokenServices, clientDetailsService(), requestFactory));

    return new CompositeTokenGranter(tokenGranters);
}
 
Example 5
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
public TokenGranter tokenGranter() {

    DefaultOAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientDetailsService());

    AuthorizationCodeServices codeServices = authorizationCodeServices();

    AuthorizationServerTokenServices tokenServices = tokenServices();
    List<TokenGranter> tokenGranters = Arrays.asList(
            new CustomAuthCodeTokenGranter(tokenServices, codeServices, clientDetailsService(), requestFactory),
            new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService(), requestFactory),
            new ImplicitTokenGranter(tokenServices, clientDetailsService(), requestFactory));

    return new CompositeTokenGranter(tokenGranters);
}
 
Example 6
Source Project: springcloud-oauth2   Source File: AuthorizationConfig.java    License: MIT License votes vote down vote up
/**
     * 创建grant_type列表
     * @param endpoints
     * @return
     */
    private TokenGranter tokenGranter(AuthorizationServerEndpointsConfigurer endpoints) {
        List<TokenGranter> list = new ArrayList<>();
        // 这里配置密码模式、刷新token模式、自定义手机号验证码模式、授权码模式、简化模式
        list.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory()));
        list.add(new RefreshTokenGranter(endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory()));
        list.add(new MobileCodeTokenGranter(authenticationManager,endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory()));
        list.add(new AuthorizationCodeTokenGranter(endpoints.getTokenServices(),endpoints.getAuthorizationCodeServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory()));
        list.add(new ImplicitTokenGranter(endpoints.getTokenServices(),endpoints.getClientDetailsService(),endpoints.getOAuth2RequestFactory()));
        return new CompositeTokenGranter(list);
    }