title: Using Apache Rampart for Signature with JKS and Binary Security Token key identifier
body: <p>I have to call a web service that was provided by a customer (some information below is masked for this reason). I've been provided with a java keystore that contains the private key that I need to use to generate a signature to include in the WSSecurity header of my request.</p>
  
  <p>Additionally, I've been sent a working SoapUI project that implements this service with the proper security configuration. The outgoing security configuration in soapUI has the "Key Identifier Type" set to "Binary Security Token"</p>
  
  <p>I am trying to set this call up in my Java application using Apache Rampart. I noticed that there is no equivalent to "Binary Security Token" key identifier in the OutflowSecurity configuration, so I'm trying the following. Here is the relevant snippet from my axis2.xml file:</p>
  
  <pre><code>&lt;module ref="rampart" /&gt;
  &lt;parameter name="OutflowSecurity"&gt;
      &lt;action&gt;
          &lt;items&gt;Signature&lt;/items&gt;
          &lt;user&gt;*******&lt;/user&gt;
          &lt;passwordCallbackClass&gt;*******.PWCBHandler&lt;/passwordCallbackClass&gt;
          &lt;signaturePropFile&gt;crypto.properties&lt;/signaturePropFile&gt;
          &lt;signatureKeyIdentifier&gt;DirectReference&lt;/signatureKeyIdentifier&gt;
      &lt;/action&gt;
  &lt;/parameter&gt;
  </code></pre>
  
  <p>And here are the contents of my crypto.properties file:</p>
  
  <pre><code>org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
  org.apache.ws.security.crypto.merlin.keystore.type=jks
  org.apache.ws.security.crypto.merlin.file=C:/rampart/*****.jks
  org.apache.ws.security.crypto.merlin.keystore.alias=******
  org.apache.ws.security.crypto.merlin.alias.password=**********
  org.apache.ws.security.crypto.merlin.keystore.password=********* (same as above)
  </code></pre>
  
  <p>The issue is that when I try to execute the service with this configuration, I get the following error:</p>
  
  <pre><code>org.apache.axis2.AxisFault: Error during Signature: 
  at org.apache.rampart.handler.WSDoAllSender.processMessage(WSDoAllSender.java:75)
  at org.apache.rampart.handler.WSDoAllHandler.invoke(WSDoAllHandler.java:72)
  at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
  at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
  at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
  at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:427)
  at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
  at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
  at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
  ... (removed)
  Caused by: org.apache.ws.security.WSSecurityException: Error during Signature: 
  at org.apache.ws.security.action.SignatureAction.execute(SignatureAction.java:64)
  at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:202)
  at org.apache.rampart.handler.WSDoAllSender.processBasic(WSDoAllSender.java:212)
  at org.apache.rampart.handler.WSDoAllSender.processMessage(WSDoAllSender.java:72)
  ... 13 more
  Caused by: org.apache.ws.security.WSSecurityException: Signature creation failed
  at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:558)
  at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:478)
  at org.apache.ws.security.message.WSSecSignature.build(WSSecSignature.java:384)
  at org.apache.ws.security.action.SignatureAction.execute(SignatureAction.java:61)
  ... 16 more
  Caused by: org.apache.ws.security.WSSecurityException: General security error (The private key for the supplied alias does not exist in the keystore)
  at org.apache.ws.security.components.crypto.Merlin.getPrivateKey(Merlin.java:725)
  at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:501)
  ... 19 more
  Caused by: java.security.UnrecoverableKeyException: Cannot recover key
  at sun.security.provider.KeyProtector.recover(Unknown Source)
  at sun.security.provider.JavaKeyStore.engineGetKey(Unknown Source)
  at sun.security.provider.JavaKeyStore$JKS.engineGetKey(Unknown Source)
  at java.security.KeyStore.getKey(Unknown Source)
  at org.apache.ws.security.components.crypto.Merlin.getPrivateKey(Merlin.java:711)
  ... 20 more
  </code></pre>
  
  <p>I've tried all of the different signatureKeyIdentifiers options without any luck. Could anyone help me perhaps figure out where to go from here to debug this issue?</p>
  
  <p>Thank you!</p>