- Timestamp:
- Sep 19, 2011 2:50:32 PM (13 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- 52131d3
- Parents:
- 4157521
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/access_to_abac.py
r4157521 rcd360a0 9 9 from optparse import OptionParser, OptionValueError 10 10 from tempfile import mkdtemp 11 12 import Creddy 11 13 12 14 from federation.fedid import fedid … … 289 291 creddy='/usr/local/bin/creddy'): 290 292 ''' 291 Make the creddy calls to createthe attributes from the list of credential293 Make the the attributes from the list of credential 292 294 objects in the creds parameter. 293 295 ''' 294 def attrs(r):295 '''296 Convert an attribute into creddy --subject-id and --subject-role297 parameters298 '''299 if r.principal and r.link and r.attr:300 return ['--subject-id=%s' % r.principal,301 '--subject-role=%s.%s' % (r.attr, r.link),302 ]303 elif r.principal and r.attr:304 return ['--subject-id=%s' % r.principal,305 '--subject-role=%s' %r.attr]306 elif r.principal:307 return ['--subject-id=%s' % r.prinicpal]308 else:309 raise parse_error('Attribute without a principal?')310 311 # main line of create_creds312 296 for i, c in enumerate(creds): 313 cmd = [creddy, '--attribute', '--issuer=%s' % cert, '--key=%s' % key, 314 '--role=%s' % c.attr, '--out=%s/cred%d_attr.der' % (dir, i)] 297 cid = Creddy.ID(cert) 298 cid.load_privkey(key) 299 cattr = Creddy.Attribute(cid, c.attr, 3600 * 24 * 365 * 10) 315 300 for r in c.req: 316 cmd.extend(attrs(r)) 317 if debug: 318 print join(cmd) 319 else: 320 rv = subprocess.call(cmd) 321 if rv != 0: 322 raise credential_error("%s: %d" % (join(cmd), rv)) 301 if r.principal and r.link and r.attr: 302 cattr.linking_role(r.principal, r.attr, r.link) 303 elif r.principal and r.attr: 304 cattr.role(r.principal, r.attr) 305 elif r.principal: 306 cattr.principal(r.principal) 307 else: 308 raise parse_error('Attribute without a principal?') 309 cattr.bake() 310 cattr.write_name('%s/cred%d_attr.der' % (dir, i)) 323 311 324 312 def clear_dir(dir):
Note: See TracChangeset
for help on using the changeset viewer.