Uranium
Application Framework
UM.Trust.Trust Class Reference

Public Member Functions

def getInstance (cls)
 
def getInstanceOrNone (cls)
 
None __init__ (self, str public_key_filename, Callable[[str], None] pre_err_handler=None)
 
bool signedFolderCheck (self, str path)
 
bool signedFileCheck (self, str filename)
 

Static Public Member Functions

str getPublicRootKeyPath ()
 
bool signatureFileExistsFor (str filename)
 

Detailed Description

Trust for use in the main-application code, as opposed to the (keygen/signing) scripts.

Can be seen as an elaborate wrapper around a public-key.
Currently used as a singleton, as we currently have only one single 'master' public key for the entire app.
See the 'createkeypair.py', 'signfile.py' and 'signfolder.py' scripts in the 'scripts' folder.

Constructor & Destructor Documentation

◆ __init__()

None UM.Trust.Trust.__init__ (   self,
str  public_key_filename,
Callable[[str], None]   pre_err_handler = None 
)
Initializes a Trust object. A Trust object represents a public key and related utility methods on that key.
If the application only has a single public key, it's best to use 'getInstance' or 'getInstanceOrNone'.

:param public_key_filename: Path to the file that holds the public key.
:param pre_err_handler: An extra error handler which will be called before TrustBasics.defaultViolationHandler
                Receives a human readable error string as argument.
:raise Exception: if public key file provided by the argument can't be found or parsed.

Member Function Documentation

◆ getInstance()

def UM.Trust.Trust.getInstance (   cls)
Get the 'canonical' Trusts object for this application. See also 'getPublicRootKeyPath'.

:raise Exception: if the public key in `getPublicRootKeyPath()` can't be loaded for some reason.
:return: The Trust singleton.

◆ getInstanceOrNone()

def UM.Trust.Trust.getInstanceOrNone (   cls)
Get the  'canonical' Trust object or None if not initialized yet

Useful if only _optional_ verification is needed.

:return: Trust singleton or None if problems occurred with loading the public key in `getPublicRootKeyPath()`.

◆ getPublicRootKeyPath()

str UM.Trust.Trust.getPublicRootKeyPath ( )
static
It is assumed that the application will have a 'master' public key.

:return: Path to the 'master' public key of this application.

◆ signatureFileExistsFor()

bool UM.Trust.Trust.signatureFileExistsFor ( str  filename)
static
Whether or not a signature file _exist_ (so _not_ necessarily correct)  for the provided (single file) path.

:param filename: The filename that should be checked for.
:return: Returns True if there is a signature file next to the provided single file (as opposed to folder).

◆ signedFileCheck()

bool UM.Trust.Trust.signedFileCheck (   self,
str  filename 
)
In the 'single signed file' case, check whether a file is signed according to the Trust-objects' public key.

:param filename: The path to the file to be checked (not the signature-file).
:return: True if the file is signed (is next to a signature file) and signed correctly.

◆ signedFolderCheck()

bool UM.Trust.Trust.signedFolderCheck (   self,
str  path 
)
In the 'singed folder' case, check whether the folder is signed according to the Trust-objects' public key.

:param path: The path to the folder to be checked (not the signature-file).
:return: True if the folder is signed (contains a signatures-file) and signed correctly.

The documentation for this class was generated from the following file: