source: fedd/init_abac_authorizer.py @ ac15159

axis_examplecompt_changesinfo-ops
Last change on this file since ac15159 was c573278, checked in by Ted Faber <faber@…>, 14 years ago

Checkpoint. Still lots to do

  • Property mode set to 100755
File size: 1.2 KB
RevLine 
[71461a4]1#!/usr/local/bin/python
2
[353db8c]3import sys
[c573278]4import os, os.path
[353db8c]5
[71461a4]6from optparse import OptionParser
7from federation.authorizer import abac_authorizer
8
9class Parser(OptionParser):
10    def __init__(self):
[547aa3b]11        OptionParser.__init__(self, usage='%prog [options]')
[71461a4]12        self.add_option('--cert', dest='cert', help='Identity certificate')
13        self.add_option('--key', dest='key', help='Identity key')
14        self.add_option('--policy', dest='policy', 
15                help='ABAC policy certificates')
16        self.add_option('--dir', dest='out_dir', help='directory to save into')
17
18parser = Parser()
19opts, args = parser.parse_args()
20
[353db8c]21if any([ not x for x in (opts.cert, opts.policy, opts.out_dir)]):
[71461a4]22    parser.print_help()
23    sys.exit(1)
[c573278]24
25try:
26    for path, dirs, files in os.walk(opts.out_dir, topdown=False):
27        for f in files: os.unlink(os.path.join(path, f))
28        for d in dirs: os.rmdir(os.path.join(path, d))
29except EnvironmentError, e:
30    sys.exit("Can't remove %s: %s" % ( e.filename, e.strerror))
31
[353db8c]32try:
33    a = abac_authorizer(key=opts.key, me=opts.cert, certs=opts.policy,
34            save=opts.out_dir)
35    a.save(opts.out_dir)
36except EnvironmentError, e:
37    sys.exit("Can't create or write %s: %s" % (e.filename, e.strerror))
[6e63513]38except abac_authorizer.bad_cert_error, e:
[353db8c]39    sys.exit("Error creating authorizer: %s" % e)
Note: See TracBrowser for help on using the repository browser.