View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.policy;
20  
21  import java.security.CodeSource;
22  import java.security.KeyStore;
23  import java.security.PermissionCollection;
24  import java.security.Principal;
25  import java.security.ProtectionDomain;
26  import java.security.cert.Certificate;
27  import java.util.Set;
28  
29  public class PolicyBlock
30  {
31      public CodeSource codesource;
32      
33      public KeyStore keyStore;
34      
35      public Set<Certificate> certificates;
36  
37      public Principal[] principals;
38      
39      public PermissionCollection permissions;
40      
41      private ProtectionDomain protectionDomain;
42      
43      public ProtectionDomain toProtectionDomain()
44      {
45          if ( protectionDomain == null )
46          {
47              protectionDomain = new ProtectionDomain(codesource,null,Thread.currentThread().getContextClassLoader(),principals);
48          }
49                  
50          return protectionDomain;
51      }
52     
53      public KeyStore getKeyStore()
54      {
55          return keyStore;
56      }
57  
58      public void setKeyStore(KeyStore keyStore)
59      {
60          this.keyStore = keyStore;
61      }
62  
63      public CodeSource getCodeSource()
64      {
65          return codesource;
66      }
67  
68      public void setCodeSource( CodeSource codesource )
69      {
70          this.codesource = codesource;
71      }
72  
73      public Set<Certificate> getCertificates()
74      {
75          return certificates;
76      }
77  
78      public void setCertificates( Set<Certificate> certificates )
79      {
80          this.certificates = certificates;
81      }
82  
83      public Principal[] getPrincipals()
84      {
85          return principals;
86      }
87  
88      public void setPrincipals( Principal[] principals )
89      {
90          this.principals = principals;
91      }
92  
93      public PermissionCollection getPermissions()
94      {
95          return permissions;
96      }
97  
98      public void setPermissions( PermissionCollection permissions )
99      {
100         this.permissions = permissions;
101     }
102 }