Browse Source

Fix high load performance issue in token expiration task

pull/1187/head
strangeweaver 9 years ago committed by Justin Richer
parent
commit
099211593c
  1. 20
      openid-connect-common/src/main/java/org/mitre/oauth2/repository/OAuth2TokenRepository.java
  2. 4
      openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java
  3. 4
      openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java

20
openid-connect-common/src/main/java/org/mitre/oauth2/repository/OAuth2TokenRepository.java

@ -61,8 +61,28 @@ public interface OAuth2TokenRepository {
public Set<OAuth2AccessTokenEntity> getAccessTokensForResourceSet(ResourceSet rs);
/**
* removes duplicate access tokens.
*
* @deprecated this method was added to return the remove duplicate access tokens values
* so that {code removeAccessToken(OAuth2AccessTokenEntity o)} would not to fail. the
* removeAccessToken method has been updated so as it will not fail in the event that an
* accessToken has been duplicated, so this method is unnecessary.
*
*/
@Deprecated
public void clearDuplicateAccessTokens();
/**
* removes duplicate refresh tokens.
*
* @deprecated this method was added to return the remove duplicate refresh token value
* so that {code removeRefreshToken(OAuth2RefreshTokenEntity o)} would not to fail. the
* removeRefreshToken method has been updated so as it will not fail in the event that
* refreshToken has been duplicated, so this method is unnecessary.
*
*/
@Deprecated
public void clearDuplicateRefreshTokens();
public List<OAuth2AccessTokenEntity> getAccessTokensForApprovedSite(ApprovedSite approvedSite);

4
openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java

@ -95,7 +95,7 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
@Override
@Transactional(value="defaultTransactionManager")
public void removeAccessToken(OAuth2AccessTokenEntity accessToken) {
OAuth2AccessTokenEntity found = getAccessTokenByValue(accessToken.getValue());
OAuth2AccessTokenEntity found = getAccessTokenById(accessToken.getId());
if (found != null) {
manager.remove(found);
} else {
@ -140,7 +140,7 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
@Override
@Transactional(value="defaultTransactionManager")
public void removeRefreshToken(OAuth2RefreshTokenEntity refreshToken) {
OAuth2RefreshTokenEntity found = getRefreshTokenByValue(refreshToken.getValue());
OAuth2RefreshTokenEntity found = getRefreshTokenById(refreshToken.getId());
if (found != null) {
manager.remove(found);
} else {

4
openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java

@ -489,10 +489,6 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
@Override
public void clearExpiredTokens() {
logger.debug("Cleaning out all expired tokens");
// get all the duplicated tokens first to maintain consistency
tokenRepository.clearDuplicateAccessTokens();
tokenRepository.clearDuplicateRefreshTokens();
Collection<OAuth2AccessTokenEntity> accessTokens = getExpiredAccessTokens();
if (accessTokens.size() > 0) {

Loading…
Cancel
Save