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 public void expand( PolicyContext context ) throws PolicyException
65 {
66 url = context.evaluate( url );
67
68 setExpanded( true );
69 }
70
71 public String getUrl()
72 {
73 return url;
74 }
75
76 public void setUrl( String url )
77 {
78 this.url = url;
79 }
80
81 public String getType()
82 {
83 return type;
84 }
85
86 public void setType( String type )
87 {
88 this.type = type;
89 }
90 }