src/share/classes/java/nio/file/SecureDirectoryStream.java

Print this page

        

*** 41,51 **** * by an attacker while the directory is open. A {@code SecureDirectoryStream} * may also be used as a virtual <em>working directory</em>. * * <p> A {@code SecureDirectoryStream} requires corresponding support from the * underlying operating system. Where an implementation supports this features ! * then the {@code DirectoryStream} returned by the {@link Path#newDirectoryStream * newDirectoryStream} method will be a {@code SecureDirectoryStream} and must * be cast to that type in order to invoke the methods defined by this interface. * * <p> In the case of the default {@link java.nio.file.spi.FileSystemProvider * provider}, and a security manager is set, then the permission checks are --- 41,51 ---- * by an attacker while the directory is open. A {@code SecureDirectoryStream} * may also be used as a virtual <em>working directory</em>. * * <p> A {@code SecureDirectoryStream} requires corresponding support from the * underlying operating system. Where an implementation supports this features ! * then the {@code DirectoryStream} returned by the {@link Files#newDirectoryStream * newDirectoryStream} method will be a {@code SecureDirectoryStream} and must * be cast to that type in order to invoke the methods defined by this interface. * * <p> In the case of the default {@link java.nio.file.spi.FileSystemProvider * provider}, and a security manager is set, then the permission checks are
*** 54,77 **** * directory is moved since it was opened). * * @since 1.7 */ ! public abstract class SecureDirectoryStream<T> ! implements DirectoryStream<T> { /** - * Initialize a new instance of this class. - */ - protected SecureDirectoryStream() { } - - /** * Opens the directory identified by the given path, returning a {@code * SecureDirectoryStream} to iterate over the entries in the directory. * * <p> This method works in exactly the manner specified by the {@link ! * Path#newDirectoryStream() newDirectoryStream} method for the case that * the {@code path} parameter is an {@link Path#isAbsolute absolute} path. * When the parameter is a relative path then the directory to open is * relative to this open directory. The {@link * LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} option may be used to * ensure that this method fails if the file is a symbolic link. --- 54,72 ---- * directory is moved since it was opened). * * @since 1.7 */ ! public interface SecureDirectoryStream<T> ! extends DirectoryStream<T> { /** * Opens the directory identified by the given path, returning a {@code * SecureDirectoryStream} to iterate over the entries in the directory. * * <p> This method works in exactly the manner specified by the {@link ! * Files#newDirectoryStream(Path) newDirectoryStream} method for the case that * the {@code path} parameter is an {@link Path#isAbsolute absolute} path. * When the parameter is a relative path then the directory to open is * relative to this open directory. The {@link * LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} option may be used to * ensure that this method fails if the file is a symbolic link.
*** 97,120 **** * @throws SecurityException * In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkRead(String) checkRead} * method is invoked to check read access to the directory. */ ! public abstract SecureDirectoryStream<T> newDirectoryStream(T path, ! LinkOption... options) throws IOException; /** * Opens or creates a file in this directory, returning a seekable byte * channel to access the file. * * <p> This method works in exactly the manner specified by the {@link ! * Path#newByteChannel Path.newByteChannel} method for the * case that the {@code path} parameter is an {@link Path#isAbsolute absolute} * path. When the parameter is a relative path then the file to open or * create is relative to this open directory. In addition to the options ! * defined by the {@code Path.newByteChannel} method, the {@link * LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} option may be used to * ensure that this method fails if the file is a symbolic link. * * <p> The channel, once created, is not dependent upon the directory stream * used to create it. Closing this directory stream has no effect upon the --- 92,114 ---- * @throws SecurityException * In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkRead(String) checkRead} * method is invoked to check read access to the directory. */ ! SecureDirectoryStream<T> newDirectoryStream(T path, LinkOption... options) throws IOException; /** * Opens or creates a file in this directory, returning a seekable byte * channel to access the file. * * <p> This method works in exactly the manner specified by the {@link ! * Files#newByteChannel Files.newByteChannel} method for the * case that the {@code path} parameter is an {@link Path#isAbsolute absolute} * path. When the parameter is a relative path then the file to open or * create is relative to this open directory. In addition to the options ! * defined by the {@code Files.newByteChannel} method, the {@link * LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} option may be used to * ensure that this method fails if the file is a symbolic link. * * <p> The channel, once created, is not dependent upon the directory stream * used to create it. Closing this directory stream has no effect upon the
*** 147,165 **** * method is invoked to check read access to the path if the file * is opened for reading. The {@link SecurityManager#checkWrite(String) * checkWrite} method is invoked to check write access to the path * if the file is opened for writing. */ ! public abstract SeekableByteChannel newByteChannel(T path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException; /** * Deletes a file. * ! * <p> Unlike the {@link Path#delete delete()} method, this method does * not first examine the file to determine if the file is a directory. * Whether a directory is deleted by this method is system dependent and * therefore not specified. If the file is a symbolic link, then the link * itself, not the final target of the link, is deleted. When the * parameter is a relative path then the file to delete is relative to --- 141,159 ---- * method is invoked to check read access to the path if the file * is opened for reading. The {@link SecurityManager#checkWrite(String) * checkWrite} method is invoked to check write access to the path * if the file is opened for writing. */ ! SeekableByteChannel newByteChannel(T path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException; /** * Deletes a file. * ! * <p> Unlike the {@link Files#delete delete()} method, this method does * not first examine the file to determine if the file is a directory. * Whether a directory is deleted by this method is system dependent and * therefore not specified. If the file is a symbolic link, then the link * itself, not the final target of the link, is deleted. When the * parameter is a relative path then the file to delete is relative to
*** 177,192 **** * @throws SecurityException * In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkDelete(String) checkDelete} * method is invoked to check delete access to the file */ ! public abstract void deleteFile(T path) throws IOException; /** * Deletes a directory. * ! * <p> Unlike the {@link Path#delete delete()} method, this method * does not first examine the file to determine if the file is a directory. * Whether non-directories are deleted by this method is system dependent and * therefore not specified. When the parameter is a relative path then the * directory to delete is relative to this open directory. * --- 171,186 ---- * @throws SecurityException * In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkDelete(String) checkDelete} * method is invoked to check delete access to the file */ ! void deleteFile(T path) throws IOException; /** * Deletes a directory. * ! * <p> Unlike the {@link Files#delete delete()} method, this method * does not first examine the file to determine if the file is a directory. * Whether non-directories are deleted by this method is system dependent and * therefore not specified. When the parameter is a relative path then the * directory to delete is relative to this open directory. *
*** 205,220 **** * @throws SecurityException * In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkDelete(String) checkDelete} * method is invoked to check delete access to the directory */ ! public abstract void deleteDirectory(T path) throws IOException; /** * Move a file from this directory to another directory. * ! * <p> This method works in a similar manner to {@link Path#moveTo moveTo} * method when the {@link StandardCopyOption#ATOMIC_MOVE ATOMIC_MOVE} option * is specified. That is, this method moves a file as an atomic file system * operation. If the {@code srcpath} parameter is an {@link Path#isAbsolute * absolute} path then it locates the source file. If the parameter is a * relative path then it is located relative to this open directory. If --- 199,214 ---- * @throws SecurityException * In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkDelete(String) checkDelete} * method is invoked to check delete access to the directory */ ! void deleteDirectory(T path) throws IOException; /** * Move a file from this directory to another directory. * ! * <p> This method works in a similar manner to {@link Files#move move} * method when the {@link StandardCopyOption#ATOMIC_MOVE ATOMIC_MOVE} option * is specified. That is, this method moves a file as an atomic file system * operation. If the {@code srcpath} parameter is an {@link Path#isAbsolute * absolute} path then it locates the source file. If the parameter is a * relative path then it is located relative to this open directory. If
*** 245,255 **** * In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkWrite(String) checkWrite} * method is invoked to check write access to both the source and * target file. */ ! public abstract void move(T srcpath, SecureDirectoryStream<T> targetdir, T targetpath) throws IOException; /** * Returns a new file attribute view to access the file attributes of this * directory. --- 239,249 ---- * In the case of the default provider, and a security manager is * installed, the {@link SecurityManager#checkWrite(String) checkWrite} * method is invoked to check write access to both the source and * target file. */ ! void move(T srcpath, SecureDirectoryStream<T> targetdir, T targetpath) throws IOException; /** * Returns a new file attribute view to access the file attributes of this * directory.
*** 271,281 **** * * @return a new file attribute view of the specified type bound to * this directory stream, or {@code null} if the attribute view * type is not available */ ! public abstract <V extends FileAttributeView> V getFileAttributeView(Class<V> type); /** * Returns a new file attribute view to access the file attributes of a file * in this directory. * --- 265,275 ---- * * @return a new file attribute view of the specified type bound to * this directory stream, or {@code null} if the attribute view * type is not available */ ! <V extends FileAttributeView> V getFileAttributeView(Class<V> type); /** * Returns a new file attribute view to access the file attributes of a file * in this directory. *
*** 304,312 **** * @return a new file attribute view of the specified type bound to a * this directory stream, or {@code null} if the attribute view * type is not available * */ ! public abstract <V extends FileAttributeView> V getFileAttributeView(T path, Class<V> type, LinkOption... options); } --- 298,306 ---- * @return a new file attribute view of the specified type bound to a * this directory stream, or {@code null} if the attribute view * type is not available * */ ! <V extends FileAttributeView> V getFileAttributeView(T path, Class<V> type, LinkOption... options); }