Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.security.permissions   Previous This
Package
Next

 


Class ReflectionRequest

public class ReflectionRequest implements ISecurityRequest
{
  // Constructors
  public ReflectionRequest(int type, Class target);

  // Methods
  public PermissionID getPermissionID();
  public String toString ();
}

This class represents a request to use the reflection APIs to gain access to members of a specified class. The type of access can be either to public members or to declared members of the class. ReflectionRequest objects should be used as the security request objects for parameterized security checks involving the reflection permission. The ReflectionPermission.check method expects a ReflectionRequest object as its parameter.

Here is an example that shows how to use a ReflectionRequest object to perform a security check.


  ...
  // Create a ReflectionRequest object that indicates that you want to
  // access the public members of a specific class.

  Class cls = java.lang.String.class;
  ReflectionRequest sreq = new ReflectionRequest(Member.PUBLIC,cls);

  // Check to see that all of your callers have the rights to
  // access the public members of the class.

  PolicyEngine.checkPermission(sreq);
  ...

For more information about checking reflection permissions, see the PolicyEngine class and the ReflectionPermission class.

Constructors

ReflectionRequest

public ReflectionRequest(int type, Class target);

Creates a ReflectionRequest object based on the access type requested and the class instance to reflect.

ParameterDescription
type The type of reflection access that is requested. This value must be either java.lang.reflect.Member.PUBLIC or java.lang.reflect.Member.DECLARED.
target The class to examine with the reflection APIs.

Methods

getPermissionID

public PermissionID getPermissionID();

Retrieves the permission identifier for the ReflectionRequest object.

Return Value:

Returns PermissionID.REFLECTION.

Remarks:

This method satisfies the ISecurityRequest interface and returns PermissionID.REFLECTION to indicate that instances of the ReflectionRequest class are associated with the reflection permission.

toString

public String toString ();

Converts the ReflectionRequest object to its string representation.

Return Value:

Returns the string representation of the ReflectionRequest object.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.