6.1.1.3.1.1.1.3. linotp.lib.ImportOTP.eTokenDat module

eToken dat file importer

class linotp.lib.ImportOTP.eTokenDat.DatToken[source]

Bases: object

eToken class which is equivalent to the token definition of the dat file

add_info(line)[source]

parse a config line into a class attribute by calling a dedicated or the generic setter for an key value pair

Parameters:line – config line which belong to one token
Returns:
  • nothing -
get_initparams()[source]

provide all init definitions

set(key, val)[source]

generic setter, so that no attribute will get lost

set_crypto(val)[source]

setter of the hash lib

Parameters:value – value of the setter
Returns:
  • nothing -
set_sccAuthenticatorId(value)[source]

take the sccAuthenticatorId for serial number

Parameters:value – value of the setter
Returns:
  • nothing -
set_sccKey(val)[source]

set up the secret key

Parameters:value – value of the setter
Returns:
  • nothing -
set_sccMode(value)[source]

setter, if the token is counter based or event based

Parameters:value – value of the setter
Returns:
  • nothing -
set_sccPrTime(value)[source]

if the token definition hat this attribute, we can assume that we have a timebased eToken, which starts its counter which starts the timecount with 1.1.2000 and not in 1.1.1970 as defined in the standard. So we have to set an offsett of 30 years

Parameters:value – value of the setter
Returns:
  • nothing -
set_sccPwLen(value)[source]

take the sccPwLen as otplen value

Parameters:value – value of the setter
Returns:
  • nothing -
set_sccTick(value)[source]

take the sccTick as timeStep value

Parameters:value – value of the setter
Returns:
  • nothing -
set_sccTokenData(value)[source]

parse the detail token definition by calling again a specific setter (if exist) or the generic one

Parameters:line – config line which belong to one token
Returns:
  • nothing -
set_sccTokenType(value)[source]

take the sccTokenType as part of the token description

Parameters:value – value of the setter
Returns:
  • nothing -
set_startdate(startdate)[source]

put in the startdate after creating the token

Parameters:startdate – wehen the counter will start counting datetime format
Returns:
  • nothing -
linotp.lib.ImportOTP.eTokenDat.create_token(lines, startdate=None)[source]

take an array of lines and create a token out of it

remark: the lines are split up on the caller level

Parameters:lines
linotp.lib.ImportOTP.eTokenDat.get_session(lino_url, user=None, pwd=None)[source]

return an LinOTP Session context, which is the session and the cookie in the header

Parameters:
  • lino_url – the linotp base url
  • user – the session for the user
  • pwd – the password of the user
Returns:

tuple of session and header

linotp.lib.ImportOTP.eTokenDat.main()[source]

main - parse the args and start the processing

linotp.lib.ImportOTP.eTokenDat.parse_dat_data(data, d_string=None)[source]

this function is called from the web-ui and parses an eToken data file

Parameters:data – data from the web-ui file upload
Returns:It returns a dictionary of serial : { /admin/init parameters }
linotp.lib.ImportOTP.eTokenDat.parse_datetime(d_string)[source]

parse an date string and try to convert it to an datetime object

Parameters:d_string – date string
Returns:datetime object
linotp.lib.ImportOTP.eTokenDat.process_file(filename, startdate, lino_url=None, user=None, password=None)[source]

read the eToken dat file and split it up into a bunch of lines, that define one token. An empty line is considered as separator.

Parameters:
  • filename – the eToken dat file
  • lino_url – if defined, the tokens will be created in linotp
linotp.lib.ImportOTP.eTokenDat.submit_tokens(lino_url, tokens, user=None, pwd=None)[source]

submit an /admin/init request to create the token in the linotp server

Parameters:
  • linotp_url – the url, where linotp resides
  • tokens – the array of tokens
  • user – the admin user -required to get a session
  • pwd – the admin password -required to get a session
linotp.lib.ImportOTP.eTokenDat.usage()[source]

print usage message