@Override public OAuth2AccessToken readAccessToken(String tokenValue) { byte[] accessTokenBytes = serverTokenStore.getAccessTokenByTokenValue(tokenValue); return accessTokenBytes != null ? deserializeAccessToken(accessTokenBytes) : null; }
@Override public String removeTokensByUserLogin(String userLogin) { if (StringUtils.isEmpty(userLogin)) { return "Please specify the user's login"; } try { Set<String> tokens = serverTokenStore.getAccessTokenValuesByUserLogin(userLogin); if (tokens.isEmpty()) { return String.format("No tokens found for user '%s'", userLogin); } tokens.forEach(serverTokenStore::removeAccessToken); return String.format("%s tokens were removed for user '%s' successfully.", tokens.size(), userLogin); } catch (Throwable t) { return ExceptionUtils.getStackTrace(t); } } }
@Override public OAuth2RefreshToken readRefreshToken(String tokenValue) { byte[] refreshTokenBytes = serverTokenStore.getRefreshTokenByTokenValue(tokenValue); return refreshTokenBytes != null ? SerializationUtils.deserialize(refreshTokenBytes) : null; }
serverTokenStore.getAccessTokenValuesByUserLogin(user.getLogin()) .forEach(serverTokenStore::removeAccessToken); serverTokenStore.getRefreshTokenValuesByUserLogin(user.getLogin()) .forEach(serverTokenStore::removeRefreshToken);
RestUserSessionInfo sessionInfo = serverTokenStore.getSessionInfoByTokenValue(tokenValue); UUID sessionId = sessionInfo != null ? sessionInfo.getId() : null; if (sessionId == null) { serverTokenStore.putSessionInfo(tokenValue, new RestUserSessionInfo(session)); AppContext.setSecurityContext(new SecurityContext(session));
@Override public void removeAccessToken(OAuth2AccessToken token) { serverTokenStore.removeAccessToken(token.getValue()); }
@Override public OAuth2Authentication readAuthentication(String token) { byte[] authenticationBytes = serverTokenStore.getAuthenticationByTokenValue(token); OAuth2Authentication authentication = authenticationBytes != null ? deserializeAuthentication(authenticationBytes) : null; if (authentication != null) { processSession(authentication, token); } return authentication; }
@Override public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication) { String key = authenticationKeyGenerator.extractKey(authentication); byte[] accessTokenBytes = serverTokenStore.getAccessTokenByAuthentication(key); return accessTokenBytes != null ? deserializeAccessToken(accessTokenBytes) : null; }
@Override public OAuth2Authentication readAuthenticationForRefreshToken(OAuth2RefreshToken token) { byte[] authenticationBytes = serverTokenStore.getAuthenticationByRefreshTokenValue(token.getValue()); return authenticationBytes != null ? SerializationUtils.deserialize(authenticationBytes) : null; }