Search in sources :

Example 1 with KeystoreEncryptionKey

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]);
    }
}
Also used : KeystoreEncryptionKey(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey) ByteBuffer(java.nio.ByteBuffer) JmhAbstractBenchmark(org.apache.ignite.internal.benchmarks.jmh.JmhAbstractBenchmark) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 2 with KeystoreEncryptionKey

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());
}
Also used : KeystoreEncryptionKey(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey) IgniteEx(org.apache.ignite.internal.IgniteEx) GroupKey(org.apache.ignite.internal.managers.encryption.GroupKey) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Example 3 with KeystoreEncryptionKey

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;
}
Also used : KeystoreEncryptionKey(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey) IgniteEx(org.apache.ignite.internal.IgniteEx) GroupKey(org.apache.ignite.internal.managers.encryption.GroupKey) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 4 with KeystoreEncryptionKey

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());
}
Also used : KeystoreEncryptionKey(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey) IgniteEx(org.apache.ignite.internal.IgniteEx) GroupKey(org.apache.ignite.internal.managers.encryption.GroupKey) Test(org.junit.Test)

Example 5 with KeystoreEncryptionKey

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());
}
Also used : KeystoreEncryptionKey(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey) IgniteEx(org.apache.ignite.internal.IgniteEx) GroupKey(org.apache.ignite.internal.managers.encryption.GroupKey) Test(org.junit.Test) EncryptedCacheRestartTest(org.apache.ignite.internal.encryption.EncryptedCacheRestartTest)

Aggregations

KeystoreEncryptionKey (org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey)12 GroupKey (org.apache.ignite.internal.managers.encryption.GroupKey)8 Test (org.junit.Test)8 IgniteEx (org.apache.ignite.internal.IgniteEx)7 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)4 EncryptedCacheRestartTest (org.apache.ignite.internal.encryption.EncryptedCacheRestartTest)2 KeystoreEncryptionSpi (org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi)2 ByteBuffer (java.nio.ByteBuffer)1 HashSet (java.util.HashSet)1 JmhAbstractBenchmark (org.apache.ignite.internal.benchmarks.jmh.JmhAbstractBenchmark)1 GridEncryptionManager (org.apache.ignite.internal.managers.encryption.GridEncryptionManager)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1