Class ProxyTrustInvocationHandler
- All Implemented Interfaces:
Serializable,InvocationHandler,TrustEquivalence
ProxyTrustVerifier. This invocation handler contains both an underlying main proxy and a
bootstrap proxy; the main proxy is not expected to be considered trusted directly by clients, but
the bootstrap proxy is. The main proxy must be an instance of both RemoteMethodControl
and TrustEquivalence, and the bootstrap proxy must be an instance of ProxyTrust,
RemoteMethodControl, and TrustEquivalence. This invocation handler
handles most method invocations by delegating to the main proxy. The bootstrap proxy is produced
by the iterator returned by the getProxyTrustIterator method, as
required by ProxyTrustVerifier.- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionProxyTrustInvocationHandler(RemoteMethodControl main, ProxyTrust boot) Creates an instance with the specified main proxy and bootstrap proxy. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif the argument is an instance of this class, and calling thecheckTrustEquivalencemethod on the main proxy of this invocation handler, passing the main proxy of the argument, returnstrue, and calling thecheckTrustEquivalencemethod on the bootstrap proxy of this invocation handler, passing the bootstrap proxy of the argument, returnstrue, and returnsfalseotherwise.static booleanequalInterfaces(Object obj1, Object obj2) Returns true if the interfaces implemented by obj1's class are the same (and in the same order) as obj2's class.booleanReturnstrueif the argument is an instance of this class with the same main proxy and the same bootstrap proxy, andfalseotherwise.protected ProxyTrustIteratorReturns an iterator that produces the bootstrap proxy as the only element of the iteration.inthashCode()Returns a hash code value for this object.Executes the specified method with the specified arguments on the specified proxy, and returns the return value, if any.static booleansameProxyClass(Object proxy1, Object proxy2) Returns true if proxy2 is a generated Proxy (proxy1 is assumed to be one) and the classes of both proxies implement the same ordered list of interfaces, and returns false otherwise.toString()Returns a string representation of this object.
-
Constructor Details
-
ProxyTrustInvocationHandler
Creates an instance with the specified main proxy and bootstrap proxy.- Parameters:
main- the main proxyboot- the bootstrap proxy- Throws:
NullPointerException- if any argument isnullIllegalArgumentException- if the main proxy is not an instance ofTrustEquivalence, or the bootstrap proxy is not an instance ofRemoteMethodControlorTrustEquivalence
-
-
Method Details
-
invoke
Executes the specified method with the specified arguments on the specified proxy, and returns the return value, if any.If the specified method is
Object.equals, returnstrueif the argument (args[0]) is an instance of a dynamic proxy class (that is, a class generated byProxy) that implements the same interfaces as the specified proxy and this invocation handler is equal to the invocation handler of that argument, and returnsfalseotherwise.If the specified method is
Object.toString, returns a string representation of the specified proxy object.If the specified method is
Object.hashCode, returns a hash code for the specified proxy object.If the specified method is
RemoteMethodControl.setConstraints, returns a new proxy (an instance of the same class as the specified proxy) containing an instance of this class with a new main proxy and the same bootstrap proxy from this handler. The new main proxy is obtained by delegating to the existing main proxy of this handler (as described below). An exception is thrown if the specified proxy is not an instance of a dynamic proxy class containing this invocation handler.If the specified method is
TrustEquivalence.checkTrustEquivalence, returnstrueif the argument (args[0]) is an instance of a dynamic proxy class that implements the same interfaces as the specified proxy and calling thecheckTrustEquivalencemethod of this invocation handler with the invocation handler of that argument returnstrue, and returnsfalseotherwise.For all other methods, returns the object obtained by delegating to the main proxy: the specified method is reflectively invoked on the main proxy with the specified arguments, unless the method's declaring class is not public but the main proxy is an instance of that declaring class and the main proxy's class is public, in which case the corresponding method of the main proxy's class is reflectively invoked instead.
The semantics of this method are unspecified if the arguments could not have been produced by an instance of some valid dynamic proxy class containing this invocation handler.
- Specified by:
invokein interfaceInvocationHandler- Parameters:
proxy- the proxy objectmethod- the method being invokedargs- the arguments to the specified method- Returns:
- the value returned by executing the specified method on the specified proxy with the
specified arguments, or
nullif the method hasvoidreturn type - Throws:
Throwable- the exception thrown by executing the specified methodIllegalArgumentException- if the declaring class of the specified method is not public and either the main proxy is not an instance of that declaring class or the main proxy's class is not public
-
checkTrustEquivalence
Returnstrueif the argument is an instance of this class, and calling thecheckTrustEquivalencemethod on the main proxy of this invocation handler, passing the main proxy of the argument, returnstrue, and calling thecheckTrustEquivalencemethod on the bootstrap proxy of this invocation handler, passing the bootstrap proxy of the argument, returnstrue, and returnsfalseotherwise.- Specified by:
checkTrustEquivalencein interfaceTrustEquivalence- Parameters:
obj- object to check that is not yet known to be trusted- Returns:
trueif the specified object (that is not yet known to be trusted) is equivalent in trust, content, and function to this known trusted object, and returnsfalseotherwise
-
equals
Returnstrueif the argument is an instance of this class with the same main proxy and the same bootstrap proxy, andfalseotherwise. -
hashCode
public int hashCode()Returns a hash code value for this object. -
toString
Returns a string representation of this object. -
getProxyTrustIterator
Returns an iterator that produces the bootstrap proxy as the only element of the iteration.- Returns:
- an iterator that produces the bootstrap proxy as the only element of the iteration
-
sameProxyClass
Returns true if proxy2 is a generated Proxy (proxy1 is assumed to be one) and the classes of both proxies implement the same ordered list of interfaces, and returns false otherwise. -
equalInterfaces
Returns true if the interfaces implemented by obj1's class are the same (and in the same order) as obj2's class.
-