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              if ( codesource == null )
43              {
44                  protectionDomain = new ProtectionDomain( null, permissions );
45              }
46              else
47              {   
48                  protectionDomain = new ProtectionDomain( codesource, permissions, Thread.currentThread().getContextClassLoader(), principals );
49              }
50          }
51          
52          return protectionDomain;
53      }
54  
55      public CodeSource getCodeSource()
56      {
57          return codesource;
58      }
59  
60      public void setCodeSource( CodeSource codesource )
61      {
62          this.codesource = codesource;
63      }
64  
65      public Set<Certificate> getCertificates()
66      {
67          return certificates;
68      }
69  
70      public void setCertificates( Set<Certificate> certificates )
71      {
72          this.certificates = certificates;
73      }
74  
75      public Principal[] getPrincipals()
76      {
77          return principals;
78      }
79  
80      public void setPrincipals( Principal[] principals )
81      {
82          this.principals = principals;
83      }
84  
85      public PermissionCollection getPermissions()
86      {
87          return permissions;
88      }
89  
90      public void setPermissions( PermissionCollection permissions )
91      {
92          this.permissions = permissions;
93      }
94      
95      
96  }