Ignore:
Timestamp:
Sep 23, 2010 5:44:47 PM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master
Children:
835cf55
Parents:
09b1e9d
Message:

checkpoint: new works pretty well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/client_lib.py

    r09b1e9d r7206e5a  
    8080        self.errstr = errstr
    8181
     82class CertificateMismatchError(RuntimeError): pass
     83
    8284
    8385def get_user_cert():
     
    9799                if os.path.isfile("%s/%s" % (dir,p))]:
    98100            f = open(fn, 'r')
    99             rv.append(join(f))
     101            rv.append(f.read())
    100102            f.close()
    101103    return rv
     
    138140    return (cert, fid, url)
    139141
    140 def save_certfile(out_certfile, ea):
     142def save_certfile(out_certfile, ea, check_cert=None):
    141143    """
    142144    if the experiment authority section in ea has a certificate and the
    143145    out_certfile parameter has a place to put it, save the cert to the file.
    144     EnvronnemtError s can come from the file operations.
     146    EnvronmentError s can come from the file operations.  If check_cert is
     147    given, the certificate in ea is compared with it and if they are not equal,
     148    a CertificateMismatchError is raised.
    145149    """
    146150    if out_certfile and ea and 'X509' in ea:
     151        out_cert = ea['X509']
     152        if check_cert and check_cert != out_cert:
     153            raise CertificateMismatchError()
    147154        f = open(out_certfile, "w")
    148         print >>f, ea['X509']
     155        f.write(out_cert)
    149156        f.close()
    150157
Note: See TracChangeset for help on using the changeset viewer.