Home | Trees | Indices | Help |
---|
|
1 ################################################################################ 2 # Ganga Project. http://cern.ch/ganga 3 # 4 # $Id: __init__.py,v 1.1 2008-07-17 16:40:53 moscicki Exp $ 5 ################################################################################ 6 # File: Credentials/__init__.py 7 # Author: K.Harrison 8 # Created: 060613 9 # 10 # 08/08/2006 KH: Added getCredential() function 11 # 12 # 28/08/2006 KH: Don't determine available credentials from allPlugins, 13 # as credential plugins are now defined as hidden 14 # 15 # 31/08/2006 KH: Corrections to getCredential() function to create 16 # only a single instance of each credential type 17 # 18 # 23/11/2006 KH: Added check on credential availability with 19 # system/configuration used 20 # 21 # 25/09/2007 KH: Changes for compatibility with multi-proxy handling 22 # => "middleware" argument added to getCredential function 23 # 24 # 02/11/2007 KH: Added argument to getCredential() function to allow 25 # or supress creation of new credential 26 27 """Initialisation file for the Credentials package, 28 containing classes for working with different types of credential.""" 29 30 __author__ = "K.Harrison <Harrison@hep.phy.cam.ac.uk>" 31 __date__ = "25 September 2007" 32 __version__ = "1.5" 33 34 from AfsToken import AfsToken 35 from Ganga.Utility.logging import getLogger 36 from Ganga.Utility.Plugin import allPlugins 37 from GridProxy import GridProxy 38 39 _credentialPlugins = {} 40 for item in locals().keys(): 41 if ( ( hasattr( locals()[ item ], "_category" ) )\ 42 and ( hasattr( locals()[ item ], "_name" ) ) ): 43 _category = getattr( locals()[ item ], "_category" ) 44 if "credentials" == _category: 45 _name = getattr( locals()[ item ], "_name" ) 46 _credentialPlugins[ _name ] = locals()[ item ] 47 del _name 48 del _category 49 50 _allCredentials = {} 51 _voidCredentials = {} 52 53 logger = getLogger() 5456 57 """ 58 Function to return credential object of requested type 59 60 Arguments: 61 middleware - String specifying any middleware used with credential 62 name - String specifying credential type 63 create - Boole specifying: 64 True - requested credential should be created if 65 it doesn't exist 66 False - no new credential should be created 67 68 Return value: Credential object of requested type if it exists or 69 can be created, or False otherwise 70 """ 71 72 # if name in allPlugins.allClasses( "credentials" ).keys(): 73 # if not name in _allCredentials.keys(): 74 # _allCredentials[ name ] = \ 75 # allPlugins.find( "credentials", name )._proxyClass() 76 if name in _credentialPlugins.keys(): 77 if ( not name in _allCredentials.keys() ) and \ 78 ( not name in _voidCredentials.keys() ) and \ 79 ( create is True ): 80 credential = _credentialPlugins[ name ]( middleware ) 81 if credential.isAvailable(): 82 _allCredentials[ name ] = credential 83 else: 84 _voidCredentials[ name ] = credential 85 else: 86 logger.warning( "Credential type '%s' not known" % str( name ) ) 87 logger.warning( "Returning False" ) 88 89 if name in _allCredentials.keys(): 90 credential = _allCredentials[ name ] 91 else: 92 credential = False 93 94 return credential95
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Jun 25 10:35:40 2012 | http://epydoc.sourceforge.net |