Search in sources :

Example 26 with GroupKey

use of org.apache.ignite.internal.managers.encryption.GroupKey in project gridgain by gridgain.

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 27 with GroupKey

use of org.apache.ignite.internal.managers.encryption.GroupKey in project gridgain by gridgain.

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)

Aggregations

GroupKey (org.apache.ignite.internal.managers.encryption.GroupKey)27 KeystoreEncryptionKey (org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionKey)16 IgniteEx (org.apache.ignite.internal.IgniteEx)14 Test (org.junit.Test)12 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)8 EncryptedCacheRestartTest (org.apache.ignite.internal.encryption.EncryptedCacheRestartTest)4 HashSet (java.util.HashSet)2 GridEncryptionManager (org.apache.ignite.internal.managers.encryption.GridEncryptionManager)2 RecordType (org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType)2 MetaStorage (org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage)2 ByteBufferBackedDataInputImpl (org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferBackedDataInputImpl)2 RecordV1Serializer.putRecordType (org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer.putRecordType)2 T3 (org.apache.ignite.internal.util.typedef.T3)2 ByteBuffer (java.nio.ByteBuffer)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 GroupKeyEncrypted (org.apache.ignite.internal.managers.encryption.GroupKeyEncrypted)1 QuerySchema (org.apache.ignite.internal.processors.query.QuerySchema)1