use of net.runelite.http.api.xtea.XteaKey in project runelite by runelite.
the class XteaKeyManager method loadKeys.
public void loadKeys() {
XteaClient xteaClient = new XteaClient();
try {
for (XteaKey key : xteaClient.get()) {
keys.put(key.getRegion(), key.getKeys());
}
} catch (IOException ex) {
// happens on release when it is not deployed yet
logger.debug("unable to load xtea keys", ex);
return;
}
logger.info("Loaded {} keys", keys.size());
}
use of net.runelite.http.api.xtea.XteaKey in project runelite by runelite.
the class XteaService method submit.
@RequestMapping(method = POST)
public void submit(@RequestBody XteaRequest xteaRequest) {
try (Connection con = sql2o.beginTransaction()) {
CacheEntry cache = cacheService.findMostRecent();
if (cache == null) {
throw new InternalServerErrorException("No most recent cache");
}
Query query = con.createQuery("insert into xtea (region, rev, key1, key2, key3, key4) " + "values (:region, :rev, :key1, :key2, :key3, :key4)");
for (XteaKey key : xteaRequest.getKeys()) {
int region = key.getRegion();
int[] keys = key.getKeys();
XteaEntry xteaEntry = findLatestXtea(con, region);
if (keys.length != 4) {
throw new IllegalArgumentException("Key length must be 4");
}
// already have these?
if (xteaEntry != null && xteaEntry.getKey1() == keys[0] && xteaEntry.getKey2() == keys[1] && xteaEntry.getKey3() == keys[2] && xteaEntry.getKey4() == keys[3]) {
continue;
}
if (!checkKeys(cache, region, keys)) {
continue;
}
query.addParameter("region", region).addParameter("rev", xteaRequest.getRevision()).addParameter("key1", keys[0]).addParameter("key2", keys[1]).addParameter("key3", keys[2]).addParameter("key4", keys[3]).addToBatch();
}
query.executeBatch();
con.commit();
}
}
use of net.runelite.http.api.xtea.XteaKey in project runelite by runelite.
the class XteaService method entryToKey.
private static XteaKey entryToKey(XteaEntry xe) {
XteaKey xteaKey = new XteaKey();
xteaKey.setRegion(xe.getRegion());
xteaKey.setKeys(new int[] { xe.getKey1(), xe.getKey2(), xe.getKey3(), xe.getKey4() });
return xteaKey;
}
Aggregations