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 print>>sys.stderr, " \r\n \t LDAP : ! hrn ldapentry[1]['uid'][0]%s " %(ldapentry[1]['uid'][0])
73 tmpname = ldapentry[1]['uid'][0]
75 if ldapentry[1]['uid'][0] == "savakian":
78 hrn=self.authname+"."+ tmpname
83 # RSA_KEY_STRING=ldapentry[1]['sshPublicKey'][0]
85 # pkey=convert_public_key(RSA_KEY_STRING)
87 # gid=self.senslabauth.create_gid("urn:publicid:IDN+"+self.authname+"+user+"+ldapentry[1]['uid'][0], uuid, pkey, CA=False)
89 parent_hrn = get_authority(hrn)
90 parent_auth_info = self.senslabauth.get_auth_info(parent_hrn)
94 'pkey': ldapentry[1]['sshPublicKey'][0],
95 #'uid': ldapentry[1]['uid'][0],
97 'email': ldapentry[1]['mail'][0],
98 'first_name': ldapentry[1]['givenName'][0],
99 'last_name': ldapentry[1]['sn'][0],
102 'authority': self.authname,
103 'peer_authority': '',