author | lana |
Thu, 26 Dec 2013 12:04:16 -0800 | |
changeset 23010 | 6dadb192ad81 |
parent 18807 | 7d65f90d7348 |
permissions | -rw-r--r-- |
18807
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
1 |
/* |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
4 |
* |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
8 |
* |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
13 |
* accompanied this code). |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
14 |
* |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
18 |
* |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
21 |
* questions. |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
22 |
*/ |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
23 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
24 |
/* @test |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
25 |
* @bug 8017212 |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
26 |
* @summary Examine methods in File.java that access the file system do the |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
27 |
* right permission check when a security manager exists. |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
28 |
* @author Dan Xu |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
29 |
*/ |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
30 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
31 |
import java.io.File; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
32 |
import java.io.FilenameFilter; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
33 |
import java.io.FileFilter; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
34 |
import java.io.IOException; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
35 |
import java.security.Permission; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
36 |
import java.util.ArrayList; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
37 |
import java.util.EnumMap; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
38 |
import java.util.EnumSet; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
39 |
import java.util.HashSet; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
40 |
import java.util.List; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
41 |
import java.util.Map; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
42 |
import java.util.Set; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
43 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
44 |
public class CheckPermission { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
45 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
46 |
private static final String CHECK_PERMISSION_TEST = "CheckPermissionTest"; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
47 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
48 |
public enum FileOperation { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
49 |
READ, WRITE, DELETE, EXEC |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
50 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
51 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
52 |
static class Checks { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
53 |
private List<Permission> permissionsChecked = new ArrayList<>(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
54 |
private Set<String> propertiesChecked = new HashSet<>(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
55 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
56 |
private Map<FileOperation, List<String>> fileOperationChecked = |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
57 |
new EnumMap<>(FileOperation.class); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
58 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
59 |
List<Permission> permissionsChecked() { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
60 |
return permissionsChecked; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
61 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
62 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
63 |
Set<String> propertiesChecked() { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
64 |
return propertiesChecked; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
65 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
66 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
67 |
List<String> fileOperationChecked(FileOperation op) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
68 |
return fileOperationChecked.get(op); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
69 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
70 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
71 |
void addFileOperation(FileOperation op, String file) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
72 |
List<String> opList = fileOperationChecked.get(op); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
73 |
if (opList == null) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
74 |
opList = new ArrayList<>(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
75 |
fileOperationChecked.put(op, opList); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
76 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
77 |
opList.add(file); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
78 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
79 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
80 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
81 |
static ThreadLocal<Checks> myChecks = new ThreadLocal<>(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
82 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
83 |
static void prepare() { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
84 |
myChecks.set(new Checks()); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
85 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
86 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
87 |
static class LoggingSecurityManager extends SecurityManager { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
88 |
static void install() { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
89 |
System.setSecurityManager(new LoggingSecurityManager()); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
90 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
91 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
92 |
private void checkFileOperation(FileOperation op, String file) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
93 |
Checks checks = myChecks.get(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
94 |
if (checks != null) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
95 |
checks.addFileOperation(op, file); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
96 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
97 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
98 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
99 |
public void checkRead(String file) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
100 |
checkFileOperation(FileOperation.READ, file); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
101 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
102 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
103 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
104 |
public void checkWrite(String file) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
105 |
checkFileOperation(FileOperation.WRITE, file); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
106 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
107 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
108 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
109 |
public void checkDelete(String file) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
110 |
checkFileOperation(FileOperation.DELETE, file); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
111 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
112 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
113 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
114 |
public void checkExec(String file) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
115 |
checkFileOperation(FileOperation.EXEC, file); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
116 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
117 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
118 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
119 |
public void checkPermission(Permission perm) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
120 |
Checks checks = myChecks.get(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
121 |
if (checks != null) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
122 |
checks.permissionsChecked().add(perm); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
123 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
124 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
125 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
126 |
public void checkPropertyAccess(String key) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
127 |
Checks checks = myChecks.get(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
128 |
if (checks != null) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
129 |
checks.propertiesChecked().add(key); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
130 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
131 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
132 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
133 |
static void assertCheckPermission(Class<? extends Permission> type, |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
134 |
String name) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
135 |
{ |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
136 |
for (Permission perm : myChecks.get().permissionsChecked()) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
137 |
if (type.isInstance(perm) && perm.getName().equals(name)) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
138 |
return; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
139 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
140 |
throw new RuntimeException(type.getName() + "(\"" + name |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
141 |
+ "\") not checked"); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
142 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
143 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
144 |
static void assertCheckPropertyAccess(String key) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
145 |
if (!myChecks.get().propertiesChecked().contains(key)) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
146 |
throw new RuntimeException("Property " + key + " not checked"); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
147 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
148 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
149 |
static void assertChecked(File file, List<String> list) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
150 |
if (list != null && !list.isEmpty()) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
151 |
for (String path : list) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
152 |
if (path.equals(file.getPath())) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
153 |
return; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
154 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
155 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
156 |
throw new RuntimeException("Access not checked"); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
157 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
158 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
159 |
static void assertNotChecked(File file, List<String> list) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
160 |
if (list != null && !list.isEmpty()) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
161 |
for (String path : list) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
162 |
if (path.equals(file.getPath())) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
163 |
throw new RuntimeException("Access checked"); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
164 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
165 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
166 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
167 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
168 |
static void assertCheckOperation(File file, Set<FileOperation> ops) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
169 |
for (FileOperation op : ops) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
170 |
assertChecked(file, myChecks.get().fileOperationChecked(op)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
171 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
172 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
173 |
static void assertNotCheckOperation(File file, Set<FileOperation> ops) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
174 |
for (FileOperation op : ops) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
175 |
assertNotChecked(file, myChecks.get().fileOperationChecked(op)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
176 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
177 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
178 |
static void assertOnlyCheckOperation(File file, |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
179 |
EnumSet<FileOperation> ops) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
180 |
{ |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
181 |
assertCheckOperation(file, ops); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
182 |
assertNotCheckOperation(file, EnumSet.complementOf(ops)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
183 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
184 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
185 |
static File testFile, another; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
186 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
187 |
static void setup() { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
188 |
testFile = new File(CHECK_PERMISSION_TEST + System.currentTimeMillis()); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
189 |
if (testFile.exists()) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
190 |
testFile.delete(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
191 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
192 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
193 |
another = new File(CHECK_PERMISSION_TEST + "Another" |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
194 |
+ System.currentTimeMillis()); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
195 |
if (another.exists()) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
196 |
another.delete(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
197 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
198 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
199 |
LoggingSecurityManager.install(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
200 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
201 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
202 |
public static void main(String[] args) throws IOException { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
203 |
setup(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
204 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
205 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
206 |
testFile.canRead(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
207 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
208 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
209 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
210 |
testFile.canWrite(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
211 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
212 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
213 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
214 |
testFile.exists(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
215 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
216 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
217 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
218 |
testFile.isDirectory(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
219 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
220 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
221 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
222 |
testFile.isFile(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
223 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
224 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
225 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
226 |
testFile.isHidden(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
227 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
228 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
229 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
230 |
testFile.lastModified(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
231 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
232 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
233 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
234 |
testFile.length(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
235 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
236 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
237 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
238 |
testFile.createNewFile(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
239 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
240 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
241 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
242 |
testFile.list(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
243 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
244 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
245 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
246 |
testFile.list(new FilenameFilter() { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
247 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
248 |
public boolean accept(File dir, String name) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
249 |
return false; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
250 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
251 |
}); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
252 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
253 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
254 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
255 |
testFile.listFiles(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
256 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
257 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
258 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
259 |
testFile.listFiles(new FilenameFilter() { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
260 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
261 |
public boolean accept(File dir, String name) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
262 |
return false; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
263 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
264 |
}); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
265 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
266 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
267 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
268 |
testFile.listFiles(new FileFilter() { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
269 |
@Override |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
270 |
public boolean accept(File file) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
271 |
return false; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
272 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
273 |
}); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
274 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
275 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
276 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
277 |
testFile.mkdir(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
278 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
279 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
280 |
if (testFile.exists()) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
281 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
282 |
testFile.mkdirs(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
283 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
284 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
285 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
286 |
if (!another.exists()) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
287 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
288 |
another.mkdirs(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
289 |
assertOnlyCheckOperation(another, |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
290 |
EnumSet.of(FileOperation.READ, FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
291 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
292 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
293 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
294 |
another.delete(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
295 |
assertOnlyCheckOperation(another, EnumSet.of(FileOperation.DELETE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
296 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
297 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
298 |
boolean renRst = testFile.renameTo(another); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
299 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
300 |
assertOnlyCheckOperation(another, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
301 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
302 |
if (renRst) { |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
303 |
if (testFile.exists()) |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
304 |
throw new RuntimeException(testFile + " is already renamed to " |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
305 |
+ another); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
306 |
testFile = another; |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
307 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
308 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
309 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
310 |
testFile.setLastModified(0); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
311 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
312 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
313 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
314 |
testFile.setReadOnly(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
315 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
316 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
317 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
318 |
testFile.setWritable(true, true); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
319 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
320 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
321 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
322 |
testFile.setWritable(true); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
323 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
324 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
325 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
326 |
testFile.setReadable(true, true); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
327 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
328 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
329 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
330 |
testFile.setReadable(true); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
331 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
332 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
333 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
334 |
testFile.setExecutable(true, true); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
335 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
336 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
337 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
338 |
testFile.setExecutable(true); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
339 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
340 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
341 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
342 |
testFile.canExecute(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
343 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.EXEC)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
344 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
345 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
346 |
testFile.getTotalSpace(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
347 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
348 |
assertCheckPermission(RuntimePermission.class, |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
349 |
"getFileSystemAttributes"); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
350 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
351 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
352 |
testFile.getFreeSpace(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
353 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
354 |
assertCheckPermission(RuntimePermission.class, |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
355 |
"getFileSystemAttributes"); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
356 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
357 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
358 |
testFile.getUsableSpace(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
359 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
360 |
assertCheckPermission(RuntimePermission.class, |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
361 |
"getFileSystemAttributes"); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
362 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
363 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
364 |
File tmpFile = File.createTempFile(CHECK_PERMISSION_TEST, null); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
365 |
assertOnlyCheckOperation(tmpFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
366 |
tmpFile.delete(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
367 |
assertCheckOperation(tmpFile, EnumSet.of(FileOperation.DELETE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
368 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
369 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
370 |
tmpFile = File.createTempFile(CHECK_PERMISSION_TEST, null, null); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
371 |
assertOnlyCheckOperation(tmpFile, EnumSet.of(FileOperation.WRITE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
372 |
tmpFile.delete(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
373 |
assertCheckOperation(tmpFile, EnumSet.of(FileOperation.DELETE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
374 |
|
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
375 |
prepare(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
376 |
testFile.deleteOnExit(); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
377 |
assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.DELETE)); |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
378 |
} |
7d65f90d7348
8017212: File.createTempFile requires unnecessary "read" permission
dxu
parents:
diff
changeset
|
379 |
} |