def importDb(input, password = None): dbSysInst = dbSys.dbSysSmart() sf = open(input, 'r') package = json.load(sf) en = enc.encryptorBase64Out(password) l = package["add"] if (password is None) and package.has_key("encPass"): print 'need password for importing' return if (not (password is None)): if unicode(str(md5.new(password).hexdigest())) != package["encPass"]: print 'pass not match:', unicode(str(md5.new(password+package["time-duration"]).hexdigest())), package["encPass"] return else: l = listEncryptor.dictListDecryptor(l, en) l = listEncryptor.dictListEncryptor(l) dbSysInst.importDb(l)
def importDb(input, username, targetPasswd, password = None): dbSysInst = dbSys.dbSysSmart() sf = open(input, 'r') package = json.load(sf) en = enc.encryptorBase64Out(password) l = package["add"] if (password is None) and package.has_key("encPass"): print 'need password for importing' return if (not (password is None)): if unicode(str(md5.new(password).hexdigest())) != package["encPass"]: print 'pass not match:', unicode(str(md5.new(password+package["time-duration"]).hexdigest())), package["encPass"] return else: l = listEncryptor.dictListDecryptor(l, en) sysUser = service.ufsUser(u'system.user', u'system.pass') if userMan.userManager().verifyPasswd(username, targetPasswd, dbSys.dbSysSmart(sysUser).getDb("passwdDb")): print 'importing' l = listEncryptor.dictListEncryptor(l, xorEnc.encryptorTxtOut(targetPasswd)) #print l l = listEncryptor.setUser(l, username) #print l dbSysInst.importDb(l)