diff --git a/framework/base/config/SafeObjectInputStream.properties b/framework/base/config/SafeObjectInputStream.properties index bdc5b4a425..548eab76be 100644 --- a/framework/base/config/SafeObjectInputStream.properties +++ b/framework/base/config/SafeObjectInputStream.properties @@ -21,7 +21,9 @@ # If you encounter a related issue (object not in the whitelist), # you must provide a complete list of objects to pass to ObjectInputStream # through ListOfSafeObjectsForInputStream property -# As an example, the a complete list of objects used by OFBiz OOTB is commented out by default here. +# As an example, the a complete list of objects used by OFBiz OOTB is here. # You will need to add your objects/classes to this list. +# OFBiz committers: don't forget to add newobjects in SafeObjectInputStream class too (as default there). -#listOfSafeObjectsForInputStream=byte\\\\[\\\\], foo, SerializationInjector, \\\\[Z,\\\\[B,\\\\[S,\\\\[I,\\\\[J,\\\\[F,\\\\[D,\\\\[C, java..*, sun.util.calendar..*, org.apache.ofbiz..* + +listOfSafeObjectsForInputStream=byte\\\\[\\\\], foo, SerializationInjector, \\\\[Z,\\\\[B,\\\\[S,\\\\[I,\\\\[J,\\\\[F,\\\\[D,\\\\[C, java..*, sun.util.calendar..*, org.apache.ofbiz..*, org.codehaus.groovy.runtime.GStringImpl, groovy.lang.GString diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/SafeObjectInputStream.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/SafeObjectInputStream.java index c48699a101..2aebcdeb5d 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/SafeObjectInputStream.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/SafeObjectInputStream.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -15,77 +15,62 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - *******************************************************************************/ + */ package org.apache.ofbiz.base.util; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.joining; +import static org.apache.ofbiz.base.util.UtilProperties.getPropertyValue; + import java.io.IOException; import java.io.InputStream; +import java.io.ObjectInputStream; import java.io.ObjectStreamClass; -import java.lang.reflect.Proxy; -import java.util.List; +import java.util.Arrays; import java.util.regex.Pattern; /** - * ObjectInputStream + * SafeObjectInputStream * + *
An implementation of {@link java.io.ObjectInputStream} that ensure that
+ * only authorized class can be read from it.
*/
-public class SafeObjectInputStream extends java.io.ObjectInputStream {
-
- private ClassLoader classloader;
- private Pattern WHITELIST_PATTERN = null;
-
- public SafeObjectInputStream(InputStream in, ClassLoader loader) throws IOException {
- super(in);
- this.classloader = loader;
- }
-
- public SafeObjectInputStream(InputStream in, ClassLoader loader, List