Search in sources :

Example 1 with ActionTokenReducedKey

use of org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey in project keycloak by keycloak.

the class InfinispanActionTokenStoreProvider method get.

@Override
public ActionTokenValueModel get(ActionTokenKeyModel actionTokenKey) {
    if (actionTokenKey == null || actionTokenKey.getUserId() == null || actionTokenKey.getActionId() == null) {
        return null;
    }
    ActionTokenReducedKey key = new ActionTokenReducedKey(actionTokenKey.getUserId(), actionTokenKey.getActionId(), actionTokenKey.getActionVerificationNonce());
    ActionTokenValueModel value = this.actionKeyCache.getAdvancedCache().get(key);
    if (value == null) {
        LOG.debugf("Not found any value in actionTokens cache for key: %s", key.toString());
    } else {
        LOG.debugf("Found value in actionTokens cache for key: %s", key.toString());
    }
    return value;
}
Also used : ActionTokenReducedKey(org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey)

Example 2 with ActionTokenReducedKey

use of org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey in project keycloak by keycloak.

the class InfinispanActionTokenStoreProvider method put.

@Override
public void put(ActionTokenKeyModel key, Map<String, String> notes) {
    if (key == null || key.getUserId() == null || key.getActionId() == null) {
        return;
    }
    ActionTokenReducedKey tokenKey = new ActionTokenReducedKey(key.getUserId(), key.getActionId(), key.getActionVerificationNonce());
    ActionTokenValueEntity tokenValue = new ActionTokenValueEntity(notes);
    LOG.debugf("Adding used action token to actionTokens cache: %s", tokenKey.toString());
    this.tx.put(actionKeyCache, tokenKey, tokenValue, key.getExpiration() - Time.currentTime(), TimeUnit.SECONDS);
}
Also used : ActionTokenReducedKey(org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey) ActionTokenValueEntity(org.keycloak.models.sessions.infinispan.entities.ActionTokenValueEntity)

Example 3 with ActionTokenReducedKey

use of org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey in project keycloak by keycloak.

the class InfinispanActionTokenStoreProviderFactory method initActionTokenCache.

private static Cache<ActionTokenReducedKey, ActionTokenValueEntity> initActionTokenCache(KeycloakSession session) {
    InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class);
    Cache<ActionTokenReducedKey, ActionTokenValueEntity> cache = connections.getCache(InfinispanConnectionProvider.ACTION_TOKEN_CACHE);
    return cache;
}
Also used : ActionTokenReducedKey(org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey) ActionTokenValueEntity(org.keycloak.models.sessions.infinispan.entities.ActionTokenValueEntity) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider)

Example 4 with ActionTokenReducedKey

use of org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey in project keycloak by keycloak.

the class InfinispanActionTokenStoreProvider method remove.

@Override
public ActionTokenValueModel remove(ActionTokenKeyModel actionTokenKey) {
    if (actionTokenKey == null || actionTokenKey.getUserId() == null || actionTokenKey.getActionId() == null) {
        return null;
    }
    ActionTokenReducedKey key = new ActionTokenReducedKey(actionTokenKey.getUserId(), actionTokenKey.getActionId(), actionTokenKey.getActionVerificationNonce());
    ActionTokenValueEntity value = this.actionKeyCache.get(key);
    if (value != null) {
        this.tx.remove(actionKeyCache, key);
    }
    return value;
}
Also used : ActionTokenReducedKey(org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey) ActionTokenValueEntity(org.keycloak.models.sessions.infinispan.entities.ActionTokenValueEntity)

Aggregations

ActionTokenReducedKey (org.keycloak.models.sessions.infinispan.entities.ActionTokenReducedKey)4 ActionTokenValueEntity (org.keycloak.models.sessions.infinispan.entities.ActionTokenValueEntity)3 InfinispanConnectionProvider (org.keycloak.connections.infinispan.InfinispanConnectionProvider)1