diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/CachableJdbcTokenStore.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/CachableJdbcTokenStore.java index 8933b1bd..8dd35ed5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/CachableJdbcTokenStore.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/CachableJdbcTokenStore.java @@ -50,10 +50,6 @@ public class CachableJdbcTokenStore implements TokenStore { } @Override - @Cacheable( - cacheNames = CACHE_NAME, - key = "#token", - unless = "#result == null") public OAuth2Authentication readAuthentication(final OAuth2AccessToken token) { if (log.isDebugEnabled()) { log.debug("Read authentication from persistent and cache if available"); @@ -68,6 +64,10 @@ public class CachableJdbcTokenStore implements TokenStore { } @Override + @Cacheable( + cacheNames = CACHE_NAME, + key = "#tokenValue", + unless = "#result == null") public OAuth2AccessToken readAccessToken(final String tokenValue) { return this.jdbcTokenStore.readAccessToken(tokenValue); } @@ -75,7 +75,7 @@ public class CachableJdbcTokenStore implements TokenStore { @Override @CacheEvict( cacheNames = CACHE_NAME, - key = "#token") + key = "#token.getValue()") public void removeAccessToken(final OAuth2AccessToken token) { if (log.isDebugEnabled()) { log.debug("Evict token from cache and remove it also from persistent store"); diff --git a/src/main/resources/config/ehcache.xml b/src/main/resources/config/ehcache.xml index ecc1b6f6..db9b470a 100644 --- a/src/main/resources/config/ehcache.xml +++ b/src/main/resources/config/ehcache.xml @@ -61,10 +61,10 @@ - org.springframework.security.oauth2.common.OAuth2AccessToken - org.springframework.security.oauth2.provider.OAuth2Authentication + java.lang.String + org.springframework.security.oauth2.common.OAuth2AccessToken - 24 + 1 100