Changeset dee164e for fedd/federation/authorizer.py
- Timestamp:
- Nov 30, 2010 7:20:16 PM (13 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master
- Children:
- c324ad3
- Parents:
- 4692a16
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/authorizer.py
r4692a16 rdee164e 6 6 from threading import Lock 7 7 8 from string import join 8 from string import join, hexdigits 9 9 10 10 from fedid import fedid … … 240 240 return abac_authorizer.clean_attr_re.sub('_', attr) 241 241 242 242 243 def import_credentials(self, file_list=None, data_list=None): 243 244 if data_list: … … 272 273 if not isinstance(attr, basestring): 273 274 attr = "%s" % attr 275 274 276 if self.me and self.key: 275 277 # Create a credential and insert it into context … … 338 340 self.lock.release() 339 341 342 @staticmethod 343 def starts_with_fedid(attr): 344 """ 345 Return true if the first 40 characters of the string are hex digits 346 followed by a dot. False otherwise. Used in check_attribute. 347 """ 348 if attr.find('.') == 40: 349 return all([ x in hexdigits for x in attr[0:40]]) 350 else: 351 return False 352 340 353 341 354 def check_attribute(self, name, attr): … … 348 361 if not isinstance(attr, basestring): 349 362 attr = "%s" % attr 350 # Naked attributes are attested by this principal351 if attr.find('.') == -1:352 a = "%s.%s" % (self.fedid, self.clean_attr(attr))353 else:363 # Attributes that start with a fedid only have the part of the 364 # attribute after the dot cleaned. Others are completely cleaned 365 # and have the owner fedid attached. 366 if self.starts_with_fedid(attr): 354 367 r, a = attr.split('.',1) 355 368 a = "%s.%s" % ( r, self.clean_attr(a)) 369 else: 370 a = "%s.%s" % (self.fedid, self.clean_attr(attr)) 371 372 a = str(a) 373 n = str("%s" % name) 356 374 357 375 self.lock.acquire() 358 rv, proof = self.context.query(a, "%s" % name) 376 # Sigh. Unicode vs swig and swig seems to lose. Make sure 377 # everything we pass into ABAC is a str not a unicode. 378 rv, proof = self.context.query(a, n) 359 379 # XXX delete soon 360 380 if not rv and attr in self.globals: rv = True
Note: See TracChangeset
for help on using the changeset viewer.