GigaSpaces XAP 9.7.2 API

net.jini.security.proxytrust
Class ProxyTrustInvocationHandler

java.lang.Object
  extended by net.jini.security.proxytrust.ProxyTrustInvocationHandler
All Implemented Interfaces:
Serializable, InvocationHandler, TrustEquivalence

public final class ProxyTrustInvocationHandler
extends Object
implements InvocationHandler, TrustEquivalence, Serializable

Invocation handler for remote objects, supporting proxy trust verification by clients using 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:
Serialized Form

Constructor Summary
ProxyTrustInvocationHandler(RemoteMethodControl main, ProxyTrust boot)
          Creates an instance with the specified main proxy and bootstrap proxy.
 
Method Summary
 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.
static boolean equalInterfaces(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.
 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.
static boolean sameProxyClass(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.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProxyTrustInvocationHandler

public ProxyTrustInvocationHandler(RemoteMethodControl main,
                                   ProxyTrust boot)
Creates an instance with the specified main proxy and bootstrap proxy.

Parameters:
main - the main proxy
boot - the bootstrap proxy
Throws:
NullPointerException - 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
Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
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, 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.

Specified by:
invoke in interface InvocationHandler
Parameters:
proxy - the proxy object
method - the method being invoked
args - the arguments to the specified method
Returns:
the value returned by executing the specified method on the specified proxy with the specified arguments, or null if the method has void return type
Throws:
Throwable - the exception thrown by executing the specified method
IllegalArgumentException - 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

public 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.

Specified by:
checkTrustEquivalence in interface TrustEquivalence
Parameters:
obj - object to check that is not yet known to be trusted
Returns:
true 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 otherwise

equals

public 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.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object

getProxyTrustIterator

protected ProxyTrustIterator 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

public static boolean sameProxyClass(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.


equalInterfaces

public static boolean equalInterfaces(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.


GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.