Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a solution. My problem was that I forgot to add hex encode to the NONCE Value and to the concated string. Here is my solution, maybe some need this.</p> <p>The functions to create pass etc.:</p> <pre><code>private String calculatePasswordDigest(String nonce, String created, String password) { String encoded = null; try { String pass = hexEncode(nonce) + created + password; MessageDigest md = MessageDigest.getInstance( "SHA1" ); md.update( pass.getBytes() ); byte[] encodedPassword = md.digest(); encoded = Base64.encodeBytes(encodedPassword); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(HeaderHandler.class.getName()).log(Level.SEVERE, null, ex); } return encoded; } private String hexEncode(String in) { StringBuilder sb = new StringBuilder(""); for (int i = 0; i &lt; (in.length() - 2) + 1; i = i + 2) { int c = Integer.parseInt(in.substring(i, i + 2), 16); char chr = (char) c; sb.append(chr); } return sb.toString(); } </code></pre> <p>Code to build the soap message:</p> <pre><code>String timestamp = HeaderHandler.localToGmtTimestamp(); String pass = "password"; String user = "username"; String nonceString = getNonce(); String dig=calculatePasswordDigest(nonceString, timestamp, pass); SOAPEnvelope envelope = smc.getMessage().getSOAPPart().getEnvelope(); SOAPHeader header = envelope.addHeader(); SOAPElement security = header.addChildElement("Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); SOAPElement usernameToken = security.addChildElement("UsernameToken", "wsse"); SOAPElement username = usernameToken.addChildElement("Username", "wsse"); username.addTextNode(user); SOAPElement password = usernameToken.addChildElement("Password", "wsse"); password.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"); password.addTextNode(dig); SOAPElement nonce = usernameToken.addChildElement("Nonce", "wsse"); nonce.addTextNode(Base64.encodeBytes(hexEncode(nonceString).getBytes())); SOAPElement created = usernameToken.addChildElement("Created", "wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); created.addTextNode(timestamp); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload