/** {@inheritDoc} */ public JsonValue queryForToken(String tokenId) throws InvalidRequestException { JsonValue results; try { results = tokenStore.query( or( equalTo(OAuthTokenField.PARENT.getField(), tokenId), equalTo(OAuthTokenField.REFRESH_TOKEN.getField(), tokenId))); } catch (CoreTokenException e) { logger.error("Unable to query refresh token corresponding to id: " + tokenId, e); throw new InvalidRequestException(); } return results; }
@Override public DeviceCode readDeviceCode(String userCode, OAuth2Request request) throws ServerException, NotFoundException, InvalidGrantException { try { JsonValue token = tokenStore.query(equalTo(CoreTokenField.STRING_FOURTEEN, userCode)); if (token.size() != 1) { throw new InvalidGrantException(); } DeviceCode deviceCode = new DeviceCode(json(token.asSet().iterator().next())); request.setToken(DeviceCode.class, deviceCode); return deviceCode; } catch (CoreTokenException e) { logger.error("Unable to read device code corresponding to id: " + userCode, e); throw new ServerException("Could not read token in CTS: " + e.getMessage()); } }