mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8338411: Implement JEP 486: Permanently Disable the Security Manager
Co-authored-by: Sean Mullan <mullan@openjdk.org> Co-authored-by: Alan Bateman <alanb@openjdk.org> Co-authored-by: Weijun Wang <weijun@openjdk.org> Co-authored-by: Aleksei Efimov <aefimov@openjdk.org> Co-authored-by: Brian Burkhalter <bpb@openjdk.org> Co-authored-by: Daniel Fuchs <dfuchs@openjdk.org> Co-authored-by: Harshitha Onkar <honkar@openjdk.org> Co-authored-by: Joe Wang <joehw@openjdk.org> Co-authored-by: Jorn Vernee <jvernee@openjdk.org> Co-authored-by: Justin Lu <jlu@openjdk.org> Co-authored-by: Kevin Walls <kevinw@openjdk.org> Co-authored-by: Lance Andersen <lancea@openjdk.org> Co-authored-by: Naoto Sato <naoto@openjdk.org> Co-authored-by: Roger Riggs <rriggs@openjdk.org> Co-authored-by: Brent Christian <bchristi@openjdk.org> Co-authored-by: Stuart Marks <smarks@openjdk.org> Co-authored-by: Ian Graves <igraves@openjdk.org> Co-authored-by: Phil Race <prr@openjdk.org> Co-authored-by: Erik Gahlin <egahlin@openjdk.org> Co-authored-by: Jaikiran Pai <jpai@openjdk.org> Reviewed-by: kevinw, aivanov, rriggs, lancea, coffeys, dfuchs, ihse, erikj, cjplummer, coleenp, naoto, mchung, prr, weijun, joehw, azvegint, psadhukhan, bchristi, sundar, attila
This commit is contained in:
parent
c12b386d19
commit
db85090553
1885 changed files with 5528 additions and 65650 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -118,16 +118,7 @@ public abstract class FileSystemProvider {
|
|||
private static volatile List<FileSystemProvider> installedProviders;
|
||||
|
||||
// used to avoid recursive loading of installed providers
|
||||
private static boolean loadingProviders = false;
|
||||
|
||||
private static Void checkPermission() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPermission(new RuntimePermission("fileSystemProvider"));
|
||||
return null;
|
||||
}
|
||||
private FileSystemProvider(Void ignore) { }
|
||||
private static boolean loadingProviders;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of this class.
|
||||
|
@ -136,13 +127,8 @@ public abstract class FileSystemProvider {
|
|||
* with the default provider but care needs to be taken to avoid circular
|
||||
* loading of other installed providers. If circular loading of installed
|
||||
* providers is detected then an unspecified error is thrown.
|
||||
*
|
||||
* @throws SecurityException
|
||||
* If a security manager has been installed and it denies
|
||||
* {@link RuntimePermission}{@code ("fileSystemProvider")}
|
||||
*/
|
||||
protected FileSystemProvider() {
|
||||
this(checkPermission());
|
||||
}
|
||||
|
||||
// loads all installed providers
|
||||
|
@ -256,9 +242,6 @@ public abstract class FileSystemProvider {
|
|||
* by the provider, or a property value is invalid
|
||||
* @throws IOException
|
||||
* An I/O error occurs creating the file system
|
||||
* @throws SecurityException
|
||||
* If a security manager is installed and it denies an unspecified
|
||||
* permission required by the file system provider implementation
|
||||
* @throws FileSystemAlreadyExistsException
|
||||
* If the file system has already been created
|
||||
*/
|
||||
|
@ -286,11 +269,6 @@ public abstract class FileSystemProvider {
|
|||
* closed (and before a new instance is created by the {@link #newFileSystem
|
||||
* newFileSystem} method).
|
||||
*
|
||||
* <p> If a security manager is installed then a provider implementation
|
||||
* may require to check a permission before returning a reference to an
|
||||
* existing file system. In the case of the {@link FileSystems#getDefault
|
||||
* default} file system, no permission check is required.
|
||||
*
|
||||
* @param uri
|
||||
* URI reference
|
||||
*
|
||||
|
@ -300,9 +278,6 @@ public abstract class FileSystemProvider {
|
|||
* If the pre-conditions for the {@code uri} parameter aren't met
|
||||
* @throws FileSystemNotFoundException
|
||||
* If the file system does not exist
|
||||
* @throws SecurityException
|
||||
* If a security manager is installed and it denies an unspecified
|
||||
* permission.
|
||||
*/
|
||||
public abstract FileSystem getFileSystem(URI uri);
|
||||
|
||||
|
@ -317,11 +292,6 @@ public abstract class FileSystemProvider {
|
|||
* fragment components. The resulting {@code Path} is associated with the
|
||||
* default {@link FileSystems#getDefault default} {@code FileSystem}.
|
||||
*
|
||||
* <p> If a security manager is installed then a provider implementation
|
||||
* may require to check a permission. In the case of the {@link
|
||||
* FileSystems#getDefault default} file system, no permission check is
|
||||
* required.
|
||||
*
|
||||
* @param uri
|
||||
* The URI to convert
|
||||
*
|
||||
|
@ -333,9 +303,6 @@ public abstract class FileSystemProvider {
|
|||
* @throws FileSystemNotFoundException
|
||||
* The file system, identified by the URI, does not exist and
|
||||
* cannot be created automatically
|
||||
* @throws SecurityException
|
||||
* If a security manager is installed and it denies an unspecified
|
||||
* permission.
|
||||
*/
|
||||
public abstract Path getPath(URI uri);
|
||||
|
||||
|
@ -370,9 +337,6 @@ public abstract class FileSystemProvider {
|
|||
* by the provider, or a property value is invalid
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* If a security manager is installed and it denies an unspecified
|
||||
* permission.
|
||||
*/
|
||||
public FileSystem newFileSystem(Path path, Map<String,?> env)
|
||||
throws IOException
|
||||
|
@ -403,10 +367,6 @@ public abstract class FileSystemProvider {
|
|||
* if an unsupported option is specified
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @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 file.
|
||||
*/
|
||||
public InputStream newInputStream(Path path, OpenOption... options)
|
||||
throws IOException
|
||||
|
@ -455,13 +415,6 @@ public abstract class FileSystemProvider {
|
|||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws SecurityException
|
||||
* 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 the file. The {@link
|
||||
* SecurityManager#checkDelete(String) checkDelete} method is
|
||||
* invoked to check delete access if the file is opened with the
|
||||
* {@code DELETE_ON_CLOSE} option.
|
||||
*/
|
||||
public OutputStream newOutputStream(Path path, OpenOption... options)
|
||||
throws IOException
|
||||
|
@ -518,12 +471,6 @@ public abstract class FileSystemProvider {
|
|||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default file system, the {@link
|
||||
* SecurityManager#checkRead(String)} method is invoked to check
|
||||
* read access if the file is opened for reading. The {@link
|
||||
* SecurityManager#checkWrite(String)} method is invoked to check
|
||||
* write access if the file is opened for writing
|
||||
*/
|
||||
public FileChannel newFileChannel(Path path,
|
||||
Set<? extends OpenOption> options,
|
||||
|
@ -571,12 +518,6 @@ public abstract class FileSystemProvider {
|
|||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default file system, the {@link
|
||||
* SecurityManager#checkRead(String)} method is invoked to check
|
||||
* read access if the file is opened for reading. The {@link
|
||||
* SecurityManager#checkWrite(String)} method is invoked to check
|
||||
* write access if the file is opened for writing
|
||||
*/
|
||||
public AsynchronousFileChannel newAsynchronousFileChannel(Path path,
|
||||
Set<? extends OpenOption> options,
|
||||
|
@ -614,16 +555,6 @@ public abstract class FileSystemProvider {
|
|||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @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 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. The {@link
|
||||
* SecurityManager#checkDelete(String) checkDelete} method is
|
||||
* invoked to check delete access if the file is opened with the
|
||||
* {@code DELETE_ON_CLOSE} option.
|
||||
*/
|
||||
public abstract SeekableByteChannel newByteChannel(Path path,
|
||||
Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException;
|
||||
|
@ -647,10 +578,6 @@ public abstract class FileSystemProvider {
|
|||
* a directory <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @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 DirectoryStream<Path> newDirectoryStream(Path dir,
|
||||
DirectoryStream.Filter<? super Path> filter) throws IOException;
|
||||
|
@ -673,10 +600,6 @@ public abstract class FileSystemProvider {
|
|||
* that name already exists <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs or the parent directory does not exist
|
||||
* @throws SecurityException
|
||||
* 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 the new directory.
|
||||
*/
|
||||
public abstract void createDirectory(Path dir, FileAttribute<?>... attrs)
|
||||
throws IOException;
|
||||
|
@ -705,11 +628,6 @@ public abstract class FileSystemProvider {
|
|||
* exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager
|
||||
* is installed, it denies {@link LinkPermission}{@code ("symbolic")}
|
||||
* or its {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method denies write access to the path of the symbolic link.
|
||||
*/
|
||||
public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
|
@ -738,12 +656,6 @@ public abstract class FileSystemProvider {
|
|||
* that name already exists <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager
|
||||
* is installed, it denies {@link LinkPermission}{@code ("hard")}
|
||||
* or its {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method denies write access to either the link or the
|
||||
* existing file.
|
||||
*/
|
||||
public void createLink(Path link, Path existing) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -764,10 +676,6 @@ public abstract class FileSystemProvider {
|
|||
* exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkDelete(String)} method
|
||||
* is invoked to check delete access to the file
|
||||
*/
|
||||
public abstract void delete(Path path) throws IOException;
|
||||
|
||||
|
@ -792,10 +700,6 @@ public abstract class FileSystemProvider {
|
|||
* exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkDelete(String)} method
|
||||
* is invoked to check delete access to the file
|
||||
*/
|
||||
public boolean deleteIfExists(Path path) throws IOException {
|
||||
try {
|
||||
|
@ -825,10 +729,6 @@ public abstract class FileSystemProvider {
|
|||
* is not a symbolic link <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager
|
||||
* is installed, it checks that {@code FilePermission} has been
|
||||
* granted with the "{@code readlink}" action to read the link.
|
||||
*/
|
||||
public Path readSymbolicLink(Path link) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -859,14 +759,6 @@ public abstract class FileSystemProvider {
|
|||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @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 source file, the
|
||||
* {@link SecurityManager#checkWrite(String) checkWrite} is invoked
|
||||
* to check write access to the target file. If a symbolic link is
|
||||
* copied the security manager is invoked to check {@link
|
||||
* LinkPermission}{@code ("symbolic")}.
|
||||
*/
|
||||
public abstract void copy(Path source, Path target, CopyOption... options)
|
||||
throws IOException;
|
||||
|
@ -898,11 +790,6 @@ public abstract class FileSystemProvider {
|
|||
* the file cannot be moved as an atomic file system operation.
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* 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(Path source, Path target, CopyOption... options)
|
||||
throws IOException;
|
||||
|
@ -920,10 +807,6 @@ public abstract class FileSystemProvider {
|
|||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @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 both files.
|
||||
*/
|
||||
public abstract boolean isSameFile(Path path, Path path2)
|
||||
throws IOException;
|
||||
|
@ -942,10 +825,6 @@ public abstract class FileSystemProvider {
|
|||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @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 file.
|
||||
*/
|
||||
public abstract boolean isHidden(Path path) throws IOException;
|
||||
|
||||
|
@ -961,12 +840,6 @@ public abstract class FileSystemProvider {
|
|||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @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 file, and in
|
||||
* addition it checks
|
||||
* {@link RuntimePermission}{@code ("getFileStoreAttributes")}
|
||||
*/
|
||||
public abstract FileStore getFileStore(Path path) throws IOException;
|
||||
|
||||
|
@ -1039,14 +912,6 @@ public abstract class FileSystemProvider {
|
|||
* privileges or other reasons. <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* is invoked when checking read access to the file or only the
|
||||
* existence of the file, the {@link SecurityManager#checkWrite(String)
|
||||
* checkWrite} is invoked when checking write access to the file,
|
||||
* and {@link SecurityManager#checkExec(String) checkExec} is invoked
|
||||
* when checking execute access.
|
||||
*/
|
||||
public abstract void checkAccess(Path path, AccessMode... modes)
|
||||
throws IOException;
|
||||
|
@ -1092,10 +957,6 @@ public abstract class FileSystemProvider {
|
|||
* if an attributes of the given type are not supported
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, a security manager is
|
||||
* installed, its {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to the file
|
||||
*/
|
||||
public abstract <A extends BasicFileAttributes> A
|
||||
readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException;
|
||||
|
@ -1122,12 +983,6 @@ public abstract class FileSystemProvider {
|
|||
* specified
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, its {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method denies read access to the file. If this method is invoked
|
||||
* to read security sensitive attributes then the security manager
|
||||
* may be invoked to check for additional permissions.
|
||||
*/
|
||||
public abstract Map<String,Object> readAttributes(Path path, String attributes,
|
||||
LinkOption... options)
|
||||
|
@ -1158,12 +1013,6 @@ public abstract class FileSystemProvider {
|
|||
* type
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, its {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method denies write access to the file. If this method is invoked
|
||||
* to set security sensitive attributes then the security manager
|
||||
* may be invoked to check for additional permissions.
|
||||
*/
|
||||
public abstract void setAttribute(Path path, String attribute,
|
||||
Object value, LinkOption... options)
|
||||
|
@ -1189,11 +1038,6 @@ public abstract class FileSystemProvider {
|
|||
* @return {@code true} if the file exists; {@code false} if the file does
|
||||
* not exist or its existence cannot be determined.
|
||||
*
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, the {@link
|
||||
* SecurityManager#checkRead(String)} is invoked to check
|
||||
* read access to the file.
|
||||
*
|
||||
* @since 20
|
||||
*/
|
||||
public boolean exists(Path path, LinkOption... options) {
|
||||
|
@ -1252,12 +1096,6 @@ public abstract class FileSystemProvider {
|
|||
* if an attributes of the given type are not supported
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, a security manager is
|
||||
* installed, its {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to the file. If this
|
||||
* method is invoked to read security sensitive attributes then the
|
||||
* security manager may be invoked to check for additional permissions.
|
||||
*
|
||||
* @since 20
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue