source: TI12-security/trunk/python/ndg.security.server/ndg/security/server/SessionMgr/server-config.tac @ 1784

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.server/ndg/security/server/SessionMgr/server-config.tac@1784
Revision 1784, 3.1 KB checked in by pjkersha, 13 years ago (diff)

ndg.security.server/setup.py: added 4Suite url to dependency links
server/SessionMgr/server-config.tac: minor reformatting
test/SessionMgrClientTest.py, common/SessionMgr/init.py: added WS-Security Signature handler code.
common/wsSecurity.py: WS-Security module as used in WebSphere? testing. will need refactoring to
use ZSI pyclass code generated from WS-Security schema.

Line 
1#!/usr/bin/env python
2"""NDG Security Attribute Authority .tac file
3
4This file enables the Session Manager web service to be
5called under the Twisted framework
6
7NERC Data Grid Project
8
9P J Kershaw 23/11/06
10
11Copyright (C) 2006 CCLRC & NERC
12
13This software may be distributed under the terms of the Q Public License,
14version 1.0 or later.
15"""
16import socket
17
18from ZSI.twisted.WSresource import WSResource
19from twisted.application import service, internet
20from twisted.web.server import Site
21from twisted.web.resource import Resource
22
23from SessionMgr_services_server import SessionMgrService
24from ndg.security.server.SessionMgr import SessionMgr
25
26# Use for stub testing only
27from ndg.security.common.SessionCookie import SessionCookie
28from datetime import datetime, timedelta
29
30# Temporary - for testing
31priKeyFilePath = '../../../../../Tests/webSphereTestkey.pem'
32certFilePath = '../../../../../Tests/webSphereTestcert.pem'
33priKeyPwd = '../../../../../Tests/tmp'
34
35class SessionMgrServiceSub(SessionMgrService, WSResource):
36    def __init__(self):
37        WSResource.__init__(self)
38         
39        # Initialize Attribute Authority class
40        self.__sm = SessionMgr()
41       
42    def soap_addUser(self, ps, **kw):
43        #import pdb;pdb.set_trace()
44        request, response = SessionMgrService.soap_addUser(self, ps)
45        return request, response
46
47    def soap_connect(self, ps, **kw):
48        #import pdb;pdb.set_trace()
49        request, response = SessionMgrService.soap_connect(self, ps)
50
51        if request.get_element_getCookie():
52            dtExpiry = datetime.utcnow() + timedelta(seconds=60*60)
53            cookie = SessionCookie(ndgID1='9'*64, 
54                                   ndgID2='0'*64,
55                                   dtExpiry=dtExpiry)
56            response.set_element_cookie(cookie)
57        else: 
58            response.set_element_proxyCert('PROXY CERT')
59                         
60        return request, response
61
62    def soap_disconnect(self, ps, **kw):
63        #import pdb;pdb.set_trace()
64        request, response = SessionMgrService.soap_disconnect(self, ps)
65        return request, response
66
67    def soap_reqAuthorisation(self, ps, **kw):
68        #import pdb;pdb.set_trace()
69        request, response = SessionMgrService.soap_reqAuthorisation(self, ps)
70        response.set_element_attCert('ATTRIBUTE CERTIFICATE')
71        response.set_element_statusCode('AcessGranted')
72        return request, response
73
74    def soap_getX509Cert(self, ps, **kw):
75        #import pdb;pdb.set_trace()
76        request, response = SessionMgrService.soap_getX509Cert(self, ps)
77        response.set_element_x509Cert('X.509 Cert.')
78        return request, response
79
80# Use default https port
81portNum = 5700
82hostname = socket.gethostname()
83
84root = Resource()
85root.putChild('SessionManager', SessionMgrServiceSub())
86siteFactory = Site(root)
87application = service.Application("ndgSecurityContainer")
88
89# Try SSL
90from twisted.internet import ssl
91kw = {}
92ctxFactory = ssl.DefaultOpenSSLContextFactory(priKeyFilePath, certFilePath)
93port = internet.SSLServer(portNum, siteFactory, ctxFactory)
94
95#port = internet.TCPServer(portNum, siteFactory)#, interface=hostname)
96port.setServiceParent(application)
Note: See TracBrowser for help on using the repository browser.