37584
|
1 |
/*
|
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package sun.rmi.server;
|
|
27 |
|
|
28 |
import java.io.ObjectStreamClass;
|
|
29 |
import java.lang.reflect.Method;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Implementing this interface to have a deserialization control when RMI
|
|
33 |
* dispatches a remote request. If an exported object implements this interface,
|
|
34 |
* RMI dispatching mechanism will call the method {@code check} every time
|
|
35 |
* deserialising a remote object for invoking a method of the exported object.
|
|
36 |
*
|
|
37 |
* @author sjiang
|
|
38 |
*/
|
|
39 |
public interface DeserializationChecker {
|
|
40 |
/**
|
|
41 |
* Will be called to check a descriptor.
|
|
42 |
* This method may be called 2 times, the first time is when a descriptor is read
|
|
43 |
* from the stream, the second is just before creating an object described
|
|
44 |
* by this descriptor.
|
|
45 |
*
|
|
46 |
* @param method the method invoked from a remote request.
|
|
47 |
* @param descriptor The descriptor of the class of any object deserialised
|
|
48 |
* while deserialising the parameter. The first descriptor will be that of
|
|
49 |
* the top level object (the concrete class of the parameter itself);
|
|
50 |
* Subsequent calls with the same {@code method}, {@code paramIndex} and
|
|
51 |
* {@code callID} will correspond to objects contained in the parameter.
|
|
52 |
* @param paramIndex an index indicates the position of a parameter in the
|
|
53 |
* method. This index will be reused for deserialising all
|
|
54 |
* objects contained in the parameter object. For example, the parameter
|
|
55 |
* being deserialised is a {@code List}, all deserialisation calls for its
|
|
56 |
* elements will have same index.
|
|
57 |
* @param callID a unique ID identifying one
|
|
58 |
* time method invocation, the same ID is used for deserialization call of
|
|
59 |
* all parameters within the method.
|
|
60 |
*/
|
|
61 |
public void check(Method method,
|
|
62 |
ObjectStreamClass descriptor,
|
|
63 |
int paramIndex,
|
|
64 |
int callID);
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Will be called to validate a Proxy interfaces from a remote user before loading it.
|
|
68 |
* @param method the method invoked from a remote request.
|
|
69 |
* @param ifaces a string table of all interfaces implemented by the proxy to be checked.
|
|
70 |
* @param paramIndex an index indicates the position of a parameter in the
|
|
71 |
* method. This index will be reused for deserialising all
|
|
72 |
* objects contained in the parameter object. For example, the parameter
|
|
73 |
* being deserialised is a {@code List}, all deserialisation calls for its
|
|
74 |
* elements will have same index.
|
|
75 |
* @param callID a unique ID identifying one
|
|
76 |
* time method invocation, the same ID is used for deserialization call of
|
|
77 |
* all parameters within the method.
|
|
78 |
*/
|
|
79 |
public void checkProxyClass(Method method,
|
|
80 |
String[] ifaces,
|
|
81 |
int paramIndex,
|
|
82 |
int callID);
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Inform of the completion of parameter deserialisation for a method invocation.
|
|
86 |
* This is useful if the last parameter is a complex object, like a {@code List}
|
|
87 |
* which elements are complex object too.
|
|
88 |
*
|
|
89 |
* The default implementation does nothing.
|
|
90 |
* @param callID the ID identifying a method invocation.
|
|
91 |
*/
|
|
92 |
public default void end(int callID) {}
|
|
93 |
}
|