OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(refreshTokenValue); if (refreshToken == null) { throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
@Override public TokenRequest createTokenRequest(Map<String, String> requestParameters, ClientDetails authenticatedClient) { if (requestParameters.get("grant_type").equals("refresh_token")) { OAuth2Authentication authentication = tokenStore.readAuthenticationForRefreshToken( tokenStore.readRefreshToken(requestParameters.get("refresh_token"))); SecurityContextHolder.getContext() .setAuthentication(new UsernamePasswordAuthenticationToken(authentication.getName(), null, userDetailsService.loadUserByUsername(authentication.getName()).getAuthorities())); } return super.createTokenRequest(requestParameters, authenticatedClient); } }
@Nullable public String revokeRefreshToken(String tokenValue, Authentication clientAuth) { OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(tokenValue); if (refreshToken != null) { OAuth2Authentication authToRevoke = tokenStore.readAuthenticationForRefreshToken(refreshToken); checkIfTokenIsIssuedToClient(clientAuth, authToRevoke); tokenStore.removeAccessTokenUsingRefreshToken(refreshToken); tokenStore.removeRefreshToken(refreshToken); log.debug("Successfully removed refresh token {} (and any associated access token).", tokenMasker.maskToken(refreshToken.getValue())); return refreshToken.getValue(); } log.debug("No refresh token {} found in the token store.", tokenMasker.maskToken(tokenValue)); return null; }
@Override public OAuth2AccessToken refreshAccessToken(String refreshTokenValue, TokenRequest tokenRequest) throws AuthenticationException { log.info("authentication-provider is refreshing token"); // Note: scope is ignored by the current implementation // - uri, Mar 14, 2012 ExpiringOAuth2RefreshToken refreshToken = (ExpiringOAuth2RefreshToken) tokenStore.readRefreshToken(refreshTokenValue); if (refreshToken == null) { throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue); } else if (isExpired(refreshToken)) { tokenStore.removeRefreshToken(refreshToken); throw new InvalidGrantException("Invalid refresh token: " + refreshToken); } OAuth2Authentication authentication = tokenStore.readAuthenticationForRefreshToken(refreshToken); tokenStore.removeRefreshToken(refreshToken); return createAccessToken(authentication); }
OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(refreshTokenValue); if (refreshToken == null) { throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(refreshTokenValue); if (refreshToken == null) { throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);
OAuth2RefreshToken refreshToken = tokenStore.readRefreshToken(refreshTokenValue); if (refreshToken == null) { throw new InvalidGrantException("Invalid refresh token: " + refreshTokenValue);