Class ProxyTrustVerifier
- All Implemented Interfaces:
TrustVerifier
ProxyTrust and RemoteMethodControl. If a bootstrap proxy (or a
derivative of it) is known to be trusted, a remote call is made through it to obtain a trust
verifier for the original service proxy. This class is intended to be specified in a resource to
configure the operation of Security.verifyObjectTrust.
com.sun.jini.impl - This implementation uses the Logger named
net.jini.security.trust to log information at the following levels: | Level | Description |
|---|---|
FINE | no verifier is obtained from a ProxyTrustIterator |
HANDLED | RemoteException being passed
to ProxyTrustIterator.setException |
FINE | ProxyTrust.getProxyVerifier remote call returns a trust verifier |
FINER | an object with a getProxyTrustIterator method is
encountered |
FINER | each object produced by a
ProxyTrustIterator and each derivative bootstrap proxy |
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.jini.security.TrustVerifier
TrustVerifier.Context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisTrustedObject(Object obj, TrustVerifier.Context ctx) Returnstrueif the specified object is known to be trusted to correctly implement its contract; returnsfalseotherwise.
-
Constructor Details
-
ProxyTrustVerifier
public ProxyTrustVerifier()Creates an instance.
-
-
Method Details
-
isTrustedObject
Returnstrueif the specified object is known to be trusted to correctly implement its contract; returnsfalseotherwise.This method returns
falseif the caller context collection of the specified trust verifier context does not contain aMethodConstraintsinstance with non-empty constraints for theProxyTrust.getProxyVerifiermethod, or if aTrustVerifiercannot be obtained from the specified object using the steps described below. Otherwise aTrustVerifieris obtained, itsisTrustedObjectmethod is called with the same arguments passed to this method, and the result of that call is returned by this method; any exception thrown by that call is thrown by this method. If a verifier cannot be obtained but one or more of the intermediate operations involved in attempting to obtain one throws aRemoteException, the last suchRemoteExceptionis thrown by this method (rather than this method returningfalse). If any intermediate operation throws aSecurityExceptionexception, that exception is immediately thrown by this method.A verifier is obtained from a candidate object as follows.
- If
either the candidate object's class has a non-
staticmember method with signature:ProxyTrustIterator getProxyTrustIterator();
or the candidate object is an instance of a dynamically generatedProxyclass and the contained invocation handler's class has such a member method, then thegetProxyTrustIteratormethod is called (on the candidate object or its invocation handler). For each object produced by thenextmethod of the returned iterator, the following substeps are used, until either a verifier is obtained or the iteration terminates. If no verifier can be obtained from any object produced by the iterator, then there is no verifier for the candidate object. For any given object produced by the iterator, if a verifier cannot be obtained from the object but an intermediate operation involved in attempting to obtain a verifier throws aRemoteException, that exception is passed to thesetExceptionmethod of the iterator, and the iteration continues.The
getProxyTrustIteratormethod and theProxyTrustIteratormethods are all invoked in a restricted security context. If the specified trust verifier context contains anUntrustedObjectSecurityContextinstance, then the security context returned by itsgetContextmethod is used. Otherwise, the security context used is equivalent to the current security context (as returned bySecurity.getContext) with an additional protection domain combined into the access control context that contains an emptyCodeSource(nulllocation and certificates),nullpermissions,nullclass loader, andnullprincipals.- If the object is an instance of both
ProxyTrustandRemoteMethodControl(that is, if the object is a bootstrap proxy), it is verified for trust by calling the specified context'sisTrustedObjectmethod with the object. IfisTrustedObjectreturnstrue, then the object'sgetProxyVerifiermethod is called, using as the client constraints for the remote call the firstMethodConstraintsinstance obtained from the caller context collection (of the specified trust verifier context) that has non-empty constraints for thatgetProxyVerifiermethod. The verifier returned by that remote call is the verifier for the original top-level object, and the entire search stops. IfisTrustedObjectreturnsfalse, but a verifier can be obtained from a trusted derivative bootstrap proxy as described below, then that verifier is the verifier for the original top-level object, and the entire search stops. Otherwise, no verifier can be obtained from the object, and the iteration continues. - If the object is
not a
ProxyTrustinstance, it is in turn treated as a new candidate object, and the complete set of steps for a candidate object are used recursively to obtain a verifier from it. If a verifier can be obtained from it, that verifier is the verifier for the original top-level object, and the entire search stops. If a verifier cannot be obtained from it, the iteration continues.
- If the object is an instance of both
- If the candidate object is the original top-level
object and it is an instance of both
ProxyTrustandRemoteMethodControl(that is, if the original top-level object is itself a bootstrap proxy), and a verifier can be obtained from a trusted derivative bootstrap proxy as described below, that verifier is the verifier for the original top-level object, and the entire search stops.
ProxyTrustVerifier(not including the current one) in this thread; the bootstrap proxy is an instance of a dynamically generatedProxyclass; neither the proxy's class nor the invocation handler's class has an appropriategetProxyTrustIteratormethod; the class loader of the proxy's class is the proper Java(TM) RMI class loader (as defined below) for its parent class loader and the class's codebase (as produced byRMIClassLoader.getClassAnnotation); and bothProxyTrustandRemoteMethodControlare loadable by the parent class loader. The derivative that is produced is an instance of a dynamically generatedProxyclass defined by the parent class loader that implements bothProxyTrustandRemoteMethodControland contains the same invocation handler as the bootstrap proxy. The derivative is a trusted derivative bootstrap proxy if calling the specified context'sisTrustedObjectmethod with the derivative returnstrue. If a trusted derivative bootstrap proxy can be produced, itsgetProxyVerifiermethod is called, using as the client constraints for the remote call the firstMethodConstraintsinstance obtained from the caller context collection (of the specified trust verifier context) that has non-empty constraints for thatgetProxyVerifiermethod. The returned verifier is used as is, if the class loader of the returned verifier's class is equal to the class loader of the original bootstrap proxy's class, or if, in generating a serialization of the verifier, no class passed toObjectOutputStream.annotateClassorObjectOutputStream.annotateProxyClasshas a class loader not equal to the class loader of the original bootstrap proxy's class but has a codebase that is equal to the codebase of the original bootstrap proxy's class. Otherwise, the verifier is remarshalled in a manner equivalent to creating aMarshalledInstancewith the verifier and then calling thegetmethod of that object with the class loader of the original bootstrap proxy's class as the default loader, with no codebase integrity verification and with an empty context collection, and the remarshalled verifier is used instead. If anIOExceptionorClassNotFoundExceptionis thrown by this remarshalling, the exception is wrapped in anUnmarshalExceptionand the resulting exception is treated as if it had been thrown by the remote call that returned the verifier.A class loader of a class is the proper Java RMI class loader for its parent class loader and the class's codebase if the class loader is not
null, the codebase for the class is a non-empty string, and callingRMIClassLoader.getClassLoaderwith that codebase, with the thread's context class loader set to the parent class loader, returns the class loader of the class.- Specified by:
isTrustedObjectin interfaceTrustVerifier- Parameters:
obj- the object in which to verify trustctx- the trust verifier context, to aid in verification of the specified object and its components- Returns:
trueif the specified object is known to be trusted to correctly implement its contract;falseotherwise- Throws:
NullPointerException- if any argument isnullSecurityException- if a security exception occursRemoteException- if a communication-related exception occurs
- If
either the candidate object's class has a non-
-