Skip to content

Instantly share code, notes, and snippets.

@gjyoung1974
Created February 25, 2017 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjyoung1974/769e75816f19b6f1e1b84216fa1982e9 to your computer and use it in GitHub Desktop.
Save gjyoung1974/769e75816f19b6f1e1b84216fa1982e9 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
__author__ = 'gjyoung1974@gmail.com'
import xml.etree.ElementTree as ET # leverage ElementTree to parse the response
import http.client # leverage the native HTTP Client
VoltageSDAURL = 'voltage-pp-0000.gordonyoung.us' # Set the URL For the Voltage IBA SecureData Appliance
PlaintextPAN = '4444555566662222' # Plaintext PAN to protect
ProtectionFormat = 'CC' # Data Protection Format to use
Identity = 'gyoung@gordonyoung.us' # IBE Identity
AuthMethod = 'SharedSecret' # Authentication Method, such as SharedSecret
AuthInfo = 'Passwor6' # IBE Password
# Marshal a ProtectFormattedData SOAP Message
soap_request = \
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vib="http://voltage.com/vibesimple"> \
<soapenv:Header/> \
<soapenv:Body> \
<vib:ProtectFormattedData> \
<dataIn>' + PlaintextPAN + '</dataIn> \
<format>' + ProtectionFormat + '</format> \
<identity>' + Identity + '</identity> \
<tweak></tweak> \
<authMethod>' + AuthMethod + '</authMethod> \
<authInfo>' + AuthInfo + '</authInfo> \
</vib:ProtectFormattedData> \
</soapenv:Body> \
</soapenv:Envelope>'
# Wire up an http.client message
headers = {"Content-type": "text/xml;charset=UTF-8",
"SOAPAction": "http://voltage.com/vibesimple"} # set the SOAP Message HTTP Headers
conn = http.client.HTTPSConnection(VoltageSDAURL, 8181) # connect to the Voltage appliance
conn.request('POST', '/vibesimple/services/VibeSimpleSOAP', soap_request, headers) # Post the SOAP Message
# collect the response and do something with it
response = conn.getresponse()
s_response = response.read()
tree = ET.fromstring(s_response)
result = tree.find('.//{http://voltage.com/vibesimple}ProtectFormattedDataResponse/dataOut').text
print(result)
conn.close() # close the socket
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment