Search in sources :

Example 1 with SerializationConfig

use of io.helidon.common.SerializationConfig in project helidon by oracle.

the class DeserializationTest method configureDeserialization.

@BeforeAll
static void configureDeserialization() {
    ObjectInputFilter myFilter = filterInfo -> {
        if (filterInfo.serialClass() == null) {
            return ObjectInputFilter.Status.UNDECIDED;
        }
        if (filterInfo.serialClass().equals(Configured.class)) {
            return ObjectInputFilter.Status.ALLOWED;
        }
        return ObjectInputFilter.Status.UNDECIDED;
    };
    ObjectInputFilter.Config.setSerialFilter(myFilter);
    // JDK Filter configured in pom.xml
    SerializationConfig sc = SerializationConfig.builder().onWrongConfig(SerializationConfig.Action.FAIL).onNoConfig(SerializationConfig.Action.IGNORE).ignoreFiles(false).traceSerialization(SerializationConfig.TraceOption.NONE).build();
    // should fail, as we do not have a blacklist for all other
    assertThrows(IllegalStateException.class, sc::configure);
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) CoreMatchers(org.hamcrest.CoreMatchers) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectInputStream(java.io.ObjectInputStream) IOException(java.io.IOException) Random(java.util.Random) Test(org.junit.jupiter.api.Test) ByteArrayInputStream(java.io.ByteArrayInputStream) BeforeAll(org.junit.jupiter.api.BeforeAll) ObjectOutputStream(java.io.ObjectOutputStream) SerializationConfig(io.helidon.common.SerializationConfig) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ObjectInputFilter(java.io.ObjectInputFilter) ObjectInputFilter(java.io.ObjectInputFilter) SerializationConfig(io.helidon.common.SerializationConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with SerializationConfig

use of io.helidon.common.SerializationConfig in project helidon by oracle.

the class DeserializationTest method configureDeserialization.

@BeforeAll
static void configureDeserialization() {
    // JDK Filter configured in pom.xml
    SerializationConfig sc = SerializationConfig.builder().onWrongConfig(SerializationConfig.Action.FAIL).onNoConfig(SerializationConfig.Action.IGNORE).ignoreFiles(false).traceSerialization(SerializationConfig.TraceOption.NONE).build();
    // should fail, as we do not have a blacklist for all other
    assertThrows(IllegalStateException.class, sc::configure);
}
Also used : SerializationConfig(io.helidon.common.SerializationConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with SerializationConfig

use of io.helidon.common.SerializationConfig in project helidon by oracle.

the class DeserializationTest method configureDeserialization.

@BeforeAll
static void configureDeserialization() {
    ObjectInputFilter myFilter = filterInfo -> {
        if (filterInfo.serialClass() == null) {
            return ObjectInputFilter.Status.UNDECIDED;
        }
        if (filterInfo.serialClass().equals(Configured.class)) {
            return ObjectInputFilter.Status.ALLOWED;
        }
        return ObjectInputFilter.Status.REJECTED;
    };
    ObjectInputFilter.Config.setSerialFilter(myFilter);
    SerializationConfig sc = SerializationConfig.builder().onWrongConfig(SerializationConfig.Action.FAIL).onNoConfig(SerializationConfig.Action.IGNORE).ignoreFiles(false).traceSerialization(SerializationConfig.TraceOption.NONE).build();
    // should not fail, as we have a blacklist for all other
    sc.configure();
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) CoreMatchers(org.hamcrest.CoreMatchers) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectInputStream(java.io.ObjectInputStream) IOException(java.io.IOException) Random(java.util.Random) InvalidClassException(java.io.InvalidClassException) Test(org.junit.jupiter.api.Test) ByteArrayInputStream(java.io.ByteArrayInputStream) BeforeAll(org.junit.jupiter.api.BeforeAll) ObjectOutputStream(java.io.ObjectOutputStream) SerializationConfig(io.helidon.common.SerializationConfig) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ObjectInputFilter(java.io.ObjectInputFilter) ObjectInputFilter(java.io.ObjectInputFilter) SerializationConfig(io.helidon.common.SerializationConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with SerializationConfig

use of io.helidon.common.SerializationConfig in project helidon by oracle.

the class DeserializationTest method configureDeserialization.

@BeforeAll
static void configureDeserialization() {
    SerializationConfig sc = SerializationConfig.builder().onWrongConfig(SerializationConfig.Action.IGNORE).onNoConfig(SerializationConfig.Action.FAIL).ignoreFiles(false).traceSerialization(SerializationConfig.TraceOption.NONE).build();
    assertThrows(IllegalStateException.class, sc::configure);
}
Also used : SerializationConfig(io.helidon.common.SerializationConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with SerializationConfig

use of io.helidon.common.SerializationConfig in project helidon by oracle.

the class DeserializationTest method configureDeserialization.

@BeforeAll
static void configureDeserialization() {
    // JDK Filter configured in pom.xml
    SerializationConfig sc = SerializationConfig.builder().onWrongConfig(SerializationConfig.Action.FAIL).onNoConfig(SerializationConfig.Action.FAIL).ignoreFiles(false).traceSerialization(SerializationConfig.TraceOption.NONE).build();
    // should not fail, as we have a blacklist for all other
    sc.configure();
}
Also used : SerializationConfig(io.helidon.common.SerializationConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

SerializationConfig (io.helidon.common.SerializationConfig)5 BeforeAll (org.junit.jupiter.api.BeforeAll)5 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 ObjectInputFilter (java.io.ObjectInputFilter)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 Random (java.util.Random)2 CoreMatchers (org.hamcrest.CoreMatchers)2 CoreMatchers.is (org.hamcrest.CoreMatchers.is)2 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)2 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)2 Test (org.junit.jupiter.api.Test)2 InvalidClassException (java.io.InvalidClassException)1