28 lines
1 KiB
XML
28 lines
1 KiB
XML
<?xml version='1.0' encoding='utf-8' ?>
|
|
<!DOCTYPE programlisting PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
]>
|
|
<!-- Automatically generated file. Do not edit. -->
|
|
<programlisting language="Java">
|
|
Permissions permissions = new Permissions();
|
|
ProtectionDomain protectionDomain =
|
|
new ProtectionDomain(null, permissions);
|
|
AccessControlContext context = new AccessControlContext(
|
|
new ProtectionDomain[] { protectionDomain });
|
|
|
|
// This is expected to succeed.
|
|
try (FileInputStream in = new FileInputStream(path)) {
|
|
System.out.format("FileInputStream: %s%n", in);
|
|
}
|
|
|
|
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
|
|
@Override
|
|
public Void run() throws Exception {
|
|
// This code runs with reduced privileges and is
|
|
// expected to fail.
|
|
try (FileInputStream in = new FileInputStream(path)) {
|
|
System.out.format("FileInputStream: %s%n", in);
|
|
}
|
|
return null;
|
|
}
|
|
}, context);
|
|
</programlisting>
|