// Something wrong with a storage driver
throw ex;
}
// Create a key
Key original;
try {
original = new Key(new AESKeyVersion.Builder().build());
} catch (BuilderException ex) {
// Problem building key
throw ex;
}
// Quickly save it (the native driver recognizes file:// addresses)
storage.save(NATIVE_STORE.toURI(), original);
// Quickly load it back
Key loaded = storage.load(NATIVE_STORE.toURI());
assert(original.buildData().build().equals(loaded.buildData().build()));
// Use Store API for more elaborate operations
Store store = null;
try {
// Open a SQLite database store
store = storage.open(
"sqlite:" + SQLITE_DATABASE.toURI().getRawPath() + "#samekey");
// Save previously loaded key
store.save(loaded);
// Check store is not empty and load key back
if (!store.isEmpty()) {
Key sameKey = store.load();
assert(loaded.buildData().build().equals(sameKey.buildData().build()));
}
} finally {
// Close store
if (store != null) {