renamed source file trust/trustedroot.py into trust/trustedroots.py
[sfa.git] / sfa / trust / trustedroots.py
diff --git a/sfa/trust/trustedroots.py b/sfa/trust/trustedroots.py
new file mode 100644 (file)
index 0000000..65b97fa
--- /dev/null
@@ -0,0 +1,27 @@
+import os.path
+import glob
+
+from sfa.trust.gid import GID
+
+class TrustedRootList:
+    def __init__(self, dir):
+        self.basedir = dir
+        # create the directory to hold the files, if not existing
+        if not os.path.isdir (self.basedir):
+            os.makedirs(self.basedir)
+
+    def add_gid(self, gid):
+        fn = os.path.join(self.basedir, gid.get_hrn() + ".gid")
+        gid.save_to_file(fn)
+
+    def get_list(self):
+        gid_list = [GID(filename=cert_file) for cert_file in self.get_file_list()]
+        return gid_list
+
+    def get_file_list(self):
+        file_list  = []
+        pattern=os.path.join(self.basedir,"*.gid")
+        for cert_file in glob.glob(pattern):
+            if os.path.isfile(cert_file):
+                file_list.append(cert_file) 
+        return file_list