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.PermissionCollection;
21  import java.security.Principal;
22  import java.security.ProtectionDomain;
23  import java.security.cert.Certificate;
24  import java.util.Set;
25  
26  public class PolicyBlock
27  {
28      public CodeSource codesource;
29      
30      public Set<Certificate> certificates;
31  
32      public Principal[] principals;
33      
34      public PermissionCollection permissions;
35      
36      private ProtectionDomain protectionDomain;
37      
38      public ProtectionDomain toProtectionDomain()
39      {
40          if ( protectionDomain == null )
41          {
42              protectionDomain = new ProtectionDomain(codesource,null,Thread.currentThread().getContextClassLoader(),principals);
43          }
44          
45          return protectionDomain;
46      }
47  
48      public CodeSource getCodeSource()
49      {
50          return codesource;
51      }
52  
53      public void setCodeSource( CodeSource codesource )
54      {
55          this.codesource = codesource;
56      }
57  
58      public Set<Certificate> getCertificates()
59      {
60          return certificates;
61      }
62  
63      public void setCertificates( Set<Certificate> certificates )
64      {
65          this.certificates = certificates;
66      }
67  
68      public Principal[] getPrincipals()
69      {
70          return principals;
71      }
72  
73      public void setPrincipals( Principal[] principals )
74      {
75          this.principals = principals;
76      }
77  
78      public PermissionCollection getPermissions()
79      {
80          return permissions;
81      }
82  
83      public void setPermissions( PermissionCollection permissions )
84      {
85          this.permissions = permissions;
86      }
87      
88      
89  }