use of example.serialization.TestExternalizableDeserialized in project hazelcast by hazelcast.
the class ExternalizableDeserializationProtectionTest method testExternalizableProtectedOnMember.
@Test
public void testExternalizableProtectedOnMember() {
JavaSerializationFilterConfig javaSerializationFilterConfig = new JavaSerializationFilterConfig().setDefaultsDisabled(true);
javaSerializationFilterConfig.getBlacklist().addClasses(TestExternalizableDeserialized.class.getName());
Config config = smallInstanceConfig();
config.getSerializationConfig().setJavaSerializationFilterConfig(javaSerializationFilterConfig);
// the index will force deserialization
config.getMapConfig("test").addIndexConfig(new IndexConfig(IndexType.HASH, "name"));
hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
expected.expect(HazelcastSerializationException.class);
client.getMap("test").put("key", new TestExternalizableDeserialized());
}
use of example.serialization.TestExternalizableDeserialized in project hazelcast by hazelcast.
the class ExternalizableDeserializationProtectionTest method testExternalizableUnprotected.
@Test
public void testExternalizableUnprotected() {
Config config = smallInstanceConfig();
config.getMapConfig("test").addIndexConfig(new IndexConfig(IndexType.HASH, "name"));
hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
client.getMap("test").put("key", new TestExternalizableDeserialized());
assertTrue(TestExternalizableDeserialized.isDeserialized);
TestExternalizableDeserialized.isDeserialized = false;
client.getMap("test").get("key");
assertTrue(TestExternalizableDeserialized.isDeserialized);
}
use of example.serialization.TestExternalizableDeserialized in project hazelcast by hazelcast.
the class ExternalizableDeserializationProtectionTest method testExternalizableProtectedOnClient.
@Test
public void testExternalizableProtectedOnClient() {
JavaSerializationFilterConfig javaSerializationFilterConfig = new JavaSerializationFilterConfig().setDefaultsDisabled(true);
javaSerializationFilterConfig.getBlacklist().addClasses(TestExternalizableDeserialized.class.getName());
Config config = smallInstanceConfig();
hazelcastFactory.newHazelcastInstance(config);
ClientConfig clientConfig1 = new ClientConfig();
HazelcastInstance client1 = hazelcastFactory.newHazelcastClient(clientConfig1);
client1.getMap("test").put("key", new TestExternalizableDeserialized());
// we don't have an index on map, so the value should not be deserialized
assertFalse(TestExternalizableDeserialized.isDeserialized);
// deserialized on client
client1.getMap("test").get("key");
assertTrue(TestExternalizableDeserialized.isDeserialized);
TestExternalizableDeserialized.isDeserialized = false;
ClientConfig clientConfig2 = new ClientConfig();
clientConfig2.getSerializationConfig().setJavaSerializationFilterConfig(javaSerializationFilterConfig);
HazelcastInstance client2 = hazelcastFactory.newHazelcastClient(clientConfig2);
expected.expect(HazelcastSerializationException.class);
client2.getMap("test").get("key");
}
Aggregations