use of org.entando.entando.aps.system.services.oauth2.model.OAuth2AccessTokenImpl in project entando-core by entando.
the class OAuth2TokenDAO method getAccessToken.
protected OAuth2AccessToken getAccessToken(final String token, Connection conn) {
OAuth2AccessTokenImpl accessToken = null;
PreparedStatement stat = null;
ResultSet res = null;
try {
stat = conn.prepareStatement(SELECT_TOKEN);
stat.setString(1, token);
res = stat.executeQuery();
if (res.next()) {
accessToken = new OAuth2AccessTokenImpl(token);
accessToken.setRefreshToken(new DefaultOAuth2RefreshToken(res.getString("refreshtoken")));
accessToken.setClientId(res.getString("clientid"));
accessToken.setGrantType(res.getString("granttype"));
accessToken.setLocalUser(res.getString("localuser"));
Timestamp timestamp = res.getTimestamp("expiresin");
Date expiration = new Date(timestamp.getTime());
accessToken.setExpiration(expiration);
}
} catch (Throwable t) {
logger.error("Error loading token {}", token, t);
throw new RuntimeException("Error loading token " + token, t);
} finally {
closeDaoResources(res, stat);
}
return accessToken;
}
Aggregations