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()
21 self.ldapdictlist = ['type',
30 def ldapFind(self, record_filter = None, columns=None):
34 if 'authority' in record_filter:
36 if record_filter['authority']==self.authname:
37 # which is SFA_REGISTRY_ROOT_AUTH
38 # request all records which are under our authority, ie all ldap entries
41 #which is NOT SFA_REGISTRY_ROOT_AUTH
44 if not 'hrn' in record_filter:
45 print >>sys.stderr,"find : don't know how to handle filter ",record_filter
49 h=record_filter['hrn']
50 if isinstance(h,list):
57 splited_hrn=hrn.split(".")
58 if splited_hrn[0] != self.authname :
59 print >>sys.stderr,"i know nothing about",hrn, " my authname is ", self.authname, " not ", splited_hrn[0]
68 rindex=self.ldapserv.search("ou=people,dc=senslab,dc=info",ldap.SCOPE_SUBTREE,ldapfilter, ['mail','givenName', 'sn', 'uid','sshPublicKey'])
69 ldapresponse=self.ldapserv.result(rindex,1)
70 for ldapentry in ldapresponse[1]:
71 hrn=self.authname+"."+ldapentry[1]['uid'][0]
74 # RSA_KEY_STRING=ldapentry[1]['sshPublicKey'][0]
76 # pkey=convert_public_key(RSA_KEY_STRING)
78 # gid=self.senslabauth.create_gid("urn:publicid:IDN+"+self.authname+"+user+"+ldapentry[1]['uid'][0], uuid, pkey, CA=False)
80 parent_hrn = get_authority(hrn)
81 parent_auth_info = self.senslabauth.get_auth_info(parent_hrn)
85 'pkey': ldapentry[1]['sshPublicKey'][0],
86 'uid': ldapentry[1]['uid'][0],
87 'email': ldapentry[1]['mail'][0],
88 'first_name': ldapentry[1]['givenName'][0],
89 'last_name': ldapentry[1]['sn'][0],
92 'authority': self.authname,