一、前言
基于mozilla的js.jar包中org.mozilla.javascript.SecurityUtilities安全工具类,对访问系统参数进行AccessController.doPrivileged访问权限过滤重写接口回调返回结果、对类class文件进行过滤安全后返回包含区域对象,详情参见源码示例。
二、源码说明
package org.mozilla.javascript;@b@@b@import java.security.AccessController;@b@import java.security.PrivilegedAction;@b@import java.security.ProtectionDomain;@b@@b@public class SecurityUtilities@b@{@b@ public static String getSystemProperty(String name)@b@ {@b@ return ((String)AccessController.doPrivileged(new PrivilegedAction(name)@b@ {@b@ public Object run()@b@ {@b@ return System.getProperty(this.val$name);@b@ }@b@ }));@b@ }@b@@b@ public static ProtectionDomain getProtectionDomain(Class<?> clazz)@b@ {@b@ return ((ProtectionDomain)AccessController.doPrivileged(new PrivilegedAction(clazz)@b@ {@b@ public Object run()@b@ {@b@ return this.val$clazz.getProtectionDomain();@b@ }@b@ }));@b@ }@b@}