本文整理匯總了Java中java.security.Policy.refresh方法的典型用法代碼示例。如果您正苦於以下問題:Java Policy.refresh方法的具體用法?Java Policy.refresh怎麽用?Java Policy.refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.Policy
的用法示例。
在下文中一共展示了Policy.refresh方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPermissions
import java.security.Policy; //導入方法依賴的package包/類
/**
* Get the Permissions for a CodeSource. If this instance
* of StandardClassLoader is for a web application context,
* add read FilePermissions for the base directory (if unpacked),
* the context URL, and jar file resources.
*
* @param CodeSource where the code was loaded from
* @return PermissionCollection for CodeSource
*/
protected final PermissionCollection getPermissions(CodeSource codeSource) {
if (!policy_refresh) {
// Refresh the security policies
Policy policy = Policy.getPolicy();
policy.refresh();
policy_refresh = true;
}
String codeUrl = codeSource.getLocation().toString();
PermissionCollection pc;
if ((pc = (PermissionCollection)loaderPC.get(codeUrl)) == null) {
pc = super.getPermissions(codeSource);
if (pc != null) {
Iterator perms = permissionList.iterator();
while (perms.hasNext()) {
Permission p = (Permission)perms.next();
pc.add(p);
}
loaderPC.put(codeUrl,pc);
}
}
return (pc);
}
示例2: main
import java.security.Policy; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// Check policy with no java.security.policy property set
Policy p = Policy.getPolicy();
checkPolicy(p);
// Check policy with java.security.policy '=' option
System.setProperty("java.security.policy", "Extra.policy");
p.refresh();
checkPolicy(p);
// Check policy with java.security.policy override '==' option
System.setProperty("java.security.policy", "=Extra.policy");
p.refresh();
checkPolicy(p);
// Check Policy.getInstance
URI policyURI = Paths.get(System.getProperty("test.src"),
"Extra.policy").toUri();
p = Policy.getInstance("JavaPolicy", new URIParameter(policyURI));
checkPolicy(p);
}
示例3: refreshPolicy
import java.security.Policy; //導入方法依賴的package包/類
/**
* Refresh the system policy file, to pick up eventual changes.
*/
protected void refreshPolicy() {
try {
// The policy file may have been modified to adjust
// permissions, so we're reloading it when loading or
// reloading a Context
Policy policy = Policy.getPolicy();
policy.refresh();
} catch (AccessControlException e) {
// Some policy files may restrict this, even for the core,
// so this exception is ignored
}
}
示例4: refreshPolicy
import java.security.Policy; //導入方法依賴的package包/類
/**
* Refresh the system policy file, to pick up eventual changes.
*/
protected void refreshPolicy() {
try {
// The policy file may have been modified to adjust
// permissions, so we're reloading it when loading or
// reloading a Context
Policy policy = Policy.getPolicy();
policy.refresh();
} catch (AccessControlException e) {
// Some policy files may restrict this, even for the core,
// so this exception is ignored
}
}
示例5: refreshPolicy
import java.security.Policy; //導入方法依賴的package包/類
/**
* Refresh the system policy file, to pick up eventual changes.
*/
protected void refreshPolicy() {
try {
// The policy file may have been modified to adjust
// permissions, so we're reloading it when loading or
// reloading a Context
Policy policy = Policy.getPolicy();
policy.refresh();
} catch (AccessControlException e) {
// Some policy files may restrict this, even for the core,
// so this exception is ignored
}
}