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