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