source: TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/paster_templates/authorisationservice/authorisationserviceapp.py @ 7843

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/paster_templates/authorisationservice/authorisationserviceapp.py@7843
Revision 7843, 2.1 KB checked in by pjkersha, 9 years ago (diff)

Incomplete - task 16: NDG Security 2.x.x - incl. updated Paster templates

  • Moved PasteDeployAppServer? class to ndg.security.server.utils.paste_utils module so that it can be included in scripts as part of the paster templates.
  • tidied and rationalised attribute and authorisation service scripts.
Line 
1#!/usr/bin/env python
2"""NDG Security test harness for authorisation service
3
4NERC DataGrid Project
5
6"""
7__author__ = "P J Kershaw"
8__date__ = "25/01/11"
9__copyright__ = "(C) 2009 Science and Technology Facilities Council"
10__contact__ = "Philip.Kershaw@stfc.ac.uk"
11__revision__ = "$Id: securityservicesapp.py 7829 2011-01-24 15:09:22Z pjkersha $"
12import os
13from os.path import dirname, abspath, join
14import optparse 
15
16from ndg.security.test.unit import BaseTestCase, TEST_CONFIG_DIR
17from ndg.security.test.unit.wsgi import PasteDeployAppServer
18
19INI_FILENAME = 'authorisation-service.ini'
20
21# To start run
22# $ paster serve services.ini or run this file as a script, see
23# $ ./authorisationserviceapp.py -h
24if __name__ == '__main__':   
25    cfgFilePath = os.path.join(dirname(abspath(__file__)), INI_FILENAME) 
26       
27    parser = optparse.OptionParser()
28    parser.add_option("-p",
29                      "--port",
30                      dest="port",
31                      default=9443,
32                      type='int',
33                      help="port number to run under")
34
35    parser.add_option("-c",
36                      "--cert-file",
37                      dest='certFilePath',
38                      help="SSL Certificate file")
39
40    parser.add_option("-k",
41                      "--private-key-file",
42                      dest='priKeyFilePath',
43                      help="SSL private key file")
44
45    parser.add_option("-f",
46                      "--conf",
47                      dest="configFilePath",
48                      default=cfgFilePath,
49                      help="Configuration file path")
50   
51    opt = parser.parse_args()[0]
52   
53    if opt.certFilePath:         
54        from OpenSSL import SSL
55       
56        ssl_context = SSL.Context(SSL.SSLv23_METHOD)
57        ssl_context.set_options(SSL.OP_NO_SSLv2)
58   
59        ssl_context.use_privatekey_file(opt.priKeyFilePath)
60        ssl_context.use_certificate_file(opt.certFilePath)
61    else:
62        ssl_context = None
63
64    server = PasteDeployAppServer(cfgFilePath=opt.configFilePath, 
65                                  port=opt.port,
66                                  ssl_context=ssl_context) 
67    server.start()
68
Note: See TracBrowser for help on using the repository browser.