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 import org.eclipse.jetty.util.resource.Resource;
25
26 public class KeystoreEntry extends AbstractEntry
27 {
28
29
30
31 private String url;
32
33
34
35
36 private String type;
37
38
39 private KeyStore keystore;
40
41 public KeyStore toKeyStore() throws PolicyException
42 {
43 if ( keystore != null && !isDirty() )
44 {
45 return keystore;
46 }
47
48 try
49 {
50 keystore = KeyStore.getInstance( type );
51
52 URL keyStoreLocation = new URL ( url );
53 Resource r = Resource.newResource(keyStoreLocation);
54 InputStream istream = r.getInputStream();
55
56 keystore.load( istream, null );
57
58
59 }
60 catch ( Exception e )
61 {
62 throw new PolicyException( e );
63 }
64
65 return keystore;
66 }
67
68 @Override
69 public void expand( PolicyContext context ) throws PolicyException
70 {
71 url = context.evaluate( url );
72
73 setExpanded( true );
74 }
75
76 public String getUrl()
77 {
78 return url;
79 }
80
81 public void setUrl( String url )
82 {
83 this.url = url;
84 }
85
86 public String getType()
87 {
88 return type;
89 }
90
91 public void setType( String type )
92 {
93 this.type = type;
94 }
95 }