def __init__(self, machineuser_id, key, value): log.debug("setting %r to %r for MachineUser %s" % (key, value, machineuser_id)) self.machineuser_id = machineuser_id self.mu_key = key self.mu_value = value Session.add(self) Session.commit()
def __init__(self, machinetoken_id, key, value): log.debug("setting %r to %r for MachineToken %s" % (key, value, machinetoken_id)) self.machinetoken_id = machinetoken_id self.mt_key = key self.mt_value = value Session.add(self) Session.commit()
def save(self): ''' enforce the saveing of a challenge - will guarentee the uniqness of the transaction id :return: transaction id of the stored challeng ''' try: Session.add(self) Session.commit() log.debug('save challenge : success') except Exception as exce: log.error('Error during saving challenge: %r' % exce) log.error("%s" % traceback.format_exc()) return self.transid
def set_config(key, value, typ, description=None): ''' create an intial config entry, if it does not exist :param key: the key :param value: the value :param description: the description of the key :return: nothing ''' count = Session.query(model.Config).filter( model.Config.Key == "privacyidea." + key).count() if count == 0: config_entry = model.Config(key, value, Type=typ, Description=description) Session.add(config_entry) return
def _storeConfigDB(key, val, typ=None, desc=None): value = val if (not key.startswith("privacyidea.")): key = "privacyidea." + key confEntries = Session.query(Config).filter(Config.Key == unicode(key)) theConf = None if typ is not None and typ == 'password': value = encryptPassword(val) en = decryptPassword(value) if (en != val): raise Exception("StoreConfig: Error during encoding password type!") ## update if confEntries.count() == 1: theConf = confEntries[0] theConf.Value = unicode(value) if (typ is not None): theConf.Type = unicode(typ) if (desc is not None): theConf.Description = unicode(desc) ## insert elif confEntries.count() == 0: theConf = Config( Key=unicode(key), Value=unicode(value), Type=unicode(typ), Description=unicode(desc) ) if theConf is not None: Session.add(theConf) return 101
def store(self): Session.add(self) Session.commit() return True
def save(self): Session.add(self) Session.commit() return self.transid
def storeToken(self): Session.add(self) Session.flush() Session.commit() return True