Java.util.PropertyPermission.implies() の使い方

Javaコード
package Permission;

import java.util.PropertyPermission;

public class Impliesdemo {
private static PropertyPermission permission;
public static void main(String[] args) {
// Create property permission object
permission = new PropertyPermission(“java.*", “read,write");
// Check permissions
checkFileReadPermission(“java.changfa");
checkFileWritePermission(“java.changfa");
}

private static void checkFileReadPermission(String path) {
// Check permission on read action
if(permission.implies(new PropertyPermission(path, “read"))) {
System.out.println(“Has permissions on “+path+" 読込み権限");
}
}

private static void checkFileWritePermission(String path) {
// Check permission on read action
if(permission.implies(new PropertyPermission(path, “write"))) {
System.out.println(“Has permissions on “+path+" 書込み権限");
}
}

}

実行結果
Has permissions on java.changfa 読込み権限
Has permissions on java.changfa 書込み権限

Java

Posted by arkgame