Search in sources :

Example 6 with KeystoreEncryptionSpi

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

the class AbstractSnapshotSelfTest method startGrid.

/**
 * {@inheritDoc}
 */
@Override
protected Ignite startGrid(String igniteInstanceName, IgniteConfiguration cfg, GridSpringResourceContext ctx) throws Exception {
    if (encryption && persistence) {
        KeystoreEncryptionSpi encSpi = new KeystoreEncryptionSpi();
        encSpi.setKeyStorePath(AbstractEncryptionTest.KEYSTORE_PATH);
        encSpi.setKeyStorePassword(AbstractEncryptionTest.KEYSTORE_PASSWORD.toCharArray());
        if (masterKeyName != null)
            encSpi.setMasterKeyName(masterKeyName);
        cfg.setEncryptionSpi(encSpi);
        if (cfg.getCacheConfiguration() != null) {
            for (CacheConfiguration<?, ?> cacheCfg : cfg.getCacheConfiguration()) cacheCfg.setEncryptionEnabled(true);
        }
    }
    return super.startGrid(igniteInstanceName, cfg, ctx);
}
Also used : KeystoreEncryptionSpi(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi)

Example 7 with KeystoreEncryptionSpi

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

the class KeystoreEncryptionSpiSelfTest method spi.

/**
 */
@NotNull
private EncryptionSpi spi() throws Exception {
    KeystoreEncryptionSpi encSpi = new KeystoreEncryptionSpi();
    encSpi.setKeyStorePath(KEYSTORE_PATH);
    encSpi.setKeyStorePassword(KEYSTORE_PASSWORD.toCharArray());
    GridTestUtils.invoke(encSpi, "onBeforeStart");
    encSpi.spiStart("default");
    return encSpi;
}
Also used : KeystoreEncryptionSpi(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi) Assert.assertNotNull(org.junit.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with KeystoreEncryptionSpi

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

the class TDE method configuration.

@Test
void configuration() {
    // tag::config[]
    IgniteConfiguration cfg = new IgniteConfiguration();
    KeystoreEncryptionSpi encSpi = new KeystoreEncryptionSpi();
    encSpi.setKeyStorePath("/home/user/ignite-keystore.jks");
    encSpi.setKeyStorePassword("secret".toCharArray());
    cfg.setEncryptionSpi(encSpi);
    // end::config[]
    Ignite ignite = Ignition.start(cfg);
    // tag::cache[]
    CacheConfiguration<Long, String> ccfg = new CacheConfiguration<Long, String>("encrypted-cache");
    ccfg.setEncryptionEnabled(true);
    ignite.createCache(ccfg);
    // end::cache[]
    // tag::master-key-rotation[]
    // Gets the current master key name.
    String name = ignite.encryption().getMasterKeyName();
    // Starts master key change process.
    IgniteFuture<Void> future = ignite.encryption().changeMasterKey("newMasterKeyName");
    // end::master-key-rotation[]
    // tag::cache-group-key-rotation[]
    // Starts cache group encryption key change process.
    // This future will be completed when the new encryption key is set for writing on
    // all nodes in the cluster and re-encryption of existing cache data is initiated.
    IgniteFuture<Void> fut = ignite.encryption().changeCacheGroupKey(Collections.singleton("encrypted-cache"));
    // end::cache-group-key-rotation[]
    ignite.close();
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) KeystoreEncryptionSpi(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi) Ignite(org.apache.ignite.Ignite) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.jupiter.api.Test)

Example 9 with KeystoreEncryptionSpi

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

the class GridCommandHandlerAbstractTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    if (atomicConfiguration != null)
        cfg.setAtomicConfiguration(atomicConfiguration);
    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
    cfg.setConnectorConfiguration(new ConnectorConfiguration().setSslEnabled(sslEnabled()));
    if (sslEnabled())
        cfg.setSslContextFactory(GridTestUtils.sslFactory());
    DataStorageConfiguration dsCfg = new DataStorageConfiguration().setWalMode(WALMode.LOG_ONLY).setCheckpointFrequency(checkpointFreq).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(50L * 1024 * 1024).setPersistenceEnabled(persistent));
    if (dataRegionConfiguration != null)
        dsCfg.setDataRegionConfigurations(dataRegionConfiguration);
    cfg.setDataStorageConfiguration(dsCfg);
    cfg.setConsistentId(igniteInstanceName);
    cfg.setClientMode(igniteInstanceName.startsWith(CLIENT_NODE_NAME_PREFIX));
    cfg.setDaemon(igniteInstanceName.startsWith(DAEMON_NODE_NAME_PREFIX));
    // Extend if necessary.
    cfg.setIncludeEventTypes(EVT_CONSISTENCY_VIOLATION);
    if (encryptionEnabled) {
        KeystoreEncryptionSpi encSpi = new KeystoreEncryptionSpi();
        encSpi.setKeyStorePath(KEYSTORE_PATH);
        encSpi.setKeyStorePassword(KEYSTORE_PASSWORD.toCharArray());
        cfg.setEncryptionSpi(encSpi);
        EncryptionConfiguration encCfg = new EncryptionConfiguration();
        encCfg.setReencryptionRateLimit(reencryptSpeed);
        encCfg.setReencryptionBatchSize(reencryptBatchSize);
        dsCfg.setEncryptionConfiguration(encCfg);
    }
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) EncryptionConfiguration(org.apache.ignite.configuration.EncryptionConfiguration) KeystoreEncryptionSpi(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration)

Example 10 with KeystoreEncryptionSpi

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

the class PlatformConfigurationUtils method writeEncryptionConfiguration.

/**
 * Writes encryption configuration.
 *
 * @param w Writer.
 * @param enc Encryption Spi.
 */
private static void writeEncryptionConfiguration(BinaryRawWriter w, EncryptionSpi enc) {
    if (enc instanceof NoopEncryptionSpi) {
        w.writeBoolean(false);
        return;
    }
    KeystoreEncryptionSpi keystoreEnc = (KeystoreEncryptionSpi) enc;
    w.writeBoolean(true);
    w.writeString(keystoreEnc.getMasterKeyName());
    w.writeInt(keystoreEnc.getKeySize());
    w.writeString(keystoreEnc.getKeyStorePath());
    w.writeCharArray(keystoreEnc.getKeyStorePwd());
}
Also used : NoopEncryptionSpi(org.apache.ignite.spi.encryption.noop.NoopEncryptionSpi) KeystoreEncryptionSpi(org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi)

Aggregations

KeystoreEncryptionSpi (org.apache.ignite.spi.encryption.keystore.KeystoreEncryptionSpi)14 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)7 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)3 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)3 Test (org.junit.Test)3 NoopEncryptionSpi (org.apache.ignite.spi.encryption.noop.NoopEncryptionSpi)2 Ignite (org.apache.ignite.Ignite)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)1 EncryptionConfiguration (org.apache.ignite.configuration.EncryptionConfiguration)1 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)1 NotNull (org.jetbrains.annotations.NotNull)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Test (org.junit.jupiter.api.Test)1