View Javadoc

1   package org.eclipse.jetty.policy;
2   
3   //========================================================================
4   //Copyright (c) Webtide LLC
5   //------------------------------------------------------------------------
6   //All rights reserved. This program and the accompanying materials
7   //are made available under the terms of the Eclipse Public License v1.0
8   //and Apache License v2.0 which accompanies this distribution.
9   //
10  //The Eclipse Public License is available at 
11  //http://www.eclipse.org/legal/epl-v10.html
12  //
13  //The Apache License v2.0 is available at
14  //http://www.opensource.org/licenses/apache2.0.php
15  //
16  //You may elect to redistribute this code under either of these licenses. 
17  //========================================================================
18  
19  import java.security.Policy;
20  import java.util.HashMap;
21  import java.util.Map;
22  
23  /**
24   * 
25   *
26   */
27  public class JettyPolicyConfigurator
28  {
29      String _policyDirectory;
30      Map<String, String> _properties = new HashMap<String,String>();
31      
32      public JettyPolicyConfigurator()
33      {
34          
35      }
36      
37      public void setPolicyDirectory( String policyDirectory )
38      {
39          _policyDirectory = policyDirectory;
40      }
41      
42      public void addProperty( String name, String value )
43      {
44          _properties.put(name,value);
45      }
46      
47      public void initialize()
48      {
49          JettyPolicy jpolicy = new JettyPolicy(_policyDirectory,_properties);
50  
51          jpolicy.refresh();
52          Policy.setPolicy(jpolicy);
53          System.setSecurityManager(new SecurityManager());
54      }
55  
56  }