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 System.out.println("Initializing Jetty Policy");
52
53 JettyPolicy jpolicy = new JettyPolicy( _policies, _properties );
54 jpolicy.refresh();
55 Policy.setPolicy(jpolicy);
56 System.setSecurityManager(new SecurityManager());
57 }
58
59 }