-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMain.java
More file actions
23 lines (20 loc) · 831 Bytes
/
Copy pathMain.java
File metadata and controls
23 lines (20 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package security;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.sql.SQLException;
public class Main {
public static void main(String[] args) throws SQLException, InterruptedException, UnsupportedEncodingException, MalformedURLException, ClassNotFoundException {
System.setProperty("java.security.policy", "src/MyApp.policy");
System.setSecurityManager(new SecurityManager());
printString("hello");
printString("php");
}
static void printString(String s) {
MyPermission myPermission = new MyPermission("use");
SecurityManager securityManager = System.getSecurityManager();
if (securityManager != null) {
securityManager.checkPermission(myPermission);
}
System.out.println(s);
}
}