本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例13: accessTokenConverter
import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Bean
public AccessTokenConverter accessTokenConverter() {
DefaultAccessTokenConverter converter = new DefaultAccessTokenConverter();
converter.setUserTokenConverter(userTokenConverter());
return converter;
}
示例14: JweTokenEnhancer
import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
public JweTokenEnhancer(AccessTokenConverter tokenConverter,
JweTokenSerializer tokenSerializer) {
this.tokenConverter = tokenConverter;
this.tokenSerializer = tokenSerializer;
}
示例15: accessTokenConverter
import org.springframework.security.oauth2.provider.token.AccessTokenConverter; //导入依赖的package包/类
@Bean
public AccessTokenConverter accessTokenConverter() {
return new DefaultAccessTokenConverter();
}