Beispiel #1
0
 def _check_install(self):
     """
     Return True if Private Key and local identity files exists and both is
     valid.
     """
     if _Debug:
         lg.out(_DebugLevel, 'initializer._check_install')
     from userid import identity
     from crypt import key
     keyfilename = settings.KeyFileName()
     keyfilenamelocation = settings.KeyFileNameLocation()
     if os.path.exists(keyfilenamelocation):
         keyfilename = bpio.ReadTextFile(keyfilenamelocation)
         if not os.path.exists(keyfilename):
             keyfilename = settings.KeyFileName()
     idfilename = settings.LocalIdentityFilename()
     if not os.path.exists(keyfilename) or not os.path.exists(idfilename):
         if _Debug:
             lg.out(_DebugLevel, 'initializer._check_install local key or local id not exists')
         return False
     current_key = bpio.ReadTextFile(keyfilename)
     current_id = bpio.ReadTextFile(idfilename)
     if not current_id:
         if _Debug:
             lg.out(_DebugLevel, 'initializer._check_install local identity is empty ')
         return False
     if not current_key:
         if _Debug:
             lg.out(_DebugLevel, 'initializer._check_install private key is empty ')
         return False
     try:
         key.InitMyKey()
     except:
         if _Debug:
             lg.out(_DebugLevel, 'initializer._check_install fail loading private key ')
         return False
     try:
         ident = identity.identity(xmlsrc=current_id)
     except:
         if _Debug:
             lg.out(_DebugLevel, 'initializer._check_install fail init local identity ')
         return False
     if not ident.isCorrect():
         lg.err('local identity is not correct !!!')
         return False
     try:
         res = ident.Valid()
     except:
         if _Debug:
             lg.out(_DebugLevel, 'failed to validate local identity')
         return False
     if not res:
         lg.err('local identity is not valid !!!')
         return False
     if _Debug:
         lg.out(_DebugLevel, 'initializer._check_install SUCCESS!!!')
     return True
Beispiel #2
0
 def _check_install(self):
     """
     Return True if Private Key and local identity files exists and both is
     valid.
     """
     lg.out(2, 'initializer._check_install')
     from userid import identity
     from crypt import key
     keyfilename = settings.KeyFileName()
     keyfilenamelocation = settings.KeyFileNameLocation()
     if os.path.exists(keyfilenamelocation):
         keyfilename = bpio.ReadTextFile(keyfilenamelocation)
         if not os.path.exists(keyfilename):
             keyfilename = settings.KeyFileName()
     idfilename = settings.LocalIdentityFilename()
     if not os.path.exists(keyfilename) or not os.path.exists(idfilename):
         lg.out(
             2,
             'initializer._check_install local key or local id not exists')
         return False
     current_key = bpio.ReadBinaryFile(keyfilename)
     current_id = bpio.ReadBinaryFile(idfilename)
     if current_id == '':
         lg.out(2, 'initializer._check_install local identity is empty ')
         return False
     if current_key == '':
         lg.out(2, 'initializer._check_install private key is empty ')
         return False
     try:
         key.InitMyKey()
     except:
         lg.out(2, 'initializer._check_install fail loading private key ')
         return False
     try:
         ident = identity.identity(xmlsrc=current_id)
     except:
         lg.out(2, 'initializer._check_install fail init local identity ')
         return False
     try:
         res = ident.Valid() and ident.isCorrect()
     except:
         lg.out(
             2,
             'initializer._check_install wrong data in local identity   ')
         return False
     if not res:
         lg.out(2,
                'initializer._check_install local identity is not valid ')
         return False
     lg.out(2, 'initializer._check_install done')
     return True