1
1
/**
2
- * Copyright 2009-2019 the original author or authors.
2
+ * Copyright 2009-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
19
19
import java .io .ByteArrayOutputStream ;
20
20
import java .io .Externalizable ;
21
21
import java .io .IOException ;
22
- import java .io .InputStream ;
23
22
import java .io .InvalidClassException ;
24
23
import java .io .ObjectInput ;
25
24
import java .io .ObjectInputStream ;
26
25
import java .io .ObjectOutput ;
27
26
import java .io .ObjectOutputStream ;
28
- import java .io .ObjectStreamClass ;
29
27
import java .io .ObjectStreamException ;
30
28
import java .io .StreamCorruptedException ;
31
29
import java .util .Arrays ;
32
30
import java .util .HashMap ;
33
31
import java .util .List ;
34
32
import java .util .Map ;
35
33
34
+ import org .apache .ibatis .io .SerialFilterChecker ;
36
35
import org .apache .ibatis .reflection .factory .ObjectFactory ;
37
36
38
37
/**
@@ -108,8 +107,10 @@ protected final Object readResolve() throws ObjectStreamException {
108
107
return this .userBean ;
109
108
}
110
109
110
+ SerialFilterChecker .check ();
111
+
111
112
/* First run */
112
- try (ObjectInputStream in = new LookAheadObjectInputStream (new ByteArrayInputStream (this .userBeanBytes ))) {
113
+ try (ObjectInputStream in = new ObjectInputStream (new ByteArrayInputStream (this .userBeanBytes ))) {
113
114
this .userBean = in .readObject ();
114
115
this .unloadedProperties = (Map <String , ResultLoaderMap .LoadPair >) in .readObject ();
115
116
this .objectFactory = (ObjectFactory ) in .readObject ();
@@ -130,33 +131,4 @@ protected final Object readResolve() throws ObjectStreamException {
130
131
131
132
protected abstract Object createDeserializationProxy (Object target , Map <String , ResultLoaderMap .LoadPair > unloadedProperties , ObjectFactory objectFactory ,
132
133
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
- }
162
134
}
0 commit comments