Microsoft SDK for Java

FileIORequest Class

The FileIORequest Class of the com.ms.security.permissions package represents a request for access to the file system. FileIORequest instances should be used as the security request objects for parameterized security checks involving the file I/O permission.

public class FileIORequest implements ISecurityRequest
{
  // Fields
  public static final int DELETE;
  public static final int READ;
  public static final int WRITE;

  // Constructors
  public FileIORequest(int type, String file);
  public FileIORequest(int type);

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

The FileIOPermission.check method expects a FileIORequest object as its parameter.

Example

The following example shows how to use a FileIORequest object to perform a security check to determine whether a file called sample.txt can be opened for reading:

  ...
  // Create a FileIORequest object that indicates that you want to
  // read the file called "c:\\sample.txt".

  FileIORequest sreq = new FileIORequest(FileIORequest.READ,"c:\\sample.txt");

  // Check to see that all of your callers
  // have the rights to read that file.

  PolicyEngine.checkPermission(sreq);
  ...

For more information about checking file I/O permissions, see the PolicyEngine class and the FileIOPermission class.

© 1999 Microsoft Corporation. All rights reserved. Terms of use.