-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OM-188 Implemented mconnect client, Added some configs
- Loading branch information
1 parent
b74686d
commit 446f30e
Showing
5 changed files
with
63 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from zeep import Plugin | ||
from zeep.exceptions import SignatureVerificationFailed | ||
|
||
from msystems.xml_utils import add_timestamp, add_signature, verify_timestamp, verify_signature | ||
|
||
|
||
class SoapClientError(Exception): | ||
pass | ||
|
||
|
||
class SoapWssePlugin(Plugin): | ||
def __init__(self, service_private_key, service_certificate, mconnect_certificate): | ||
self.service_certificate = service_certificate | ||
self.service_private_key = service_private_key | ||
self.mconnect_certificate = mconnect_certificate | ||
|
||
def egress(self, envelope, http_headers, operation, binding_options): | ||
root = envelope | ||
|
||
add_timestamp(root) | ||
add_signature(root, self.service_private_key, self.service_certificate) | ||
|
||
return envelope, http_headers | ||
|
||
def ingress(self, envelope, http_headers, operation): | ||
try: | ||
verify_timestamp(envelope) | ||
except ValueError as e: | ||
raise SoapClientError(str(e)) | ||
|
||
try: | ||
verify_signature(envelope, self.mconnect_certificate) | ||
except SignatureVerificationFailed: | ||
raise SoapClientError("Envelope signature verification failed") | ||
|
||
return envelope, http_headers |
This file contains 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
This file contains 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