Skip to content

Instantly share code, notes, and snippets.

@akostadinov akostadinov/wsse_xml.rb
Last active Jun 13, 2016

What would you like to do?
generate XML WSSE credentials with the simple `wsse` gem.
require 'io/console'
require 'wsse'
header = WSSE::header('username', STDIN.noecho(&:gets).chomp)
def wsse_xml(user, password)
raw = WSSE::header(user, password)
# username = raw.gsub(/^.* Username="(.*)", PasswordDigest=".*(?!PasswordDigest)$/, '\\1')
digest = raw.gsub(/^.*, PasswordDigest="(.*)", Nonce=".*$/, '\\1')
nonce = raw.gsub(/^.*, Nonce="(.*)", Created=".*$/, '\\1')
created = raw.gsub(/^.*, Created="(.*)".*$/, '\\1')
xml = '''
<wsse:Security xmlns:wsse="">
<wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="">
<wsse:Password Type="">DIGEST</wsse:Password>
<!-- <wsse:Password Type="">PASSWORD</wsse:Password> -->
<wsse:Nonce EncodingType="">NONCE</wsse:Nonce>
# return xml.gsub("USER", user).gsub("PASSWORD", password).gsub("NONCE",nonce).gsub("CREATED",created)
return xml.gsub("USER", user).gsub("DIGEST", digest).gsub("NONCE",nonce).gsub("CREATED",created)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.