use of com.haulmont.cuba.core.entity.AccessToken in project cuba by cuba-platform.
the class ServerTokenStoreImpl method getAccessTokenByAuthentication.
@Override
public byte[] getAccessTokenByAuthentication(String authenticationKey) {
byte[] accessTokenBytes;
accessTokenBytes = getAccessTokenByAuthenticationFromMemory(authenticationKey);
if (accessTokenBytes == null && serverConfig.getRestStoreTokensInDb()) {
AccessToken accessToken = getAccessTokenByAuthenticationKeyFromDatabase(authenticationKey);
if (accessToken != null) {
accessTokenBytes = accessToken.getTokenBytes();
restoreAccessTokenIntoMemory(accessToken);
}
}
return accessTokenBytes;
}
use of com.haulmont.cuba.core.entity.AccessToken in project cuba by cuba-platform.
the class ServerTokenStoreImpl method getAccessTokenByAuthenticationKeyFromDatabase.
@Nullable
protected AccessToken getAccessTokenByAuthenticationKeyFromDatabase(String authenticationKey) {
AccessToken accessToken;
try (Transaction tx = persistence.createTransaction()) {
EntityManager em = persistence.getEntityManager();
accessToken = em.createQuery("select e from sys$AccessToken e where e.authenticationKey = :authenticationKey", AccessToken.class).setParameter("authenticationKey", authenticationKey).setViewName(View.LOCAL).getFirstResult();
tx.commit();
return accessToken;
}
}
use of com.haulmont.cuba.core.entity.AccessToken in project cuba by cuba-platform.
the class ServerTokenStoreImpl method getAccessTokenByTokenValueFromDatabase.
@Nullable
protected AccessToken getAccessTokenByTokenValueFromDatabase(String accessTokenValue) {
AccessToken accessToken;
try (Transaction tx = persistence.createTransaction()) {
EntityManager em = persistence.getEntityManager();
accessToken = em.createQuery("select e from sys$AccessToken e where e.tokenValue = :tokenValue", AccessToken.class).setParameter("tokenValue", accessTokenValue).setViewName(View.LOCAL).getFirstResult();
tx.commit();
return accessToken;
}
}
use of com.haulmont.cuba.core.entity.AccessToken in project cuba by cuba-platform.
the class ServerTokenStoreImpl method getAccessTokenByTokenValue.
@Override
public byte[] getAccessTokenByTokenValue(String accessTokenValue) {
byte[] accessTokenBytes;
accessTokenBytes = getAccessTokenByTokenValueFromMemory(accessTokenValue);
if (accessTokenBytes == null && serverConfig.getRestStoreTokensInDb()) {
AccessToken accessToken = getAccessTokenByTokenValueFromDatabase(accessTokenValue);
if (accessToken != null) {
accessTokenBytes = accessToken.getTokenBytes();
restoreAccessTokenIntoMemory(accessToken);
}
}
return accessTokenBytes;
}
use of com.haulmont.cuba.core.entity.AccessToken in project cuba by cuba-platform.
the class ServerTokenStoreImpl method getAuthenticationByTokenValue.
@Override
public byte[] getAuthenticationByTokenValue(String tokenValue) {
byte[] authenticationBytes;
authenticationBytes = getAuthenticationByTokenValueFromMemory(tokenValue);
if (authenticationBytes == null && serverConfig.getRestStoreTokensInDb()) {
AccessToken accessToken = getAccessTokenByTokenValueFromDatabase(tokenValue);
if (accessToken != null) {
authenticationBytes = accessToken.getAuthenticationBytes();
restoreAccessTokenIntoMemory(accessToken);
}
}
return authenticationBytes;
}
Aggregations