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