Skip to content

Instantly share code, notes, and snippets.

@bshaffer
Created February 20, 2013 18:35
Show Gist options
  • Save bshaffer/4997860 to your computer and use it in GitHub Desktop.
Save bshaffer/4997860 to your computer and use it in GitHub Desktop.
protected String getSecurityHeader(String apiKey, String apiSecret, byte[] nonce, String username, String secret, String created) throws UnsupportedEncodingException {
String password64 = AuthenticationHelper.getBase64Digest(nonce, created.getBytes(), secret.getBytes());
StringBuffer header = new StringBuffer();
header.append("UsernameToken Username=\"");
header.append(username);
header.append("\", ");
header.append("PasswordDigest=\"");
header.append(password64.trim());
header.append("\", ");
header.append("Nonce=\"");
header.append(AuthenticationHelper.base64Encode(nonce).trim());
header.append("\", ");
header.append("Created=\"");
header.append(created);
header.append("\", ");
header.append("appkey=\"");
header.append(apiKey);
header.append("\", ");
header.append("appdigest=\"");
header.append(getAppPassword(apiSecret, nonce));
header.append("\", ");
header.append("appnonce=\"");
header.append(AuthenticationHelper.base64Encode(nonce).trim());
return header.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment