use of org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey in project ignite by apache.
the class JmhKeystoreEncryptionSpiBenchmark method encryptBenchmark.
/**
*/
@Benchmark
public void encryptBenchmark(EncryptionData d, Blackhole receiver) {
for (int i = 0; i < DATA_AMOUNT; i++) {
ByteBuffer[] dt = d.randomData[i];
KeystoreEncryptionKey key = d.keys[ThreadLocalRandom.current().nextInt(4)];
d.encSpi.encryptNoPadding(dt[0], key, dt[1]);
receiver.consume(d.res);
dt[0].rewind();
dt[1].rewind();
d.encSpi.decryptNoPadding(dt[1], key, dt[0]);
}
}
use of org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey in project ignite by apache.
the class EncryptedCacheCreateTest method testCreateEncryptedCache.
/**
* @throws Exception If failed.
*/
@Test
public void testCreateEncryptedCache() throws Exception {
CacheConfiguration<Long, String> ccfg = new CacheConfiguration<>(ENCRYPTED_CACHE);
ccfg.setEncryptionEnabled(true);
IgniteEx grid = grid(0);
grid.createCache(ccfg);
IgniteInternalCache<Object, Object> enc = grid.cachex(ENCRYPTED_CACHE);
assertNotNull(enc);
GroupKey grpKey = grid.context().encryption().getActiveKey(CU.cacheGroupId(ENCRYPTED_CACHE, null));
assertNotNull(grpKey);
KeystoreEncryptionKey key = (KeystoreEncryptionKey) grpKey.key();
assertNotNull(key);
assertNotNull(key.key());
}
use of org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey in project ignite by apache.
the class EncryptedCacheGroupCreateTest method createEncryptedCache.
/**
*/
private KeystoreEncryptionKey createEncryptedCache(String cacheName, String grpName) {
CacheConfiguration<Long, String> ccfg = new CacheConfiguration<>(cacheName);
ccfg.setEncryptionEnabled(true);
ccfg.setGroupName(grpName);
IgniteEx grid = grid(0);
grid.createCache(ccfg);
IgniteInternalCache<Object, Object> enc = grid.cachex(cacheName);
assertNotNull(enc);
GroupKey grpKey = grid.context().encryption().getActiveKey(CU.cacheGroupId(cacheName, grpName));
assertNotNull(grpKey);
KeystoreEncryptionKey key = (KeystoreEncryptionKey) grpKey.key();
assertNotNull(key);
assertNotNull(key.key());
return key;
}
use of org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey in project ignite by apache.
the class EncryptedCacheRestartTest method testCreateEncryptedCache.
/**
* @throws Exception If failed.
*/
@Test
public void testCreateEncryptedCache() throws Exception {
T2<IgniteEx, IgniteEx> grids = startTestGrids(true);
createEncryptedCache(grids.get1(), grids.get2(), cacheName(), null);
checkEncryptedCaches(grids.get1(), grids.get2());
int grpId = CU.cacheGroupId(cacheName(), null);
KeystoreEncryptionKey keyBeforeRestart = (KeystoreEncryptionKey) grids.get1().context().encryption().getActiveKey(grpId).key();
stopAllGrids();
grids = startTestGrids(false);
checkEncryptedCaches(grids.get1(), grids.get2());
GroupKey grpKeyAfterRestart = grids.get1().context().encryption().getActiveKey(grpId);
assertNotNull(grpKeyAfterRestart);
KeystoreEncryptionKey keyAfterRestart = (KeystoreEncryptionKey) grpKeyAfterRestart.key();
assertNotNull(keyAfterRestart);
assertNotNull(keyAfterRestart.key());
assertEquals(keyBeforeRestart.key(), keyAfterRestart.key());
}
use of org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey in project ignite by apache.
the class SpringEncryptedCacheRestartTest method testCreateEncryptedCacheGroup.
/**
* @throws Exception If failed.
*/
@Test
public void testCreateEncryptedCacheGroup() throws Exception {
IgniteEx g0 = (IgniteEx) IgnitionEx.start(IgniteUtils.resolveIgnitePath("modules/spring/src/test/config/enc/enc-group.xml").getAbsolutePath(), "grid-0");
IgniteEx g1 = (IgniteEx) IgnitionEx.start(IgniteUtils.resolveIgnitePath("modules/spring/src/test/config/enc/enc-group-2.xml").getAbsolutePath(), "grid-1");
g1.cluster().active(true);
awaitPartitionMapExchange();
IgniteInternalCache<Object, Object> encrypted = g0.cachex("encrypted");
assertNotNull(encrypted);
IgniteInternalCache<Object, Object> encrypted2 = g0.cachex("encrypted-2");
assertNotNull(encrypted2);
GroupKey grpKey = g0.context().encryption().getActiveKey(CU.cacheGroupId(encrypted.name(), encrypted.configuration().getGroupName()));
assertNotNull(grpKey);
KeystoreEncryptionKey key = (KeystoreEncryptionKey) grpKey.key();
assertNotNull(key);
assertNotNull(key.key());
GroupKey grpKey2 = g0.context().encryption().getActiveKey(CU.cacheGroupId(encrypted2.name(), encrypted2.configuration().getGroupName()));
assertNotNull(grpKey2);
KeystoreEncryptionKey key2 = (KeystoreEncryptionKey) grpKey2.key();
assertNotNull(key2);
assertNotNull(key2.key());
assertEquals(key.key(), key2.key());
}
Aggregations