public final class ProxyTrustInvocationHandler extends Object implements InvocationHandler, TrustEquivalence, Serializable
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
.Constructor and Description |
---|
ProxyTrustInvocationHandler(RemoteMethodControl main,
ProxyTrust boot)
Creates an instance with the specified main proxy and bootstrap proxy.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkTrustEquivalence(Object obj)
Returns
true if the argument is an instance of this
class, and calling the checkTrustEquivalence method on
the main proxy of this invocation handler, passing the main proxy of
the argument, returns true , and calling the
checkTrustEquivalence method on the bootstrap proxy of
this invocation handler, passing the bootstrap proxy of the argument,
returns true , and returns false otherwise. |
boolean |
equals(Object obj)
Returns
true if the argument is an instance of this
class with the same main proxy and the same bootstrap proxy, and
false otherwise. |
protected ProxyTrustIterator |
getProxyTrustIterator()
Returns an iterator that produces the bootstrap proxy as the only
element of the iteration.
|
int |
hashCode()
Returns a hash code value for this object.
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Executes the specified method with the specified arguments on the
specified proxy, and returns the return value, if any.
|
String |
toString()
Returns a string representation of this object.
|
public ProxyTrustInvocationHandler(RemoteMethodControl main, ProxyTrust boot)
main
- the main proxyboot
- the bootstrap proxyNullPointerException
- if any argument is null
IllegalArgumentException
- if the main proxy is not an instance
of TrustEquivalence
, or the bootstrap proxy is not an instance
of RemoteMethodControl
or TrustEquivalence
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
If the specified method is Object.equals
, returns
true
if the argument (args[0]
) is an
instance of a dynamic proxy class (that is, a class generated by
Proxy
) that implements the same interfaces as the specified
proxy and this invocation handler is equal to the invocation handler
of that argument, and returns false
otherwise.
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
, returns true
if
the argument (args[0]
) is an instance of a dynamic proxy
class that implements the same interfaces as the specified proxy and
calling the checkTrustEquivalence
method
of this invocation handler with the invocation handler of that argument
returns true
, and returns false
otherwise.
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.
invoke
in interface InvocationHandler
proxy
- the proxy objectmethod
- the method being invokedargs
- the arguments to the specified methodnull
if the method has void
return typeThrowable
- 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
publicpublic boolean checkTrustEquivalence(Object obj)
true
if the argument is an instance of this
class, and calling the checkTrustEquivalence
method on
the main proxy of this invocation handler, passing the main proxy of
the argument, returns true
, and calling the
checkTrustEquivalence
method on the bootstrap proxy of
this invocation handler, passing the bootstrap proxy of the argument,
returns true
, and returns false
otherwise.checkTrustEquivalence
in interface TrustEquivalence
obj
- object to check that is not yet known to be trustedtrue
if the specified object (that is not yet
known to be trusted) is equivalent in trust, content, and function to
this known trusted object, and returns false
otherwisepublic boolean equals(Object obj)
true
if the argument is an instance of this
class with the same main proxy and the same bootstrap proxy, and
false
otherwise.public int hashCode()
public String toString()
protected ProxyTrustIterator getProxyTrustIterator()
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.