Search in sources :

Example 1 with RedisConnection

use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.

the class RedisAuthorizationCodeServices method store.

@Override
protected void store(String code, OAuth2Authentication authentication) {
    RedisConnection conn = connectionFactory.getConnection();
    conn.setexObject(PREFIX + code, codeValiditySeconds, authentication);
    conn.close();
}
Also used : RedisConnection(org.maxkey.persistence.redis.RedisConnection)

Example 2 with RedisConnection

use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.

the class RedisAuthorizationCodeServices method remove.

@Override
public OAuth2Authentication remove(String code) {
    RedisConnection conn = connectionFactory.getConnection();
    OAuth2Authentication auth = conn.getObject(PREFIX + code);
    conn.delete(PREFIX + code);
    return auth;
}
Also used : OAuth2Authentication(org.maxkey.authz.oauth2.provider.OAuth2Authentication) RedisConnection(org.maxkey.persistence.redis.RedisConnection)

Example 3 with RedisConnection

use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.

the class RedisOtpTokenStore method validate.

@Override
public boolean validate(UserInfo userInfo, String token, String type, int interval) {
    RedisConnection conn = connectionFactory.getConnection();
    OneTimePassword otp = (OneTimePassword) conn.getObject(PREFIX + userInfo.getUsername() + "_" + type + "_" + token);
    conn.delete(PREFIX + userInfo.getUsername() + "_" + type + "_" + token);
    conn.close();
    if (otp != null) {
        return true;
    }
    return false;
}
Also used : OneTimePassword(org.maxkey.password.onetimepwd.OneTimePassword) RedisConnection(org.maxkey.persistence.redis.RedisConnection)

Example 4 with RedisConnection

use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.

the class RedisOtpTokenStore method store.

@Override
public void store(UserInfo userInfo, String token, String receiver, String type) {
    DateTime currentDateTime = new DateTime();
    OneTimePassword otp = new OneTimePassword();
    otp.setId(userInfo.getUsername() + "_" + type + "_" + token);
    otp.setType(type);
    otp.setUsername(userInfo.getUsername());
    otp.setToken(token);
    otp.setReceiver(receiver);
    otp.setCreateTime(currentDateTime.toString("yyyy-MM-dd HH:mm:ss"));
    RedisConnection conn = connectionFactory.getConnection();
    conn.setexObject(PREFIX + otp.getId(), validitySeconds, otp);
    conn.close();
}
Also used : OneTimePassword(org.maxkey.password.onetimepwd.OneTimePassword) DateTime(org.joda.time.DateTime) RedisConnection(org.maxkey.persistence.redis.RedisConnection)

Example 5 with RedisConnection

use of org.maxkey.persistence.redis.RedisConnection in project MaxKey by dromara.

the class RedisRemeberMeService method save.

@Override
public void save(RemeberMe remeberMe) {
    RedisConnection conn = connectionFactory.getConnection();
    conn.setexObject(PREFIX + remeberMe.getUsername(), serviceTicketValiditySeconds, remeberMe);
    conn.close();
}
Also used : RedisConnection(org.maxkey.persistence.redis.RedisConnection)

Aggregations

RedisConnection (org.maxkey.persistence.redis.RedisConnection)31 Ticket (org.maxkey.authz.cas.endpoint.ticket.Ticket)6 OAuth2AccessToken (org.maxkey.authz.oauth2.common.OAuth2AccessToken)4 ExpiringOAuth2RefreshToken (org.maxkey.authz.oauth2.common.ExpiringOAuth2RefreshToken)3 OAuth2Authentication (org.maxkey.authz.oauth2.provider.OAuth2Authentication)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 OAuth2RefreshToken (org.maxkey.authz.oauth2.common.OAuth2RefreshToken)2 OneTimePassword (org.maxkey.password.onetimepwd.OneTimePassword)2 DateTime (org.joda.time.DateTime)1