protected void cancelToken(String value) { try { tokenServices.revokeToken(value); } catch (Exception e) { // ignore } }
/** * Delegates to the internal instance {@link JwtTokenStore#readAuthentication(OAuth2AccessToken)}. * * @param token the access token * @return the {@link OAuth2Authentication} representation of the access token */ @Override public OAuth2Authentication readAuthentication(OAuth2AccessToken token) { return this.delegate.readAuthentication(token); }
protected OAuth2AccessToken getAccessToken(ClientDetails client, TokenRequest tokenRequest) { return tokenServices.createAccessToken(getOAuth2Authentication(client, tokenRequest)); }
private ResourceServerTokenServices tokenServices(HttpSecurity http) { if (resourceTokenServices != null) { return resourceTokenServices; } DefaultTokenServices tokenServices = new DefaultTokenServices(); tokenServices.setTokenStore(tokenStore()); tokenServices.setSupportRefreshToken(true); tokenServices.setClientDetailsService(clientDetails()); this.resourceTokenServices = tokenServices; return tokenServices; }
private DefaultTokenServices createDefaultTokenServices() { DefaultTokenServices tokenServices = new DefaultTokenServices(); tokenServices.setTokenStore(tokenStore()); tokenServices.setSupportRefreshToken(true); tokenServices.setReuseRefreshToken(reuseRefreshToken); tokenServices.setClientDetailsService(clientDetailsService()); tokenServices.setTokenEnhancer(tokenEnhancer()); addUserDetailsService(tokenServices, this.userDetailsService); return tokenServices; }
public boolean revokeToken(String tokenValue) { OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue); if (accessToken == null) { return false; } if (accessToken.getRefreshToken() != null) { tokenStore.removeRefreshToken(accessToken.getRefreshToken()); } tokenStore.removeAccessToken(accessToken); return true; }
/** * Delegates to the internal instance {@link JwtTokenStore#readAccessToken(String)}. * * @param tokenValue the access token value * @return the {@link OAuth2AccessToken} representation of the access token value */ @Override public OAuth2AccessToken readAccessToken(String tokenValue) { return this.delegate.readAccessToken(tokenValue); }
/** * Delegates to the internal instance {@link JwtTokenStore#removeAccessToken(OAuth2AccessToken)}. * * @param token the access token */ @Override public void removeAccessToken(OAuth2AccessToken token) { this.delegate.removeAccessToken(token); }
private AccessTokenConverter accessTokenConverter() { if (this.accessTokenConverter == null) { accessTokenConverter = new DefaultAccessTokenConverter(); } return this.accessTokenConverter; }
/** * Loop over the {@link #setTokenEnhancers(List) delegates} passing the result into the next member of the chain. * * @see org.springframework.security.oauth2.provider.token.TokenEnhancer#enhance(org.springframework.security.oauth2.common.OAuth2AccessToken, * org.springframework.security.oauth2.provider.OAuth2Authentication) */ public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) { OAuth2AccessToken result = accessToken; for (TokenEnhancer enhancer : delegates) { result = enhancer.enhance(result, authentication); } return result; }
@Override public OAuth2Authentication extractAuthentication(Map<String, ?> map) { return tokenConverter.extractAuthentication(map); }
public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication) { return tokenStore.getAccessToken(authentication); }
@Override protected OAuth2AccessToken getAccessToken(ClientDetails client, TokenRequest tokenRequest) { return super.getAccessToken(client, tokenRequest); }
@Override public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) { OAuth2AccessToken token = super.grant(grantType, tokenRequest); if (token != null) { DefaultOAuth2AccessToken norefresh = new DefaultOAuth2AccessToken(token); // The spec says that client credentials should not be allowed to get a refresh token if (!allowRefresh) { norefresh.setRefreshToken(null); } token = norefresh; } return token; }
@Override public OAuth2AccessToken extractAccessToken(String value, Map<String, ?> map) { return tokenConverter.extractAccessToken(value, map); }
@Override public Map<String, ?> convertAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) { return tokenConverter.convertAccessToken(token, authentication); }
@Override protected OAuth2RequestFactory getRequestFactory() { return super.getRequestFactory(); }
@Bean public DefaultTokenServices tokenServices() { DefaultTokenServices services = new DefaultTokenServices(); services.setClientDetailsService(clientDetailsService); services.setSupportRefreshToken(true); services.setTokenStore(tokenStore()); return services; }
public OAuth2AccessToken readAccessToken(String accessToken) { return tokenStore.readAccessToken(accessToken); }
/** * Delegates to the internal instance {@link JwtTokenStore#readAuthentication(String)}. * * @param tokenValue the access token value * @return the {@link OAuth2Authentication} representation of the access token */ @Override public OAuth2Authentication readAuthentication(String tokenValue) { return this.delegate.readAuthentication(tokenValue); }