当前位置: 首页>>代码示例>>Java>>正文


Java AccessTokenConverter类代码示例

本文整理汇总了Java中org.springframework.security.oauth2.provider.token.AccessTokenConverter的典型用法代码示例。如果您正苦于以下问题:Java AccessTokenConverter类的具体用法?Java AccessTokenConverter怎么用?Java AccessTokenConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AccessTokenConverter类属于org.springframework.security.oauth2.provider.token包,在下文中一共展示了AccessTokenConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadAuthentication

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Override
public OAuth2Authentication loadAuthentication(String token) {
    AccessToken accessToken = validateAccessToken(token);

    Set<String> scopes = new HashSet<>();
    if (accessToken.getScopes() != null) {
        for (Scope scope : accessToken.getScopes()) {
            scopes.add(scope.toString());
        }
    }

    Map<String, String> parameters = new HashMap<>();
    parameters.put(AccessTokenConverter.CLIENT_ID, accessToken.getClientId());
    OAuth2Request authRequest = new OAuth2Request(parameters, accessToken.getClientId(), null, true, scopes, null, null,
            null, null);

    Authentication auth = null;

    if (!accessToken.isClientOnly()) {
        User authUser = new User.Builder(accessToken.getUserName()).setId(accessToken.getUserId()).build();

        auth = new UsernamePasswordAuthenticationToken(authUser, null, new ArrayList<GrantedAuthority>());
    }

    return new OAuth2Authentication(authRequest, auth);
}
 
开发者ID:osiam,项目名称:resource-server,代码行数:27,代码来源:AccessTokenValidationService.java

示例2: createRefreshTokenCookie

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
/**
 * Create a cookie out of the given refresh token.
 * Refresh token cookies contain the base64 encoded refresh token (a JWT token).
 * They also contain a hint whether the refresh token was for remember me or not.
 * If not, then the cookie will be prefixed by the timestamp it was created at followed by a pipe '|'.
 * This gives us the chance to expire session cookies regardless of the token duration.
 */
private Cookie createRefreshTokenCookie(OAuth2RefreshToken refreshToken, boolean rememberMe) {
    int maxAge = -1;
    String name = SESSION_TOKEN_COOKIE;
    String value = refreshToken.getValue();
    if (rememberMe) {
        name = REFRESH_TOKEN_COOKIE;
        //get expiration in seconds from the token's "exp" claim
        Integer exp = getClaim(refreshToken.getValue(), AccessTokenConverter.EXP, Integer.class);
        if (exp != null) {
            int now = (int) (System.currentTimeMillis() / 1000L);
            maxAge = exp - now;
            log.debug("refresh token valid for another {} secs", maxAge);
            //let cookie expire a bit earlier than the token to avoid race conditions
            maxAge -= REFRESH_TOKEN_EXPIRATION_WINDOW_SECS;
        }
    }
    Cookie refreshTokenCookie = new Cookie(name, value);
    refreshTokenCookie.setMaxAge(maxAge);
    return refreshTokenCookie;
}
 
开发者ID:jhipster,项目名称:generator-jhipster,代码行数:28,代码来源:_OAuth2CookieHelper.java

示例3: OAuth2AuthorizationServerConfiguration

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
public OAuth2AuthorizationServerConfiguration(BaseClientDetails details,
		AuthenticationConfiguration authenticationConfiguration,
		ObjectProvider<TokenStore> tokenStore,
		ObjectProvider<AccessTokenConverter> tokenConverter,
		AuthorizationServerProperties properties) throws Exception {
	this.details = details;
	this.authenticationManager = authenticationConfiguration.getAuthenticationManager();
	this.tokenStore = tokenStore.getIfAvailable();
	this.tokenConverter = tokenConverter.getIfAvailable();
	this.properties = properties;
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:12,代码来源:OAuth2AuthorizationServerConfiguration.java

示例4: jwtAccessTokenConverter

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
/**
 * Token converter and enhancer
 * @return
 */
@Bean
public JwtAccessTokenConverter jwtAccessTokenConverter(AccessTokenConverter accessTokenConverter) {
	JwtAccessTokenConverter tokenConverter = new JwtAccessTokenConverter();
	tokenConverter.setAccessTokenConverter(accessTokenConverter);
	return tokenConverter;
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:11,代码来源:SecurityConfig.java

示例5: OAuth2AuthorizationServerConfig

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
public OAuth2AuthorizationServerConfig(AccessTokenConverter accessTokenConverter, ApprovalStore approvalStore, AuthenticationManager authenticationManager, OAuth2ClientService clientService, TokenEnhancer tokenEnhancer, TokenStore tokenStore) {
	this.accessTokenConverter = accessTokenConverter;
	this.approvalStore = approvalStore;
	this.authenticationManager = authenticationManager;
	this.clientService = clientService;
	this.tokenEnhancer = tokenEnhancer;
	this.tokenStore = tokenStore;
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:9,代码来源:OAuth2AuthorizationServerConfig.java

示例6: accessTokenConverter

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Bean
@Primary
public AccessTokenConverter accessTokenConverter() {
    DefaultAccessTokenConverter defaultAccessTokenConverter = new DefaultAccessTokenConverter();
    defaultAccessTokenConverter.setUserTokenConverter(userAuthenticationConverter());
    return defaultAccessTokenConverter;
}
 
开发者ID:themadweaz,项目名称:weazbootgradle,代码行数:8,代码来源:SharedTokenConfiguration.java

示例7: AuthorizationServerConfiguration

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Autowired
public AuthorizationServerConfiguration(AuthenticationManager authenticationManager,
                                        CustomClientDetailsService customClientDetailsService,
                                        AuthorizationServerTokenServices tokenServices, TokenStore tokenStore,
                                        OAuth2RequestFactory requestFactory, UserDetailsService userDetailsService, AccessTokenConverter accessTokenConverter) {
    super();
    this.authenticationManager = authenticationManager;
    this.customClientDetailsService = customClientDetailsService;
    this.tokenServices = tokenServices;
    this.tokenStore = tokenStore;
    this.requestFactory = requestFactory;
    this.userDetailsService = userDetailsService;
    this.accessTokenConverter = accessTokenConverter;
}
 
开发者ID:themadweaz,项目名称:weazbootgradle,代码行数:15,代码来源:AuthorizationServerConfiguration.java

示例8: accessTokenConverter

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
/**
 * AccessTokenConverter bean initializer.
 */
@Bean
public AccessTokenConverter accessTokenConverter() {
  DefaultAccessTokenConverter defaultAccessTokenConverter = new DefaultAccessTokenConverter();
  defaultAccessTokenConverter.setUserTokenConverter(new CustomUserAuthenticationConverter());
  return defaultAccessTokenConverter;
}
 
开发者ID:OpenLMIS,项目名称:openlmis-stockmanagement,代码行数:10,代码来源:ResourceServerSecurityConfiguration.java

示例9: AuthorizationServerConfiguration

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
public AuthorizationServerConfiguration(BaseClientDetails details, AuthenticationManager authenticationManager,
                                        ObjectProvider<TokenStore> tokenStore,
                                        ObjectProvider<AccessTokenConverter> tokenConverter,
                                        ObjectProvider<TokenEnhancer> tokenEnhancer,
                                        AuthorizationServerProperties properties) {
    super(details, authenticationManager, tokenStore, tokenConverter, properties);
    this.tokenEnhancer = tokenEnhancer.getIfAvailable();
}
 
开发者ID:unbroken-dome,项目名称:jsonwebtoken,代码行数:9,代码来源:JwtOAuth2AutoConfiguration.java

示例10: AuthzResourceServerTokenServices

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
public AuthzResourceServerTokenServices(String authzCheckTokenClientId, String authzCheckTokenSecret, String authzCheckTokenEndpointUrl, AccessTokenConverter accessTokenConverter) {
  super();
  setCheckTokenEndpointUrl(authzCheckTokenEndpointUrl);
  setClientId(authzCheckTokenClientId);
  setClientSecret(authzCheckTokenSecret);

  setAccessTokenConverter(accessTokenConverter);

}
 
开发者ID:OpenConext,项目名称:OpenConext-voot,代码行数:10,代码来源:AuthzResourceServerTokenServices.java

示例11: accessTokenConverter

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Bean
public AccessTokenConverter accessTokenConverter() throws IOException {
    final JwtAccessTokenConverter jwtTokenEnhancer = new JwtAccessTokenConverter();
    jwtTokenEnhancer.setSigningKey(IOUtils.toString(getClass().getResourceAsStream("/security/tokensigningkey")));
    jwtTokenEnhancer.setVerifierKey(IOUtils.toString(getClass().getResourceAsStream("/security/tokensigningkey.pub")));
    return jwtTokenEnhancer;
}
 
开发者ID:as-ideas,项目名称:crowdsource,代码行数:8,代码来源:SecurityConfig.java

示例12: dashboardAccessTokenConverter

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Bean(name = "dashboardAccessTokenConverter")
public AccessTokenConverter dashboardAccessTokenConverter() {
    final DefaultAccessTokenConverter defaultAccessTokenConverter = new DefaultAccessTokenConverter();

    final DefaultUserAuthenticationConverter userTokenConverter = new DefaultUserAuthenticationConverter();
    userTokenConverter.setDefaultAuthorities(new String[]{"ROLE_" + ApplicationWebSecurityConfigurerAdapter.ROLE_DASHBOARD});

    defaultAccessTokenConverter.setUserTokenConverter(userTokenConverter);

    return defaultAccessTokenConverter;
}
 
开发者ID:bsblabs,项目名称:cf-sample-service,代码行数:12,代码来源:DashboardSecurityConfiguration.java

示例13: accessTokenConverter

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Bean
public AccessTokenConverter accessTokenConverter() {
    DefaultAccessTokenConverter converter = new DefaultAccessTokenConverter();
    converter.setUserTokenConverter(userTokenConverter());
    return converter;
}
 
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:7,代码来源:OAuth2ResourceServer.java

示例14: JweTokenEnhancer

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
public JweTokenEnhancer(AccessTokenConverter tokenConverter,
    JweTokenSerializer tokenSerializer) {
    this.tokenConverter = tokenConverter;
    this.tokenSerializer = tokenSerializer;
}
 
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:6,代码来源:JweTokenEnhancer.java

示例15: accessTokenConverter

import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Bean
public AccessTokenConverter accessTokenConverter() {
	return new DefaultAccessTokenConverter();
}
 
开发者ID:cypherkey,项目名称:multi-tenant-rest-api,代码行数:5,代码来源:ResourceServerConfig.java


注:本文中的org.springframework.security.oauth2.provider.token.AccessTokenConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。