Changeset 1227
- Timestamp:
- 21/06/06 13:57:58 (15 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/Tests/SecurityClientTest.py
r1215 r1227 28 28 try: 29 29 # Session Manager WSDL 30 self.smWSDL = 'http://glue.badc.rl.ac.uk/sessionMgr.wsdl' 30 self.smWSDL = './sessionMgr.wsdl' 31 # self.smWSDL = 'http://glue.badc.rl.ac.uk/sessionMgr.wsdl' 31 32 # self.smWSDL = 'http://gabriel.bnsc.rl.ac.uk/sessionMgr.wsdl' 32 33 … … 51 52 52 53 # Attribute Authority client tests 53 #self.aaWSDL = '/home/pjkersha/Development/security/python/Tests/attAuthority.wsdl'54 self.aaWSDL = 'http://glue.badc.rl.ac.uk/attAuthority.wsdl'54 self.aaWSDL = '/home/pjkersha/Development/security/python/Tests/attAuthority.wsdl' 55 # self.aaWSDL = 'http://glue.badc.rl.ac.uk/attAuthority.wsdl' 55 56 # self.aaWSDL = 'http://gabriel.bnsc.rl.ac.uk/attAuthority.wsdl' 56 57 aaPubKeyFilePath = None … … 63 64 self.sessCookie = None 64 65 self.proxyCert = None 65 self.newUserName = 'lawrence' 66 # self.userName = 'gabriel' 67 self.userName = 'lawrence' 66 67 # self.newUserName = 'lawrence' 68 self.newUserName = 'gabriel' 69 70 self.userName = 'gabriel' 71 # self.userName = 'lawrence' 72 68 73 # self.trustedHostRequiredRole = 'acsoe' 69 self.trustedHostRequiredRole = 'coapec' 74 # self.trustedHostRequiredRole = 'coapec' 75 self.trustedHostRequiredRole = 'academic' 70 76 71 77 except Exception, e: -
TI12-security/trunk/python/bin/AttAuthorityServer.py
r1176 r1227 21 21 import sys 22 22 import os 23 import getopt23 import optparse 24 24 25 25 # Web service interface … … 76 76 77 77 78 def usage(): 79 """Describes how to call AttAuthorityServer from the command line""" 80 print "usage: %s " % sys.argv[0].split(os.sep)[-1] 81 print """ 82 [-h | --help] 83 print usage summary 84 85 [-f <properties file path> | --file=<properties file path>] 86 87 [-p <port #> | --port=<port #> 88 specify a port number to override the default 89 90 [-d | --debug] 91 set to stop in debugger on receipt of WS request 92 """ 93 94 95 #_____________________________________________________________________________ 96 if __name__ == '__main__': 97 98 try: 99 opts, args = getopt.getopt(sys.argv[1:], 100 "hf:p:d", 101 ["help", "file=", "port=", "debug"]) 102 except getopt.GetoptError: 103 usage() 104 sys.exit(1) 105 106 107 propFilePath = None 108 109 # Port may be set from an environment variable. Note that this will be 110 # overridden if the port command line argument is set 111 if 'NDG_AA_PORT_NUM' in os.environ: 112 port = int(os.environ['NDG_AA_PORT_NUM']) 113 else: 114 # Default port number 115 port = 5000 116 117 debug = False 118 119 for opt, arg in opts: 120 if opt in ("-h", "--help"): 121 usage() 122 sys.exit(0) 123 124 elif opt in ("-d", "--debug"): 125 debug = True 126 127 elif opt in ("-f", "--file"): 128 propFilePath = arg 129 130 elif opt in ("-p", "--port"): 131 port = int(arg) 132 133 if propFilePath is None: 134 # Check in installation area otherwise assume local directory 135 if 'NDG_DIR' in os.environ: 136 propFileDir = os.path.join(os.environ['NDG_DIR'], "conf") 137 else: 138 propFileDir = "." 139 140 propFilePath = os.path.join(propFileDir, 'attAuthorityProperties.xml') 141 142 143 # Create server instance at start up 144 try: 145 aa = AttAuthority(propFilePath) 146 147 except Exception, e: 148 sys.stderr.write("Initialising Attribute Authority: %s\n" % e) 149 sys.exit(1) 78 #_____________________________________________________________________________ 79 def runInForegnd(): 80 """Run Attribute Authority in the same process as this script""" 150 81 151 82 print "Attribute Authority Server listening..." 152 83 try: 153 AsServer(port= port,154 services= [attAuthority(aa, debug=debug)],84 AsServer(port=options.port, 85 services=(attAuthority(aa, debug=options.debug),), 155 86 RequestHandlerClass=attAuthoritySOAPRequestHandler) 156 87 … … 166 97 sys.stderr.write("Attribute Authority Server: %s\n" % e) 167 98 sys.exit(1) 168 99 100 101 #_____________________________________________________________________________ 102 def fork(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): 103 """Run Attribute Authority in a separate child process 104 105 Thanks to Jorgen Hermann and user contributors for fork code 106 107 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 108 109 """ 110 111 try: 112 pid = os.fork() 113 if pid > 0: 114 # exit first parent 115 sys.exit(0) 116 except OSError, e: 117 print >>sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror) 118 sys.exit(1) 119 120 # Decouple from parent environment 121 os.chdir("/") # Allows for current dir path being renamed or deleted 122 os.setsid() 123 os.umask(0) 124 125 # Redirect standard file descriptors 126 si = file(stdin, 'r') 127 so = file(stdout, 'a+') 128 se = file(stderr, 'a+', 0) 129 130 sys.stdout.flush() 131 sys.stderr.flush() 132 133 os.dup2(si.fileno(), sys.stdin.fileno()) 134 os.dup2(so.fileno(), sys.stdout.fileno()) 135 os.dup2(se.fileno(), sys.stderr.fileno()) 136 137 138 # Do second fork 139 try: 140 pid = os.fork() 141 if pid > 0: 142 # exit from second parent 143 sys.exit(pid) 144 except OSError, e: 145 print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror) 146 sys.exit(1) 147 148 # start the daemon main loop 149 try: 150 AsServer(port=options.port, 151 services=[attAuthority(aa)], 152 RequestHandlerClass=attAuthoritySOAPRequestHandler) 153 154 except socket.error, e: 155 print >>sys.stderr, "Attribute Authority Server socket error: %s" % \ 156 e[1] 157 sys.exit(1) 158 159 except Exception, e: 160 print >>sys.stderr, "Attribute Authority Server: %s" % e 161 sys.exit(1) 162 163 164 #_____________________________________________________________________________ 165 if __name__ == '__main__': 166 167 parser = optparse.OptionParser() 168 169 # Check in installation area otherwise assume local directory 170 if 'NDG_DIR' in os.environ: 171 propFileDir = os.path.join(os.environ['NDG_DIR'], "conf") 172 else: 173 propFileDir = "." 174 175 propFilename = 'attAuthorityProperties.xml' 176 parser.add_option("-f", 177 "--file", 178 dest="propFilePath", 179 default=os.path.join(propFileDir, propFilename), 180 help=\ 181 """properties file path - default is $NDG_DIR/%s or ./%s if NDG_DIR is not 182 set""" % (propFilename, propFilename)) 183 184 185 # Port may be set from an environment variable. Note that this will be 186 # overridden if the port command line argument is set 187 aaPortNumEnvVarName = 'NDG_AA_PORT_NUM' 188 defaultPort = 5000 189 190 initPort = aaPortNumEnvVarName in os.environ and \ 191 int(os.environ[aaPortNumEnvVarName]) or defaultPort 192 193 parser.add_option("-p", 194 "--port", 195 dest="port", 196 default=initPort, 197 type="int", 198 help=\ 199 "specify a port number - default is %d or set environment variable \"%s\"" % \ 200 (defaultPort, aaPortNumEnvVarName)) 201 202 foregndFlags = ("-i", "--foreground") 203 parser.add_option(action="store_true", 204 dest="foregndProc", 205 default=False, 206 help=\ 207 "run server as process in the foreground. If not set, fork a child process", 208 *foregndFlags) 209 210 parser.add_option("-d", 211 "--debug", 212 action="store_true", 213 dest="debug", 214 default=False, 215 help=\ 216 "set to stop in debugger on receipt of WS request. %s flag must be set also"\ 217 % '/'.join(foregndFlags)) 218 219 (options, args) = parser.parse_args() 220 221 # Create server instance at start up 222 try: 223 aa = AttAuthority(options.propFilePath) 224 225 except Exception, e: 226 print >>sys.stderr, "Initialising Attribute Authority: %s" % e 227 sys.exit(1) 228 229 if options.foregndProc: 230 runInForegnd() 231 else: 232 if options.debug: 233 print >>sys.stderr, "%s must be set with debug option" % \ 234 '/'.join(foregndFlags) 235 parser.print_help() 236 sys.exit(1) 237 238 # Run server in child process 239 fork() 240 -
TI12-security/trunk/python/bin/SessionMgrServer.py
r690 r1227 19 19 import sys 20 20 import os 21 import getopt21 import optparse 22 22 23 23 # Web service interface … … 75 75 76 76 #_____________________________________________________________________________ 77 def usage(fp=sys.stdout): 78 """Describes how to call SessionMgrServer from the command line""" 79 fp.write("usage: %s \n" % sys.argv[0].split(os.sep)[-1]) 80 fp.write(""" 81 [-h | --help] 82 print usage summary 83 84 [-f <properties file path> | --file=<properties file path>] 85 86 [-p <port #> | --port=<port #>] 87 port number for server to listen on 88 89 [-d | --debug] 90 set to stop in debugger on receipt of WS request 91 92 [-n | --nopassphrase] 93 skip the prompt for the database pass-phrase. In this case, the 94 pass-phrase must be set in the 'dbURI' tag in the configuration file. 95 96 [-w | --noencrkey] 97 skip the prompt for the encryption key and pick up the key from the 98 'sessMgrEncrKey' tag in the configuration file. 99 """) 77 def runInForegnd(): 78 """Run Session Manager in the same process as this script""" 79 80 print "Session Manager Server listening..." 81 try: 82 AsServer(port=options.port, 83 services=(sessionMgr(sm, debug=options.debug),), 84 RequestHandlerClass=SessionMgrSOAPRequestHandler) 85 86 except KeyboardInterrupt: 87 sys.exit(0) 88 89 except socket.error, e: 90 print >>sys.stderr, "Session Manager Server socket error: %s" % e[1] 91 sys.exit(1) 92 93 except Exception, e: 94 print >>sys.stderr, "Session Manager Server: %s" % e 95 sys.exit(1) 96 97 98 #_____________________________________________________________________________ 99 def fork(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): 100 """Run Session Manager in a separate child process 101 102 Thanks to Jorgen Hermann and user contributors for fork code 103 104 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 105 106 """ 107 108 try: 109 pid = os.fork() 110 if pid > 0: 111 # exit first parent 112 sys.exit(0) 113 except OSError, e: 114 print >>sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror) 115 sys.exit(1) 116 117 # Decouple from parent environment 118 os.chdir("/") # Allows for current dir path being renamed or deleted 119 os.setsid() 120 os.umask(0) 121 122 # Redirect standard file descriptors 123 si = file(stdin, 'r') 124 so = file(stdout, 'a+') 125 se = file(stderr, 'a+', 0) 126 127 sys.stdout.flush() 128 sys.stderr.flush() 129 130 os.dup2(si.fileno(), sys.stdin.fileno()) 131 os.dup2(so.fileno(), sys.stdout.fileno()) 132 os.dup2(se.fileno(), sys.stderr.fileno()) 133 134 135 # Do second fork 136 try: 137 pid = os.fork() 138 if pid > 0: 139 # exit from second parent 140 sys.exit(pid) 141 except OSError, e: 142 print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror) 143 sys.exit(1) 144 145 # start the daemon main loop 146 try: 147 AsServer(port=options.port, 148 services=(sessionMgr(sm),), 149 RequestHandlerClass=SessionMgrSOAPRequestHandler) 150 151 except socket.error, e: 152 print >>sys.stderr, "Session Manager Server socket error: %s" % e[1] 153 sys.exit(1) 154 155 except Exception, e: 156 print >>sys.stderr, "Session Manager Server: %s" % e 157 sys.exit(1) 158 100 159 101 160 #_____________________________________________________________________________ 102 161 if __name__ == '__main__': 103 162 104 try: 105 optLongNames = [ "help", 106 "file=", 107 "port=", 108 "debug", 109 "nopassphrase", 110 "noencrkey"] 111 opts, args = getopt.getopt(sys.argv[1:], "hf:p:dnw", optLongNames) 112 113 except getopt.GetoptError, e: 114 sys.stderr.write("Error: %s\n\n" % e) 115 usage(fp=sys.stderr) 116 sys.exit(1) 117 118 119 propFilePath = None 120 port = 5700 #80 # temporary port for testing 121 debug = False 122 noPPhrase = False 123 noWSDLencrKey = False 124 125 for opt, arg in opts: 126 if opt in ("-h", "--help"): 127 usage() 128 sys.exit(0) 129 130 elif opt in ("-d", "--debug"): 131 debug = True 132 133 elif opt in ("-f", "--file"): 134 propFilePath = arg 135 136 elif opt in ("-p", "--port"): 137 port = int(arg) 138 139 elif opt in ("-n", "--nopassphrase"): 140 noPPhrase = True 141 142 elif opt in ("-w", "--noencrkey"): 143 noWSDLencrKey = True 144 145 else: 146 sys.stderr.write("Option not recognised: %s" % opt) 147 usage(fp=sys.stderr) 148 sys.exit(1) 149 150 151 if propFilePath is None: 152 # Check in installation area otherwise assume local directory 153 if 'NDG_DIR' in os.environ: 154 propFileDir = os.path.join(os.environ['NDG_DIR'], "conf") 155 else: 156 propFileDir = "." 157 158 propFilePath = os.path.join(propFileDir, 'sessionMgrProperties.xml') 159 160 161 if noPPhrase is False: 163 parser = optparse.OptionParser() 164 165 # Check in installation area otherwise assume local directory 166 propFileDir = 'NDG_DIR' in os.environ and \ 167 os.path.join(os.environ['NDG_DIR'], "conf") or "." 168 169 propFilename = 'sessionMgrProperties.xml' 170 parser.add_option("-f", 171 "--file", 172 dest="propFilePath", 173 default=os.path.join(propFileDir, propFilename), 174 help=\ 175 """properties file path - default is $NDG_DIR/%s or ./%s if NDG_DIR is not 176 set""" % (propFilename, propFilename)) 177 178 parser.add_option("-w", 179 "--noencrkey", 180 action="store_true", 181 dest="noWSDLencrKey", 182 default=False, 183 help=\ 184 """skip the prompt for the encryption key and pick up the key from the 185 'sessMgrEncrKey' tag in the properties file.""") 186 187 parser.add_option("-n", 188 "--nopassphrase", 189 action="store_true", 190 dest="noPPhrase", 191 default=False, 192 help=\ 193 """skip the prompt for the database pass-phrase. In this case, the 194 pass-phrase must be set in the 'dbURI' tag in the configuration file.""") 195 196 197 # Port may be set from an environment variable. Note that this will be 198 # overridden if the port command line argument is set 199 smPortNumEnvVarName = 'NDG_SM_PORT_NUM' 200 defaultPort = 5700 201 202 initPort = smPortNumEnvVarName in os.environ and \ 203 int(os.environ[smPortNumEnvVarName]) or defaultPort 204 205 parser.add_option("-p", 206 "--port", 207 dest="port", 208 default=initPort, 209 type="int", 210 help=\ 211 "specify a port number - default is %d or set environment variable \"%s\"" % \ 212 (defaultPort, smPortNumEnvVarName)) 213 214 foregndFlags = ("-i", "--foreground") 215 parser.add_option(action="store_true", 216 dest="foregndProc", 217 default=False, 218 help=\ 219 "run server as process in the foreground. If not set, fork a child process", 220 *foregndFlags) 221 222 parser.add_option("-d", 223 "--debug", 224 action="store_true", 225 dest="debug", 226 default=False, 227 help=\ 228 "set to stop in debugger on receipt of WS request. %s flag must be set also"\ 229 % '/'.join(foregndFlags)) 230 231 (options, args) = parser.parse_args() 232 233 234 if options.noPPhrase is False: 162 235 import getpass 163 236 try: … … 170 243 171 244 172 if noWSDLencrKey is False:245 if options.noWSDLencrKey is False: 173 246 import getpass 174 247 try: … … 181 254 182 255 # Create server instance at start up 183 # import pdb184 # pdb.set_trace()185 256 try: 186 sm = SessionMgr( propFilePath,257 sm = SessionMgr(options.propFilePath, 187 258 credReposPPhrase=credReposPPhrase, 188 259 sessMgrEncrKey=sessMgrEncrKey) 189 260 190 261 except Exception, e: 191 sys.stderr.write("Initialising Session Manager: %s\n" % e) 192 sys.exit(1) 193 194 print "Session Manager Server listening..." 195 try: 196 AsServer(port=port, 197 services=(sessionMgr(sm, debug=debug),), 198 RequestHandlerClass=SessionMgrSOAPRequestHandler) 199 200 except KeyboardInterrupt: 201 sys.exit(0) 202 203 except socket.error, e: 204 sys.stderr.write("Session Manager Server socket error: %s\n" % \ 205 e[1]) 206 sys.exit(1) 207 208 except Exception, e: 209 sys.stderr.write("Session Manager Server: %s\n" % e) 210 sys.exit(1) 211 212 262 print >>sys.stderr, "Initialising Session Manager: %s" % e 263 sys.exit(1) 264 265 266 if options.foregndProc: 267 runInForegnd() 268 else: 269 if options.debug: 270 print >>sys.stderr, "%s must be set with debug option" % \ 271 '/'.join(foregndFlags) 272 parser.print_help() 273 sys.exit(1) 274 275 # Run server in child process 276 fork() 277 -
TI12-security/trunk/python/ndgSetup.sh
r941 r1227 36 36 37 37 38 39 38 # NDG Custom Python installation 40 39 if [ ! `echo ${PATH} | grep "${NDG_DIR}/<Python location>"` ]; then … … 42 41 export PATH=${NDG_DIR}/<Python location>:$PATH 43 42 fi 43 44 45 # Override default Attribute Authority and Session Manager port number 46 # settings 47 #export NDG_AA_PORT_NUM=5001 48 #export NDG_SM_PORT_NUM= 49 44 50 45 51 # Globus Toolkit and MyProxy Server
Note: See TracChangeset
for help on using the changeset viewer.