예제 #1
0
 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()
예제 #2
0
 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()
예제 #3
0
    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
예제 #4
0
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
예제 #5
0
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
예제 #6
0
 def store(self):
     Session.add(self)
     Session.commit()
     return True
예제 #7
0
 def save(self):
     Session.add(self)
     Session.commit()
     return self.transid
예제 #8
0
 def storeToken(self):
     Session.add(self)
     Session.flush()
     Session.commit()
     return True