1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.policy.entry;
20
21 import java.io.InputStream;
22 import java.net.URL;
23 import java.security.KeyStore;
24
25 import org.eclipse.jetty.policy.PolicyContext;
26 import org.eclipse.jetty.policy.PolicyException;
27 import org.eclipse.jetty.util.resource.Resource;
28
29 public class KeystoreEntry extends AbstractEntry
30 {
31
32
33
34 private String url;
35
36
37
38
39 private String type;
40
41
42 private KeyStore keystore;
43
44 public KeyStore toKeyStore() throws PolicyException
45 {
46 if ( keystore != null && !isDirty() )
47 {
48 return keystore;
49 }
50
51 try
52 {
53 keystore = KeyStore.getInstance( type );
54
55 URL keyStoreLocation = new URL ( url );
56 Resource r = Resource.newResource(keyStoreLocation);
57 InputStream istream = r.getInputStream();
58
59 keystore.load( istream, null );
60
61
62 }
63 catch ( Exception e )
64 {
65 throw new PolicyException( e );
66 }
67
68 return keystore;
69 }
70
71 @Override
72 public void expand( PolicyContext context ) throws PolicyException
73 {
74 url = context.evaluate( url );
75
76 setExpanded( true );
77 }
78
79 public String getUrl()
80 {
81 return url;
82 }
83
84 public void setUrl( String url )
85 {
86 this.url = url;
87 }
88
89 public String getType()
90 {
91 return type;
92 }
93
94 public void setType( String type )
95 {
96 this.type = type;
97 }
98 }