123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- from pwman.util.crypto_engine import CryptoEngine
- __DB_FORMAT__ = 0.5
- class DatabaseException(Exception):
- pass
- class Database(object):
- def __init__(self, dbver=None):
- self._filtertags = []
- self.dbver = dbver
- def open(self, dbver=None):
- """
- Open the database, by calling the _open method of the
- class inherited for the specific database.
- When done validation that the file is OK, check if it has
- encryption key, by calling
- enc = CryptoEngine.get()
- key = self.loadkey()
- """
- self._open()
- enc = CryptoEngine.get(dbver=dbver)
- key = self.loadkey()
- if key is not None:
- enc.set_cryptedkey(key)
- else:
- self.get_user_password()
- def close(self):
- pass
- def get_user_password(self):
- """
- get the databases password from the user
- """
- enc = CryptoEngine.get()
- newkey = enc.changepassword()
- return self.savekey(newkey)
- def changepassword(self):
- """
- Change the databases password.
- """
-
-
-
-
-
-
-
- def listtags(self, all=False):
- pass
- def currenttags(self):
- return self._filtertags
- def filter(self, tags):
- for tag in tags:
- if not (tag in self._filtertags):
- self._filtertags.append(tag)
- def clearfilter(self):
- self._filtertags = []
-
-
- def addnodes(self, nodes):
- pass
- def editnode(self, id, node):
- pass
- def removenodes(self, nodes):
- pass
-
-
- def savekey(self, key):
- pass
- def loadkey(self):
- pass
|