author | egahlin |
Wed, 18 Sep 2019 08:00:36 +0200 | |
branch | JEP-349-branch |
changeset 58200 | 2d147d680311 |
parent 58112 | e7754025004b |
permissions | -rw-r--r-- |
58112 | 1 |
/* |
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
24 |
package jdk.jfr.internal.consumer; |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
25 |
|
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
26 |
import java.io.File; |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
27 |
import java.io.IOException; |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
28 |
import java.io.RandomAccessFile; |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
29 |
import java.nio.file.DirectoryStream; |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
30 |
import java.nio.file.Files; |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
31 |
import java.nio.file.Path; |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
32 |
|
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
33 |
// Protected by modular boundaries. |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
34 |
public abstract class FileAccess { |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
35 |
public final static FileAccess UNPRIVILIGED = new UnPriviliged(); |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
36 |
|
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
37 |
public abstract RandomAccessFile openRAF(File f, String mode) throws IOException; |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
38 |
|
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
39 |
public abstract DirectoryStream<Path> newDirectoryStream(Path repository) throws IOException; |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
40 |
|
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
41 |
public abstract String getAbsolutePath(File f) throws IOException; |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
42 |
|
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
43 |
public abstract long length(File f) throws IOException; |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
44 |
|
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
45 |
public abstract long fileSize(Path p) throws IOException; |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
46 |
|
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
47 |
private static class UnPriviliged extends FileAccess { |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
48 |
@Override |
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
49 |
public RandomAccessFile openRAF(File f, String mode) throws IOException { |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
50 |
return new RandomAccessFile(f, mode); |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
51 |
} |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
52 |
|
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
53 |
@Override |
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
54 |
public DirectoryStream<Path> newDirectoryStream(Path dir) throws IOException { |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
55 |
return Files.newDirectoryStream(dir); |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
56 |
} |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
57 |
|
58200 | 58 |
@Override |
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
59 |
public String getAbsolutePath(File f) throws IOException { |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
60 |
return f.getAbsolutePath(); |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
61 |
} |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
62 |
|
58200 | 63 |
@Override |
57717
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
64 |
public long length(File f) throws IOException { |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
65 |
return f.length(); |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
66 |
} |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
67 |
|
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
68 |
@Override |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
69 |
public long fileSize(Path p) throws IOException { |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
70 |
return Files.size(p); |
4ce66d271065
Security handling, but two tests fails with driver
egahlin
parents:
57690
diff
changeset
|
71 |
} |
57690
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
72 |
} |
9316d02dd4a5
Add EventStream::setEndTime(...) and a first stab at priviliged access to local repository
egahlin
parents:
diff
changeset
|
73 |
} |