5 from sfa.util.config import *
6 from sfa.trust.gid import *
7 from sfa.trust.hierarchy import *
8 from sfa.trust.auth import *
9 from sfa.trust.certificate import *
12 def __init__(self, record_filter = None):
13 self.ldapserv=ldap.open("192.168.0.251")
14 self.senslabauth=Hierarchy()
16 self.authname=config.SFA_REGISTRY_ROOT_AUTH
17 authinfo=self.senslabauth.get_auth_info(self.authname)
20 gid=authinfo.get_gid_object()
22 def ldapFind(self, record_filter = None, columns=None):
26 if 'authority' in record_filter:
28 if record_filter['authority']==self.authname:
29 # which is SFA_REGISTRY_ROOT_AUTH
30 # request all records which are under our authority, ie all ldap entries
33 #which is NOT SFA_REGISTRY_ROOT_AUTH
36 if not 'hrn' in record_filter:
37 print >>sys.stderr,"find : don't know how to handle filter ",record_filter
41 h=record_filter['hrn']
42 if isinstance(h,list):
49 splited_hrn=hrn.split(".")
50 if splited_hrn[0] != self.authname :
51 print >>sys.stderr,"i know nothing about",hrn
60 rindex=self.ldapserv.search("ou=people,dc=senslab,dc=info",ldap.SCOPE_SUBTREE,ldapfilter, ['mail','givenName', 'sn', 'uid','sshPublicKey'])
61 ldapresponse=self.ldapserv.result(rindex,1)
62 for ldapentry in ldapresponse[1]:
63 hrn=self.authname+"."+ldapentry[1]['uid'][0]
66 RSA_KEY_STRING=ldapentry[1]['sshPublicKey'][0]
68 pkey=convert_public_key(RSA_KEY_STRING)
70 gid=self.senslabauth.create_gid("urn:publicid:IDN+"+self.authname+"+user+"+ldapentry[1]['uid'][0], uuid, pkey, CA=False)
72 parent_hrn = get_authority(hrn)
73 parent_auth_info = self.senslabauth.get_auth_info(parent_hrn)
77 # 'email': ldapentry[1]['mail'][0],
78 # 'first_name': ldapentry[1]['givenName'][0],
79 # 'last_name': ldapentry[1]['sn'][0],
81 'gid': gid.save_to_string(),
83 'authority': self.authname,
87 'date_created' : 'none',
88 'last_updated': 'none'