Java Code Examples for java.security.Policy#refresh()
The following examples show how to use
java.security.Policy#refresh() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultPolicy.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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); }
Example 2
Source File: WebappClassLoaderBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * 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 } }
Example 3
Source File: CallbacksSecurityTests.java From spring-analysis-note with MIT License | 5 votes |
public CallbacksSecurityTests() { // setup security if (System.getSecurityManager() == null) { Policy policy = Policy.getPolicy(); URL policyURL = getClass() .getResource( "/org/springframework/beans/factory/support/security/policy.all"); System.setProperty("java.security.policy", policyURL.toString()); System.setProperty("policy.allowSystemProperty", "true"); policy.refresh(); System.setSecurityManager(new SecurityManager()); } }
Example 4
Source File: CallbacksSecurityTests.java From java-technology-stack with MIT License | 5 votes |
public CallbacksSecurityTests() { // setup security if (System.getSecurityManager() == null) { Policy policy = Policy.getPolicy(); URL policyURL = getClass() .getResource( "/org/springframework/beans/factory/support/security/policy.all"); System.setProperty("java.security.policy", policyURL.toString()); System.setProperty("policy.allowSystemProperty", "true"); policy.refresh(); System.setSecurityManager(new SecurityManager()); } }
Example 5
Source File: WebappClassLoaderBase.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * 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 } }
Example 6
Source File: CallbacksSecurityTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
public CallbacksSecurityTests() { // setup security if (System.getSecurityManager() == null) { Policy policy = Policy.getPolicy(); URL policyURL = getClass() .getResource( "/org/springframework/beans/factory/support/security/policy.all"); System.setProperty("java.security.policy", policyURL.toString()); System.setProperty("policy.allowSystemProperty", "true"); policy.refresh(); System.setSecurityManager(new SecurityManager()); } }
Example 7
Source File: WebappClassLoaderBase.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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 } }
Example 8
Source File: AbstractSecurityService.java From tomee with Apache License 2.0 | 5 votes |
private static void installPolicy(String policyProvider) { try { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final Class policyClass = Class.forName(policyProvider, true, classLoader); final Policy policy = (Policy) policyClass.newInstance(); policy.refresh(); Policy.setPolicy(policy); } catch (final Exception e) { throw new IllegalStateException("Could not install JACC Policy Provider: " + policyProvider, e); } }