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

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

server/SessionMgr/server-config.tac: added twisted SSLServer.
test/SessionMgrClientTest.py: testing SSL connection to SessionMgr? - appears to be a problem with
the socket library. It doesn't have the ssl module?? - update version of python
common/AttAuthorityIO.py, common/LogIO.py and common/SessionMgrIO.py: these are not needed anymore as
ZSI will do the required XML formatting of SOAP messages.

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
26from ndg.security.common.SessionCookie import SessionCookie
27from datetime import datetime, timedelta
28
29class SessionMgrServiceSub(SessionMgrService, WSResource):
30     def __init__(self):
31         WSResource.__init__(self)
32         
33         # Initialize Attribute Authority class
34         self.__sm = SessionMgr()
35
36     def soap_addUser(self, ps, **kw):
37         #import pdb;pdb.set_trace()
38         request, response = SessionMgrService.soap_addUser(self, ps)
39         return request, response
40
41     def soap_connect(self, ps, **kw):
42         #import pdb;pdb.set_trace()
43         request, response = SessionMgrService.soap_connect(self, ps)
44         response.set_element_proxyCert('PROXY CERT')
45         
46         dtExpiry = datetime.utcnow() + timedelta(seconds=60*60)
47         cookie = SessionCookie(ndgID1='9'*64, 
48                                ndgID2='0'*64,
49                                dtExpiry=dtExpiry)
50         
51         response.set_element_cookie(cookie)
52         return request, response
53
54     def soap_disconnect(self, ps, **kw):
55         #import pdb;pdb.set_trace()
56         request, response = SessionMgrService.soap_disconnect(self, ps)
57         return request, response
58
59     def soap_reqAuthorisation(self, ps, **kw):
60         #import pdb;pdb.set_trace()
61         request, response = SessionMgrService.soap_reqAuthorisation(self, ps)
62         response.set_element_attCert('ATTRIBUTE CERTIFICATE')
63         response.set_element_statusCode('AcessGranted')
64         return request, response
65
66     def soap_getX509Cert(self, ps, **kw):
67         #import pdb;pdb.set_trace()
68         request, response = SessionMgrService.soap_getX509Cert(self, ps)
69         response.set_element_x509Cert('X.509 Cert.')
70         return request, response
71
72portNum = 5000
73hostname = socket.gethostname()
74
75root = Resource()
76root.putChild('SessionManager', SessionMgrServiceSub())
77siteFactory = Site(root)
78application = service.Application("ndgSecurityContainer")
79
80# Try SSL
81from twisted.internet import ssl
82kw = {}
83priKeyFilePath = '../../../../../Tests/Junk2-key.pem'
84certFilePath = '../../../../../Tests/Junk2-cert.pem'
85ctxFactory = ssl.DefaultOpenSSLContextFactory(priKeyFilePath, certFilePath)
86port = internet.SSLServer(portNum, siteFactory, ctxFactory)
87
88#port = internet.TCPServer(portNum, siteFactory)#, interface=hostname)
89port.setServiceParent(application)
Note: See TracBrowser for help on using the repository browser.