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.apache.org/licenses/LICENSE-2.0.txt
15  //
16  //You may elect to redistribute this code under either of these licenses.
17  //========================================================================
18  
19  import java.security.CodeSource;
20  import java.security.KeyStore;
21  import java.security.PermissionCollection;
22  import java.security.Principal;
23  import java.security.ProtectionDomain;
24  import java.security.cert.Certificate;
25  import java.util.Set;
26  
27  public class PolicyBlock
28  {
29      public CodeSource codesource;
30      
31      public KeyStore keyStore;
32      
33      public Set<Certificate> certificates;
34  
35      public Principal[] principals;
36      
37      public PermissionCollection permissions;
38      
39      private ProtectionDomain protectionDomain;
40      
41      public ProtectionDomain toProtectionDomain()
42      {
43          if ( protectionDomain == null )
44          {
45              protectionDomain = new ProtectionDomain(codesource,null,Thread.currentThread().getContextClassLoader(),principals);
46          }
47                  
48          return protectionDomain;
49      }
50     
51      public KeyStore getKeyStore()
52      {
53          return keyStore;
54      }
55  
56      public void setKeyStore(KeyStore keyStore)
57      {
58          this.keyStore = keyStore;
59      }
60  
61      public CodeSource getCodeSource()
62      {
63          return codesource;
64      }
65  
66      public void setCodeSource( CodeSource codesource )
67      {
68          this.codesource = codesource;
69      }
70  
71      public Set<Certificate> getCertificates()
72      {
73          return certificates;
74      }
75  
76      public void setCertificates( Set<Certificate> certificates )
77      {
78          this.certificates = certificates;
79      }
80  
81      public Principal[] getPrincipals()
82      {
83          return principals;
84      }
85  
86      public void setPrincipals( Principal[] principals )
87      {
88          this.principals = principals;
89      }
90  
91      public PermissionCollection getPermissions()
92      {
93          return permissions;
94      }
95  
96      public void setPermissions( PermissionCollection permissions )
97      {
98          this.permissions = permissions;
99      }
100 }