use of com.hazelcast.config.PersistenceConfig 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());
}
use of com.hazelcast.config.PersistenceConfig in project hazelcast by hazelcast.
the class NodeSecurityBanner method printSecurityFeaturesInfo.
@SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:MethodLength" })
private void printSecurityFeaturesInfo(Config config, Level logLevel) {
StringBuilder sb = new StringBuilder("\n").append(getLockEmo()).append("Security recommendations and their status:");
addSecurityFeatureCheck(sb, "Use a custom cluster name", !Config.DEFAULT_CLUSTER_NAME.equals(config.getClusterName()));
addSecurityFeatureCheck(sb, "Disable member multicast discovery/join method", !multicastUsed);
AdvancedNetworkConfig advancedNetworkConfig = config.getAdvancedNetworkConfig();
addSecurityFeatureCheck(sb, "Use advanced networking, separate client and member sockets", advancedNetworkConfig.isEnabled());
boolean bindAny = properties.getBoolean(SOCKET_SERVER_BIND_ANY);
addSecurityFeatureCheck(sb, "Bind Server sockets to a single network interface (disable " + SOCKET_SERVER_BIND_ANY.getName() + ")", !bindAny);
StringBuilder tlsSb = new StringBuilder();
boolean tlsUsed = true;
if (advancedNetworkConfig.isEnabled()) {
for (Map.Entry<EndpointQualifier, EndpointConfig> e : advancedNetworkConfig.getEndpointConfigs().entrySet()) {
tlsUsed = addAdvNetworkTlsInfo(tlsSb, e.getKey(), e.getValue().getSSLConfig()) && tlsUsed;
}
} else {
SSLConfig sslConfig = config.getNetworkConfig().getSSLConfig();
tlsUsed = addSecurityFeatureCheck(tlsSb, "Use TLS communication protection (Enterprise)", sslConfig != null && sslConfig.isEnabled());
}
boolean jetEnabled = config.getJetConfig().isEnabled();
if (jetEnabled) {
boolean trustedEnv = tlsUsed || !bindAny;
addSecurityFeatureCheck(sb, "Use Jet in trusted environments only (single network interface and/or TLS enabled)", trustedEnv);
if (config.getJetConfig().isResourceUploadEnabled()) {
addSecurityFeatureInfo(sb, "Jet resource upload is enabled. Any uploaded code can be executed within " + "Hazelcast. Use this in trusted environments only.");
}
}
if (config.getUserCodeDeploymentConfig().isEnabled()) {
addSecurityFeatureInfo(sb, "User code deployment is enabled. Any uploaded code can be executed within " + "Hazelcast. Use this in trusted environments only.");
}
addSecurityFeatureCheck(sb, "Disable scripting in the Management Center", !config.getManagementCenterConfig().isScriptingEnabled());
addSecurityFeatureCheck(sb, "Disable console in the Management Center", !config.getManagementCenterConfig().isConsoleEnabled());
SecurityConfig securityConfig = config.getSecurityConfig();
boolean securityEnabled = securityConfig != null && securityConfig.isEnabled();
addSecurityFeatureCheck(sb, "Enable Security (Enterprise)", securityEnabled);
if (securityEnabled) {
checkAuthnConfigured(sb, securityConfig, "member-authentication", securityConfig.getMemberRealm());
checkAuthnConfigured(sb, securityConfig, "client-authentication", securityConfig.getClientRealm());
}
// TLS here
sb.append(tlsSb.toString());
PersistenceConfig persistenceConfig = config.getPersistenceConfig();
if (persistenceConfig != null && persistenceConfig.isEnabled()) {
EncryptionAtRestConfig encryptionAtRestConfig = persistenceConfig.getEncryptionAtRestConfig();
addSecurityFeatureCheck(sb, "Enable encryption-at-rest in the Persistence config (Enterprise)", encryptionAtRestConfig != null && encryptionAtRestConfig.isEnabled());
}
AuditlogConfig auditlogConfig = config.getAuditlogConfig();
addSecurityFeatureCheck(sb, "Enable auditlog (Enterprise)", auditlogConfig != null && auditlogConfig.isEnabled());
sb.append("\nCheck the hazelcast-security-hardened.xml/yaml example config file to find why and how to configure" + " these security related settings.\n");
securityLogger.log(logLevel, sb.toString());
}
use of com.hazelcast.config.PersistenceConfig in project hazelcast by hazelcast.
the class DefaultNodeExtension method checkPersistenceAllowed.
private void checkPersistenceAllowed() {
PersistenceConfig persistenceConfig = node.getConfig().getPersistenceConfig();
if (persistenceConfig != null && persistenceConfig.isEnabled()) {
if (!BuildInfoProvider.getBuildInfo().isEnterprise()) {
throw new IllegalStateException("Hot Restart requires Hazelcast Enterprise Edition");
}
}
CPSubsystemConfig cpSubsystemConfig = node.getConfig().getCPSubsystemConfig();
if (cpSubsystemConfig != null && cpSubsystemConfig.isPersistenceEnabled()) {
if (!BuildInfoProvider.getBuildInfo().isEnterprise()) {
throw new IllegalStateException("CP persistence requires Hazelcast Enterprise Edition");
}
}
}
use of com.hazelcast.config.PersistenceConfig in project hazelcast by hazelcast.
the class PersistenceAndHotRestartPersistenceMergerTest method test.
private void test(String template) {
String xml = String.format(template, persistenceEnabled, directory, parallelism, hotRestartPersistenceEnabled, directory + "a", max(parallelism - 1, parallelism + 1));
Config cfg = Config.loadFromString(xml);
HotRestartPersistenceConfig hotRestartPersistenceConfig = cfg.getHotRestartPersistenceConfig();
PersistenceConfig persistenceConfig = cfg.getPersistenceConfig();
assertEquals(persistenceEnabled || hotRestartPersistenceEnabled, persistenceConfig.isEnabled());
assertEquals(new File(expectedDirectory).getAbsolutePath(), persistenceConfig.getBaseDir().getAbsolutePath());
assertEquals(expectedParallelism, persistenceConfig.getParallelism());
assertEquals(persistenceEnabled || hotRestartPersistenceEnabled, hotRestartPersistenceConfig.isEnabled());
assertEquals(new File(expectedDirectory).getAbsolutePath(), hotRestartPersistenceConfig.getBaseDir().getAbsolutePath());
assertEquals(expectedParallelism, hotRestartPersistenceConfig.getParallelism());
}
use of com.hazelcast.config.PersistenceConfig in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handlePersistence.
private void handlePersistence(Node prRoot) throws Exception {
PersistenceConfig prConfig = config.getPersistenceConfig().setEnabled(getBooleanValue(getAttribute(prRoot, "enabled")));
String parallelismName = "parallelism";
String validationTimeoutName = "validation-timeout-seconds";
String dataLoadTimeoutName = "data-load-timeout-seconds";
String rebalanceDelaySecondsName = "rebalance-delay-seconds";
for (Node n : childElements(prRoot)) {
String name = cleanNodeName(n);
if (matches("encryption-at-rest", name)) {
handleEncryptionAtRest(n, prConfig);
} else {
if (matches("base-dir", name)) {
prConfig.setBaseDir(new File(getTextContent(n)).getAbsoluteFile());
} else if (matches("backup-dir", name)) {
prConfig.setBackupDir(new File(getTextContent(n)).getAbsoluteFile());
} else if (matches(parallelismName, name)) {
prConfig.setParallelism(getIntegerValue(parallelismName, getTextContent(n)));
} else if (matches(validationTimeoutName, name)) {
prConfig.setValidationTimeoutSeconds(getIntegerValue(validationTimeoutName, getTextContent(n)));
} else if (matches(dataLoadTimeoutName, name)) {
prConfig.setDataLoadTimeoutSeconds(getIntegerValue(dataLoadTimeoutName, getTextContent(n)));
} else if (matches("cluster-data-recovery-policy", name)) {
prConfig.setClusterDataRecoveryPolicy(PersistenceClusterDataRecoveryPolicy.valueOf(upperCaseInternal(getTextContent(n))));
} else if (matches("auto-remove-stale-data", name)) {
prConfig.setAutoRemoveStaleData(getBooleanValue(getTextContent(n)));
} else if (matches("rebalance-delay-seconds", name)) {
prConfig.setRebalanceDelaySeconds(getIntegerValue(rebalanceDelaySecondsName, getTextContent(n)));
}
}
}
config.setPersistenceConfig(prConfig);
}
Aggregations