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.HashSet;
22  import java.util.Map;
23  import java.util.Set;
24  
25  /**
26   * 
27   *
28   */
29  public class JettyPolicyConfigurator
30  {
31      Set<String> _policies= new HashSet<String>();
32      Map<String, String> _properties = new HashMap<String,String>();
33      
34      public JettyPolicyConfigurator()
35      {
36          
37      }
38      
39      public void addPolicy( String policy )
40      {
41          _policies.add(policy);
42      }
43      
44      public void addProperty( String name, String value )
45      {
46          _properties.put(name,value);
47      }
48      
49      public void initialize()
50      {        
51          JettyPolicy jpolicy = new JettyPolicy( _policies, _properties );
52          jpolicy.refresh();
53          Policy.setPolicy(jpolicy);
54          System.setSecurityManager(new SecurityManager());
55      }
56      
57  }