11/**
2- * Copyright 2009-2019 the original author or authors.
2+ * Copyright 2009-2020 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1919import java .io .ByteArrayOutputStream ;
2020import java .io .Externalizable ;
2121import java .io .IOException ;
22- import java .io .InputStream ;
2322import java .io .InvalidClassException ;
2423import java .io .ObjectInput ;
2524import java .io .ObjectInputStream ;
2625import java .io .ObjectOutput ;
2726import java .io .ObjectOutputStream ;
28- import java .io .ObjectStreamClass ;
2927import java .io .ObjectStreamException ;
3028import java .io .StreamCorruptedException ;
3129import java .util .Arrays ;
3230import java .util .HashMap ;
3331import java .util .List ;
3432import java .util .Map ;
3533
34+ import org .apache .ibatis .io .SerialFilterChecker ;
3635import org .apache .ibatis .reflection .factory .ObjectFactory ;
3736
3837/**
@@ -108,8 +107,10 @@ protected final Object readResolve() throws ObjectStreamException {
108107 return this .userBean ;
109108 }
110109
110+ SerialFilterChecker .check ();
111+
111112 /* First run */
112- try (ObjectInputStream in = new LookAheadObjectInputStream (new ByteArrayInputStream (this .userBeanBytes ))) {
113+ try (ObjectInputStream in = new ObjectInputStream (new ByteArrayInputStream (this .userBeanBytes ))) {
113114 this .userBean = in .readObject ();
114115 this .unloadedProperties = (Map <String , ResultLoaderMap .LoadPair >) in .readObject ();
115116 this .objectFactory = (ObjectFactory ) in .readObject ();
@@ -130,33 +131,4 @@ protected final Object readResolve() throws ObjectStreamException {
130131
131132 protected abstract Object createDeserializationProxy (Object target , Map <String , ResultLoaderMap .LoadPair > unloadedProperties , ObjectFactory objectFactory ,
132133 List <Class <?>> constructorArgTypes , List <Object > constructorArgs );
133-
134- private static class LookAheadObjectInputStream extends ObjectInputStream {
135- private static final List <String > blacklist = Arrays .asList (
136- "org.apache.commons.beanutils.BeanComparator" ,
137- "org.apache.commons.collections.functors.InvokerTransformer" ,
138- "org.apache.commons.collections.functors.InstantiateTransformer" ,
139- "org.apache.commons.collections4.functors.InvokerTransformer" ,
140- "org.apache.commons.collections4.functors.InstantiateTransformer" ,
141- "org.codehaus.groovy.runtime.ConvertedClosure" ,
142- "org.codehaus.groovy.runtime.MethodClosure" ,
143- "org.springframework.beans.factory.ObjectFactory" ,
144- "org.springframework.transaction.jta.JtaTransactionManager" ,
145- "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl" );
146-
147- public LookAheadObjectInputStream (InputStream in ) throws IOException {
148- super (in );
149- }
150-
151- @ Override
152- protected Class <?> resolveClass (ObjectStreamClass desc ) throws IOException , ClassNotFoundException {
153- String className = desc .getName ();
154- if (blacklist .contains (className )) {
155- throw new InvalidClassException (className , "Deserialization is not allowed for security reasons. "
156- + "It is strongly recommended to configure the deserialization filter provided by JDK. "
157- + "See http://openjdk.java.net/jeps/290 for the details." );
158- }
159- return super .resolveClass (desc );
160- }
161- }
162134}
0 commit comments