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