Esempio n. 1
0
    def _create_new_identity(self):
        """
        Generate new Private key and new identity file.
        Reads some extra info from config files.
        """
        login = strng.to_bin(bpio.ReadTextFile(settings.UserNameFilename()))
        externalIP = strng.to_bin(misc.readExternalIP()) or b'127.0.0.1'
        if self.free_idurls[0].count(b'127.0.0.1'):
            externalIP = b'127.0.0.1'
        lg.out(
            4,
            'id_registrator._create_new_identity %s %s ' % (login, externalIP))

        my_id.forgetLocalIdentity()
        my_id.eraseLocalIdentity(do_backup=True)
        key.ForgetMyKey(erase_file=True, do_backup=True)
        key.InitMyKey()
        if not key.isMyKeyReady():
            key.GenerateNewKey()
        lg.out(4, '    my key is ready')
        ident = my_id.buildDefaultIdentity(name=login,
                                           ip=externalIP,
                                           idurls=self.free_idurls)
        my_identity_xmlsrc = ident.serialize(as_text=True)
        newfilename = settings.LocalIdentityFilename() + '.new'
        bpio.WriteTextFile(newfilename, my_identity_xmlsrc)
        try:
            id_url.identity_cached(ident)
        except:
            lg.exc()
        self.new_identity = ident
        lg.out(
            4, '    wrote %d bytes to %s' %
            (len(my_identity_xmlsrc), newfilename))
Esempio n. 2
0
 def _create_new_identity(self):
     """
     Generate new Private key and new identity file.
     Reads some extra info from config files.
     """
     login = strng.to_bin(bpio.ReadTextFile(settings.UserNameFilename()))
     externalIP = strng.to_bin(misc.readExternalIP()) or b'127.0.0.1'
     if self.free_idurls[0].count(b'127.0.0.1'):
         externalIP = b'127.0.0.1'
     lg.out(
         4,
         'id_registrator._create_new_identity %s %s ' % (login, externalIP))
     key.InitMyKey()
     if not key.isMyKeyReady():
         key.GenerateNewKey()
     lg.out(4, '    my key is ready')
     ident = my_id.buildDefaultIdentity(name=login,
                                        ip=externalIP,
                                        idurls=self.free_idurls)
     # my_id.rebuildLocalIdentity(
     #     identity_object=ident, revision_up=True, save_identity=False)
     # localIP = bpio.ReadTextFile(settings.LocalIPFilename())
     my_identity_xmlsrc = ident.serialize(as_text=True)
     newfilename = settings.LocalIdentityFilename() + '.new'
     bpio.WriteTextFile(newfilename, my_identity_xmlsrc)
     self.new_identity = ident
     lg.out(
         4, '    wrote %d bytes to %s' %
         (len(my_identity_xmlsrc), newfilename))
Esempio n. 3
0
def is_identity_authenticated():
    ok = my_id.isLocalIdentityReady() and key.isMyKeyReady()
    # lg.out(8, 'django.is_identity_authenticated node=%s' % (ok))
    return ok
Esempio n. 4
0
def is_identity_authenticated():
    ok = my_id.isLocalIdentityReady() and key.isMyKeyReady()
    # lg.out(8, 'django.is_identity_authenticated node=%s' % (ok))
    return ok