Search in sources :

Example 11 with KeystoreEncryptionKey

use of org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey in project ignite by apache.

the class KeystoreEncryptionSpiSelfTest method checkKeyEncryptDecrypt.

/**
 */
private void checkKeyEncryptDecrypt(EncryptionSpi encSpi, KeystoreEncryptionKey k) {
    byte[] encGrpKey = encSpi.encryptKey(k);
    assertNotNull(encGrpKey);
    assertTrue(encGrpKey.length > 0);
    KeystoreEncryptionKey k2 = (KeystoreEncryptionKey) encSpi.decryptKey(encGrpKey);
    assertEquals(k.key(), k2.key());
}
Also used : KeystoreEncryptionKey(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey)

Example 12 with KeystoreEncryptionKey

use of org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey in project ignite by apache.

the class SpringEncryptedCacheRestartTest method testEncryptionKeysEqualsOnThirdNodeJoin.

/**
 * @throws Exception If failed.
 */
@Test
public void testEncryptionKeysEqualsOnThirdNodeJoin() throws Exception {
    T2<IgniteEx, IgniteEx> g = startTestGrids(true);
    IgniteEx g2 = (IgniteEx) IgnitionEx.start(IgniteUtils.resolveIgnitePath("modules/spring/src/test/config/enc/enc-group-2.xml").getAbsolutePath(), "grid-2");
    Collection<String> cacheNames = Arrays.asList("encrypted", "encrypted-2");
    for (String cacheName : cacheNames) {
        IgniteInternalCache<Object, Object> enc = g.get1().cachex(cacheName);
        assertNotNull(enc);
        int grpId = CU.cacheGroupId(enc.name(), enc.configuration().getGroupName());
        GroupKey grpKey0 = g.get1().context().encryption().getActiveKey(grpId);
        GroupKey grpKey1 = g.get2().context().encryption().getActiveKey(grpId);
        GroupKey grpKey2 = g2.context().encryption().getActiveKey(grpId);
        assertNotNull(cacheName, grpKey0);
        assertNotNull(cacheName, grpKey1);
        assertNotNull(cacheName, grpKey2);
        KeystoreEncryptionKey key0 = (KeystoreEncryptionKey) grpKey0.key();
        KeystoreEncryptionKey key1 = (KeystoreEncryptionKey) grpKey1.key();
        KeystoreEncryptionKey key2 = (KeystoreEncryptionKey) grpKey2.key();
        assertNotNull(cacheName, key0.key());
        assertNotNull(cacheName, key1.key());
        assertNotNull(cacheName, key2.key());
        assertNotNull(cacheName, key0.key());
        assertNotNull(cacheName, key1.key());
        assertNotNull(cacheName, key2.key());
        assertEquals(cacheName, key0.key(), key1.key());
        assertEquals(cacheName, key1.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