Changeset e062282 for fedd/federation
- Timestamp:
- Jul 7, 2012 5:42:28 PM (12 years ago)
- Branches:
- compt_changes, master
- Children:
- 7718539
- Parents:
- cd5b279 (diff), d064566 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- fedd/federation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/authorizer.py
rcd5b279 re062282 21 21 import os, os.path 22 22 import re 23 import fcntl 23 24 24 25 class authorizer_base: … … 208 209 class bad_cert_error(RuntimeError): pass 209 210 210 def __init__(self, certs=None, me=None, key=None, load=None, save=None): 211 def __init__(self, certs=None, me=None, key=None, load=None, save=None, 212 update=None): 211 213 self.creddy_id = None 212 214 self.globals = set() … … 215 217 self.save_dir = load or save 216 218 self.local_files = False 219 self.update_dir = os.path.abspath(update) 217 220 if self.save_dir: 218 221 self.save_dir = os.path.abspath(self.save_dir) … … 648 651 return found 649 652 653 def update(self): 654 rv = False 655 if update_dir is None: return True 656 lf = None 657 files = [] 658 try: 659 lf = open('%s/lock' % self.update_dir, 'r') 660 except EnvironmentError, e: 661 return rv 662 try: 663 fcntl.flock(lf, fcntl.LOCK_EX) 664 files = os.listdir(update_dir) 665 rv = self.import_credentials(file_list=files) 666 try: 667 for fn in files: 668 os.remove(fn) 669 except EnvironmentError, e: 670 # failure to clear the update directory is no biggie 671 pass 672 rv = True 673 finally: 674 fcntl.flock(fl, fcntl.LOCK_UN) 675 return rv 676 677 678 679 650 680 def __str__(self): 651 681 -
fedd/federation/client_lib.py
rd064566 re062282 59 59 def log_authentication(fn, action, outcome, proof): 60 60 f = open(fn, 'a') 61 print >>f, ' %s %s at %s' % (action, outcome, datetime.now())61 print >>f, '<comment>%s %s at %s</comment>' % (action, outcome, datetime.now()) 62 62 if isinstance(proof, list): 63 63 for p in proof: -
fedd/federation/proof.py
rd064566 re062282 3 3 4 4 import ABAC 5 import Creddy 5 6 import sys 6 7 import os, os.path … … 9 10 from base64 import b64encode, b64decode 10 11 from xml.parsers.expat import ParserCreate 12 from tempfile import mkdtemp 13 from shutil import rmtree 11 14 12 15 class proof: … … 29 32 ids = set([c.issuer_cert() for c in self.creds]) 30 33 attrs = set([c.attribute_cert() for c in self.creds]) 31 return list(ids) + list(attrs) 34 out_ids = [] 35 d = mkdtemp() 36 for i, c in enumerate(ids): 37 try: 38 der_name = os.path.join(d, 'file%04d.der' % i) 39 pem_name = os.path.join(d, 'file%04d.pem' % i) 40 f = open(der_name, 'w') 41 f.write(c) 42 f.close() 43 44 cid = Creddy.ID(der_name) 45 46 tf = open(pem_name, 'w') 47 cid.write_cert(tf) 48 tf.close() 49 tf = open(pem_name, 'r') 50 out_ids.append(tf.read()) 51 tf.close() 52 except EnvironmentError, e: 53 print "Certs to creds Error: %s" % e 54 pass 55 rmtree(d) 56 57 return out_ids + list(attrs) 32 58 33 59 def __str__(self):
Note: See TracChangeset
for help on using the changeset viewer.