Changeset cd5b279 for fedd


Ignore:
Timestamp:
Jul 5, 2012 3:44:51 PM (7 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, master
Children:
e062282
Parents:
311ece3
Message:

Output IDs in pem for other tools

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/proof.py

    re83f2f2 rcd5b279  
    33
    44import ABAC
     5import Creddy
    56import sys
    67import os, os.path
     
    910from base64 import b64encode, b64decode
    1011from xml.parsers.expat import ParserCreate
     12from tempfile import mkdtemp
     13from shutil import rmtree
    1114
    1215class proof:
     
    2932        ids = set([c.issuer_cert() for c in self.creds])
    3033        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)
    3258
    3359    def __str__(self):
Note: See TracChangeset for help on using the changeset viewer.