use self.get_auth_info
[sfa.git] / sfa / trust / trustedroot.py
1 ### $Id$
2 ### $URL$
3
4 import os
5
6 from sfa.trust.gid import *
7 from sfa.util.config import Config
8
9 class TrustedRootList():
10     def __init__(self, dir=None):
11         if not dir:
12             config = Config()
13             dir = config.config_path + os.sep + 'trusted_roots'
14         self.basedir = dir
15         
16         # create the directory to hold the files
17         try:
18             os.makedirs(self.basedir)
19         # if the path already exists then pass
20         except OSError, (errno, strerr):
21             if errno == 17:
22                 pass
23
24     def add_gid(self, gid):
25         fn = os.path.join(self.basedir, gid.get_hrn() + ".gid")
26
27         gid.save_to_file(fn)
28
29     def get_list(self):
30         gid_list = []
31
32         file_list = os.listdir(self.basedir)
33         for gid_file in file_list:
34             fn = os.path.join(self.basedir, gid_file)
35             if os.path.isfile(fn):
36                 gid = GID(filename = fn)
37                 gid_list.append(gid)
38
39         return gid_list
40