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 catch ( Exception e )
57 {
58 throw new PolicyException( e );
59 }
60
61 return keystore;
62 }
63
64 @Override
65 public void expand( PolicyContext context ) throws PolicyException
66 {
67 url = context.evaluate( url );
68
69 setExpanded( true );
70 }
71
72 public String getUrl()
73 {
74 return url;
75 }
76
77 public void setUrl( String url )
78 {
79 this.url = url;
80 }
81
82 public String getType()
83 {
84 return type;
85 }
86
87 public void setType( String type )
88 {
89 this.type = type;
90 }
91 }