Changeset 67fa1cf for fedd/federation


Ignore:
Timestamp:
May 30, 2013 3:53:29 PM (11 years ago)
Author:
Ted Faber <faber@…>
Branches:
master
Children:
1f9c361, b213b53
Parents:
e8f2d4c
Message:

MOve over to ABAC 0.1.4

Location:
fedd/federation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/authorizer.py

    re8f2d4c r67fa1cf  
    1515
    1616import ABAC
    17 import Creddy
    1817import pickle
    1918
     
    258257
    259258        for dir in certs or []:
    260             self.context.load_directory(dir)
     259            self.resilient_load_directory(dir)
    261260
    262261        if load:
     
    266265        self.creddy_id = None
    267266        try:
    268             self.creddy_id = Creddy.ID(self.me)
     267            self.creddy_id = ABAC.ID(self.me)
    269268        except:
    270269            raise abac_authorizer.bad_cert_error('Cannot load cert %s' \
     
    277276            raise abac_authorized_bad_cert_error('Cannot load key %s' \
    278277                    % self.key)
     278
     279    def resilient_load_directory(self, dirname):
     280        '''
     281        ABAC.Context.load_directory has foolish arbitrary filename
     282        distinctions.  This tries to load the contents of dirname into the
     283        authorizer's context first as IDs and then any that fail as attributes.
     284        '''
     285        files = os.listdir(dirname)
     286        attrs = []
     287        for f in files:
     288            p = os.path.join(dirname, f)
     289            if not os.path.isfile(p): continue
     290            if self.context.load_id_file(p) != ABAC.ABAC_CERT_SUCCESS:
     291                attrs.append(p)
     292        for p in attrs:
     293            self.context.load_attribute_file(p)
    279294
    280295
     
    318333            if data_list is None: data_list = []
    319334            for fn in file_list:
    320                 # Try to parse file as a Creddy ID, so we can import PEM files
     335                # Try to parse file as a ABAC ID, so we can import PEM files
    321336                try:
    322                     cid = Creddy.ID(fn)
     337                    cid = ABAC.ID(fn)
    323338                    data_list.append(cid.cert_chunk())
    324339                    continue
     
    379394                # This will simplify when we have libcreddy
    380395                try:
    381                     attrcert = Creddy.Attribute(self.creddy_id,
     396                    attrcert = ABAC.Attribute(self.creddy_id,
    382397                            self.clean_attr(attr), 3600 * 24 * 365 * 10)
    383398                    attrcert.principal("%s" % name)
     
    575590                attr = c.attribute_cert()
    576591                # NB: file naming conventions matter here.  The trailing_ID and
    577                 # _attr are required by ABAC.COntext.load_directory()
     592                # _attr are required by ABAC.Context.load_directory().  We use
     593                # resilient_load_directory now, but no sense pulling these out
     594                # now.
    578595                if id and id not in seenid:
    579                     f = open("%s/certs/ID_%05d_ID.der" % (dir, ii), "w")
     596                    f = open("%s/certs/ID_%05d_ID.xml" % (dir, ii), "w")
    580597                    f.write(id)
    581598                    f.close()
     
    583600                    seenid.add(id)
    584601                if attr and attr not in seenattr:
    585                     f = open("%s/certs/attr_%05d_attr.der" % (dir, ai), "w")
     602                    f = open("%s/certs/attr_%05d_attr.xml" % (dir, ai), "w")
    586603                    f.write(attr)
    587604                    f.close()
     
    620637                if self.key:
    621638                    self.init_libcreddy_id()
    622             self.context.load_directory("%s/certs" % dir)
     639            self.resilient_load_directory("%s/certs" % dir)
    623640            self.save_dir = dir
    624641        except EnvironmentError, e:
  • fedd/federation/proof.py

    re8f2d4c r67fa1cf  
    33
    44import ABAC
    5 import Creddy
    65import sys
    76import os, os.path
     
    4342                f.close()
    4443
    45                 cid = Creddy.ID(der_name)
     44                cid = ABAC.ID(der_name)
    4645
    4746                tf = open(pem_name, 'w')
Note: See TracChangeset for help on using the changeset viewer.