Class VerifyingProxyPreparer
- All Implemented Interfaces:
ProxyPreparer
ProxyPreparer for verifying that proxies are trusted, dynamically granting
permissions to trusted proxies, and optionally setting the client constraints on trusted
proxies.- Since:
- 2.1
- Author:
- Sun Microsystems, Inc.
-
Constructor Summary
ConstructorsConstructorDescriptionVerifyingProxyPreparer(boolean addProxyConstraints, ClassLoader loader, Object[] contextElements, Principal[] principals, Permission[] permissions) Creates a proxy preparer that verifies proxies using the specified class loader and trust verifier context elements (optionally with the proxy's client constraints as an additional context element), dynamically grants the specified permissions to trusted proxies for the specified principals, and returns trusted proxies with their original client constraints intact.VerifyingProxyPreparer(ClassLoader loader, Object[] contextElements, Principal[] principals, Permission[] permissions) Creates a proxy preparer that verifies proxies using the specified class loader and trust verifier context elements, dynamically grants the specified permissions to trusted proxies for the specified principals, and returns trusted proxies with their client constraints set to the constraints specified as a trust verifier context element.VerifyingProxyPreparer(Object[] contextElements, Permission[] permissions) Creates a proxy preparer that verifies proxies using the context class loader and specified trust verifier context elements, dynamically grants the specified permissions to trusted proxies for the principals of the preparing thread's subject, and returns trusted proxies with their client constraints set to the constraints specified as a trust verifier context element. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif the specified object and this object are both instances of this class that were constructed with equivalent arguments.inthashCode()Returns a hash code value for this object.prepareProxy(Object proxy) Performs operations on a proxy to prepare it for use, returning the prepared proxy, which may or may not be the argument itself.toString()Returns a string representation of this object.
-
Constructor Details
-
VerifyingProxyPreparer
Creates a proxy preparer that verifies proxies using the context class loader and specified trust verifier context elements, dynamically grants the specified permissions to trusted proxies for the principals of the preparing thread's subject, and returns trusted proxies with their client constraints set to the constraints specified as a trust verifier context element. The arrays passed to this constructor are neither modified nor retained; subsequent changes to the arrays have no effect on the instance created.- Parameters:
contextElements- the trust verifier context elementspermissions- the permissions to dynamically grant, ornullif no permissions should be granted- Throws:
NullPointerException- ifcontextElementsisnullor any element ofpermissionsisnullIllegalArgumentException- if no element ofcontextElementsis an instance ofMethodConstraints
-
VerifyingProxyPreparer
public VerifyingProxyPreparer(ClassLoader loader, Object[] contextElements, Principal[] principals, Permission[] permissions) Creates a proxy preparer that verifies proxies using the specified class loader and trust verifier context elements, dynamically grants the specified permissions to trusted proxies for the specified principals, and returns trusted proxies with their client constraints set to the constraints specified as a trust verifier context element. The arrays passed to this constructor are neither modified nor retained; subsequent changes to the arrays have no effect on the instance created.- Parameters:
loader- the class loader for finding trust verifiers, ornullto use the context class loadercontextElements- the trust verifier context elementsprincipals- minimum set of principals to which grants apply, ornullto use the principals of the preparing thread's subjectpermissions- the permissions to dynamically grant, ornullif no permissions should be granted- Throws:
NullPointerException- ifcontextElementsisnullor any element ofprincipalsorpermissionsisnullIllegalArgumentException- if no element ofcontextElementsis an instance ofMethodConstraints
-
VerifyingProxyPreparer
public VerifyingProxyPreparer(boolean addProxyConstraints, ClassLoader loader, Object[] contextElements, Principal[] principals, Permission[] permissions) Creates a proxy preparer that verifies proxies using the specified class loader and trust verifier context elements (optionally with the proxy's client constraints as an additional context element), dynamically grants the specified permissions to trusted proxies for the specified principals, and returns trusted proxies with their original client constraints intact. The arrays passed to this constructor are neither modified nor retained; subsequent changes to the arrays have no effect on the instance created.- Parameters:
addProxyConstraints-trueif the proxy's client constraints should be included as a trust verifier context element,falseotherwiseloader- the class loader for finding trust verifiers, ornullto use the context class loadercontextElements- the trust verifier context elements, ornullif no elements need to be suppliedprincipals- minimum set of principals to which grants apply, ornullto use the principals of the preparing thread's subjectpermissions- the permissions to dynamically grant, ornullif no permissions should be granted- Throws:
NullPointerException- if any element ofprincipalsorpermissionsisnull
-
-
Method Details
-
prepareProxy
Performs operations on a proxy to prepare it for use, returning the prepared proxy, which may or may not be the argument itself.If this preparer was created using the two-argument or four-argument constructor, or using the five-argument constructor with
addProxyConstraintsset totrue, and if the specified proxy is not an instance ofRemoteMethodControl, then aSecurityExceptionis thrown. Otherwise,Security.verifyObjectTrustis invoked with the specified proxy, the class loader that was passed to the constructor of this preparer (ornullif the two-argument constructor was used), and a trust verifier context collection containing all of the context elements that were passed to the constructor of this preparer. If this preparer was created using the five-arguent constructor withaddProxyConstraintsset totrue, then the proxy's client constraints (obtained by callinggetConstraintson the proxy) are included as an additional context element. Any exception thrown byverifyObjectTrustis thrown by this method. If this preparer was created with a non-nullarray of principals and one or more permissions, thenSecurity.grantis invoked with the proxy's class and those principals and permissions. If this preparer was created with no array of principals (eithernullwas specified or the two-argument constructor was used) but one or more permissions, thenSecurity.grantis invoked with the proxy's class and those permissions. In either case, ifgrantthrows anUnsupportedOperationException, this method throws aSecurityException. Finally, if this preparer was created using the five-argument constructor, then the original proxy is returned, otherwise what is returned is the result of callingRemoteMethodControl.setConstraintson the proxy, passing the first trust verifier context element that is an instance ofMethodConstraints.- Specified by:
prepareProxyin interfaceProxyPreparer- Parameters:
proxy- the proxy to prepare- Returns:
- the prepared proxy
- Throws:
NullPointerException- ifproxyisnullRemoteException- if a communication-related exception occursSecurityException- if a security exception occurs
-
toString
Returns a string representation of this object. -
equals
Returnstrueif the specified object and this object are both instances of this class that were constructed with equivalent arguments. The order of trust verifier context elements, principals, and permissions in the arrays that were passed to the constructor is not significant. -
hashCode
public int hashCode()Returns a hash code value for this object.
-