Created
February 25, 2017 18:59
-
-
Save gjyoung1974/769e75816f19b6f1e1b84216fa1982e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
__author__ = '[email protected]' | |
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 = '[email protected]' # 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