use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.
the class RedisRemeberMeService method remove.
@Override
public void remove(String username) {
RedisConnection conn = connectionFactory.getConnection();
conn.delete(PREFIX + username);
conn.close();
}
use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.
the class RedisRemeberMeService method update.
@Override
public void update(RemeberMe remeberMe) {
RedisConnection conn = connectionFactory.getConnection();
conn.setexObject(PREFIX + remeberMe.getUsername(), serviceTicketValiditySeconds, remeberMe);
conn.close();
}
use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.
the class RedisTokenStore method storeRefreshToken.
@Override
public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) {
String refreshKey = (REFRESH + refreshToken.getValue());
String refreshAuthKey = (REFRESH_AUTH + refreshToken.getValue());
RedisConnection conn = getConnection();
try {
conn.openPipeline();
conn.setObject(refreshKey, refreshToken);
conn.setObject(refreshAuthKey, authentication);
if (refreshToken instanceof ExpiringOAuth2RefreshToken) {
ExpiringOAuth2RefreshToken expiringRefreshToken = (ExpiringOAuth2RefreshToken) refreshToken;
Date expiration = expiringRefreshToken.getExpiration();
if (expiration != null) {
int seconds = Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L).intValue();
conn.expire(refreshKey, seconds);
conn.expire(refreshAuthKey, seconds);
}
}
conn.closePipeline();
} finally {
conn.close();
}
}
use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.
the class RedisTokenStore method findTokensByClientId.
@Override
public Collection<OAuth2AccessToken> findTokensByClientId(String clientId) {
String key = (CLIENT_ID_TO_ACCESS + clientId);
_logger.trace("TokensByClientId " + key);
List<String> stringList = null;
RedisConnection conn = getConnection();
try {
stringList = conn.lRange(key, 0, -1);
} finally {
conn.close();
}
if (stringList == null || stringList.size() == 0) {
return Collections.<OAuth2AccessToken>emptySet();
}
List<OAuth2AccessToken> accessTokens = new ArrayList<OAuth2AccessToken>(stringList.size());
for (String str : stringList) {
OAuth2AccessToken accessToken = conn.getObject(str);
accessTokens.add(accessToken);
}
return Collections.<OAuth2AccessToken>unmodifiableCollection(accessTokens);
}
use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.
the class RedisTokenStore method readAuthentication.
@Override
public OAuth2Authentication readAuthentication(String token) {
_logger.trace("read Authentication by token " + token + " , token key " + AUTH + token);
RedisConnection conn = getConnection();
try {
OAuth2Authentication auth = conn.getObject(AUTH + token);
return auth;
} finally {
conn.close();
}
}
Aggregations