source: TI12-security/trunk/WSSecurity/ndg/wssecurity/encryptionhandler/__init__.py @ 6409

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/WSSecurity/ndg/wssecurity/encryptionhandler/__init__.py@6409
Revision 6409, 1.6 KB checked in by pjkersha, 10 years ago (diff)
Line 
1"""Encryption Handler package
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "05/06/2009"
7__copyright__ = ""
8__license__ = "BSD - see LICENSE file in top-level directory"
9__contact__ = "Philip.Kershaw@stfc.ac.uk"
10__revision__ = '$Id: $'
11from ZSI.wstools.Namespaces import ENCRYPTION
12
13# Conditional import as this is required for the encryption
14# handler
15try:
16    # For shared key encryption
17    from Crypto.Cipher import AES, DES3
18except:
19    from warnings import warn
20    warn('Crypto.Cipher not available: EncryptionHandler disabled!',
21         RuntimeWarning)
22    class AES:
23        MODE_ECB = None
24        MODE_CBC = None
25       
26    class DES3: 
27        MODE_CBC = None
28       
29class _ENCRYPTION(ENCRYPTION):
30    '''Derived from ENCRYPTION class to add in extra 'tripledes-cbc' - is this
31    any different to 'des-cbc'?  ENCRYPTION class implies that it is the same
32    because it's assigned to 'BLOCK_3DES' ??'''
33    BLOCK_TRIPLEDES = "http://www.w3.org/2001/04/xmlenc#tripledes-cbc"
34   
35   
36class EncryptionHandlerBase(object):
37    """ZSI based Encryption handler virtual base class"""
38   
39    def decrypt(self, parsedSOAP):
40        """Decrypt a message
41       
42        @type parsedSOAP: ZSI.parse.ParsedSoap
43        @param parsedSOAP: object contain parsed SOAP message received from
44        sender"""       
45        raise NotImplementedError()
46   
47    def encrypt(self, soapWriter):
48        '''Encrypt the message
49       
50        @type soapWriter: ZSI.writer.SoapWriter
51        @param soapWriter: ZSI object to write SOAP message
52        '''
53        raise NotImplementedError()
Note: See TracBrowser for help on using the repository browser.