Java examples for Security:Permission
permitted security auth Subject
//package com.java2s; import java.security.Permission; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javax.security.auth.Subject; public class Main { static SecurityManager sm; static public boolean permitted(Subject subj, final Permission p) throws PrivilegedActionException { if (p == null) { return false; }/*from w ww. ja va2 s. c om*/ if (subj == null) { subj = new Subject(); } if (sm == null) sm = new SecurityManager(); Subject.doAsPrivileged(subj, new PrivilegedExceptionAction<Object>() { public Object run() { sm.checkPermission(p); return null; } }, null); return true; } }