Search in sources :

Example 1 with JavaKeyStoreSecureStoreConfig

use of com.hazelcast.config.JavaKeyStoreSecureStoreConfig in project hazelcast by hazelcast.

the class TestPersistenceEncryptionKeyStoreApplicationContext method testPersistence.

@Test
public void testPersistence() {
    File dir = new File("/mnt/persistence/");
    File hotBackupDir = new File("/mnt/persistence-backup/");
    PersistenceConfig persistenceConfig = config.getPersistenceConfig();
    assertFalse(persistenceConfig.isEnabled());
    assertEquals(dir.getAbsolutePath(), persistenceConfig.getBaseDir().getAbsolutePath());
    assertEquals(hotBackupDir.getAbsolutePath(), persistenceConfig.getBackupDir().getAbsolutePath());
    assertEquals(1111, persistenceConfig.getValidationTimeoutSeconds());
    assertEquals(2222, persistenceConfig.getDataLoadTimeoutSeconds());
    assertEquals(PARTIAL_RECOVERY_MOST_COMPLETE, persistenceConfig.getClusterDataRecoveryPolicy());
    assertFalse(persistenceConfig.isAutoRemoveStaleData());
    EncryptionAtRestConfig encryptionAtRestConfig = persistenceConfig.getEncryptionAtRestConfig();
    assertNotNull(encryptionAtRestConfig);
    assertTrue(encryptionAtRestConfig.isEnabled());
    assertEquals("AES/CBC/PKCS5Padding", encryptionAtRestConfig.getAlgorithm());
    assertEquals("sugar", encryptionAtRestConfig.getSalt());
    assertEquals(16, encryptionAtRestConfig.getKeySize());
    assertTrue(encryptionAtRestConfig.getSecureStoreConfig() instanceof JavaKeyStoreSecureStoreConfig);
    JavaKeyStoreSecureStoreConfig keyStoreConfig = (JavaKeyStoreSecureStoreConfig) encryptionAtRestConfig.getSecureStoreConfig();
    assertEquals(new File("/mnt/hot-restart/keystore.p12").getAbsolutePath(), keyStoreConfig.getPath().getAbsolutePath());
    assertEquals("PKCS12", keyStoreConfig.getType());
    assertEquals("password", keyStoreConfig.getPassword());
    assertEquals(60, keyStoreConfig.getPollingInterval());
}
Also used : EncryptionAtRestConfig(com.hazelcast.config.EncryptionAtRestConfig) JavaKeyStoreSecureStoreConfig(com.hazelcast.config.JavaKeyStoreSecureStoreConfig) PersistenceConfig(com.hazelcast.config.PersistenceConfig) File(java.io.File) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with JavaKeyStoreSecureStoreConfig

use of com.hazelcast.config.JavaKeyStoreSecureStoreConfig in project hazelcast by hazelcast.

the class MemberDomConfigProcessor method handleJavaKeyStore.

private SecureStoreConfig handleJavaKeyStore(Node keyStoreRoot) {
    File path = null;
    String password = null;
    String type = null;
    String currentKeyAlias = null;
    int pollingInterval = JavaKeyStoreSecureStoreConfig.DEFAULT_POLLING_INTERVAL;
    for (Node n : childElements(keyStoreRoot)) {
        String name = cleanNodeName(n);
        if (matches("path", name)) {
            path = new File(getTextContent(n)).getAbsoluteFile();
        } else if (matches("type", name)) {
            type = getTextContent(n);
        } else if (matches("password", name)) {
            password = getTextContent(n);
        } else if (matches("current-key-alias", name)) {
            currentKeyAlias = getTextContent(n);
        } else if (matches("polling-interval", name)) {
            pollingInterval = parseInt(getTextContent(n));
        }
    }
    JavaKeyStoreSecureStoreConfig keyStoreSecureStoreConfig = new JavaKeyStoreSecureStoreConfig(path).setPassword(password).setPollingInterval(pollingInterval).setCurrentKeyAlias(currentKeyAlias);
    if (type != null) {
        keyStoreSecureStoreConfig.setType(type);
    }
    return keyStoreSecureStoreConfig;
}
Also used : JavaKeyStoreSecureStoreConfig(com.hazelcast.config.JavaKeyStoreSecureStoreConfig) Node(org.w3c.dom.Node) File(java.io.File)

Aggregations

JavaKeyStoreSecureStoreConfig (com.hazelcast.config.JavaKeyStoreSecureStoreConfig)2 File (java.io.File)2 EncryptionAtRestConfig (com.hazelcast.config.EncryptionAtRestConfig)1 PersistenceConfig (com.hazelcast.config.PersistenceConfig)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1