Changeset 4052 for TI12-security/trunk
- Timestamp:
- 18/07/08 16:00:44 (11 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/Tests/etreewss/server/echoServer.cfg
r4024 r4052 9 9 [setUp] 10 10 hostname = localhost 11 #port = 700012 port = 710011 port = 7000 12 #port = 7100 13 13 path = /Echo 14 14 wsseCfgFilePath = $NDGSEC_WSSESRV_UNITTEST_DIR/wssecurity.cfg -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/wsSecurity.py
r3897 r4052 758 758 759 759 760 def _verifyTimeStamp(self, parsedSOAP, ctxt ):760 def _verifyTimeStamp(self, parsedSOAP, ctxt, timestampMustBeSet=False): 761 761 """Call from verify to check timestamp if found. 762 762 … … 770 770 771 771 try: 772 timestampNode = xpath.Evaluate('//ws se:Timestamp',772 timestampNode = xpath.Evaluate('//wsu:Timestamp', 773 773 contextNode=parsedSOAP.dom, 774 774 context=ctxt)[0] 775 775 except: 776 log.warning("Verifying message - No timestamp element found") 777 return 776 msg = "Verifying message - No timestamp element found" 777 if timestampMustBeSet: 778 raise TimestampError(msg) 779 else: 780 log.warning(msg) 781 return 778 782 779 783 # Time now 780 784 dtNow = datetime.utcnow() 781 782 createdNode = timestampNode.getElementsByTagName("Created") 783 785 import pdb;pdb.set_trace() 786 try: 787 createdNodeText = getElements(timestampNode, "Created")[0].\ 788 childNodes[0].nodeValue 789 except IndexError: 790 raise TimestampError("Verifying message - No Created timestamp " 791 "sub-element found") 792 784 793 # Workaround for fractions of second 785 794 try: 786 [createdDateTime, createdSecFraction]=createdNode.nodeValue.split() 795 createdDateTime, strCreatedSecFraction = createdNodeText.split('.') 796 797 strCreatedSecFraction = strCreatedSecFraction.split('Z')[0] 798 createdExp = -int(len(strCreatedSecFraction)) 799 createdSecFraction = int(strCreatedSecFraction) * 10 ** createdExp 800 787 801 except ValueError, e: 788 802 raise ValueError("Parsing timestamp Created element: %s" % e) 789 803 790 804 dtCreated = datetime.strptime(createdDateTime, '%Y-%m-%dT%H:%M:%S') 791 dtCreated += timedelta(seconds= int(createdSecFraction))805 dtCreated += timedelta(seconds=createdSecFraction) 792 806 if dtCreated >= dtNow: 793 807 raise TimestampError(\ … … 795 809 (dtCreated, dtNow)) 796 810 797 expiresNode = timestampNode.getElementsByTagName("Expires")798 if expiresNode is None:799 log.warning(\800 "Verifying message - No Expires element found in Timestamp")801 return802 803 811 try: 804 [expiresDateTime, expiresSecFraction]=expiresNode.nodeValue.split() 812 expiresNodeText = getElements(timestampNode, "Expires")[0].\ 813 childNodes[0].nodeValue 814 except IndexError: 815 raise TimestampError("Verifying message - No Expires element " 816 "found in Timestamp") 817 818 try: 819 expiryDateTime, strExpirySecFraction = expiresNodeText.split('.') 820 821 strExpirySecFraction = strExpirySecFraction.split('Z')[0] 822 expiryExp = -int(len(strExpirySecFraction)) 823 expirySecFraction = int(strExpirySecFraction) * 10 ** expiryExp 824 805 825 except ValueError, e: 806 826 raise ValueError("Parsing timestamp Expires element: %s" % e) 807 827 808 dt Created = datetime.strptime(expiresDateTime, '%Y-%m-%dT%H:%M:%S')809 dt Created += timedelta(seconds=int(createdSecFraction))810 if dtExpiry >dtNow:828 dtExpiry = datetime.strptime(expiryDateTime, '%Y-%m-%dT%H:%M:%S') 829 dtExpiry += timedelta(seconds=expirySecFraction) 830 if dtExpiry < dtNow: 811 831 raise TimestampError(\ 812 832 "Timestamp expiry time %s is after the current time %s" % \ -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/wssecurity/etree.py
r4051 r4052 836 836 namespaces=self._processorNSs) 837 837 if expiresElem is None: 838 raise TimestampError(\ 839 "Verifying message - No Expires element found in Timestamp") 840 return 838 raise TimestampError("Verifying message - No Expires element " 839 "found in Timestamp") 841 840 842 841 try: -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/wsSecurity/client/echoClientTest.py
r3652 r4052 18 18 from os.path import join as jnPath 19 19 mkPath = lambda file: jnPath(os.environ['NDGSEC_WSSECLNT_UNITTEST_DIR'], file) 20 21 import logging 22 logging.basicConfig(level=logging.DEBUG) 20 23 21 24 class EchoClientTestCase(unittest.TestCase):
Note: See TracChangeset
for help on using the changeset viewer.