View Javadoc

1   package ca.uhn.hl7v2.examples.hoh;
2   
3   import javax.servlet.ServletConfig;
4   import javax.servlet.ServletException;
5   
6   import ca.uhn.hl7v2.hoh.hapi.server.HohServlet;
7   import ca.uhn.hl7v2.hoh.sign.BouncyCastleCmsMessageSigner;
8   import ca.uhn.hl7v2.hoh.util.KeystoreUtils;
9   
10  //START SNIPPET: servlet 
11  public class SignatureServlet extends HohServlet {
12  
13  	@Override
14  	public void init(ServletConfig theConfig) throws ServletException {
15  		
16  		//Create a message signer and pass it to the servlet
17  		BouncyCastleCmsMessageSigner signer = new BouncyCastleCmsMessageSigner();
18  		try {
19  			signer.setKeyStore(KeystoreUtils.loadKeystore("/path/to/keystore/keystore.jks", "store_password"));
20  		} catch (Exception e) {
21  			throw new ServletException(e);
22  		}
23  		signer.setKeyAlias("keyalias");
24  		signer.setAliasPassword("key_password");
25  		setSigner(signer);
26  	
27  		// ... also provide a message handler ...
28  		
29  	}
30  
31  }
32  //END SNIPPET: servlet