6.1.1.3.2.32. linotp.lib.util module¶
contains utility functions
- linotp.lib.util.check_selfservice_session()[source]¶
This function checks the session cookie for the selfservcice session
- linotp.lib.util.check_session()[source]¶
This function checks the session cookie for management API and compares it to the session parameter
- linotp.lib.util.generate_otpkey(key_size=20)[source]¶
generates the HMAC key of keysize. Should be 20 or 32 THe key is returned as a hexlified string
- linotp.lib.util.generate_password(size=6, characters='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')[source]¶
- linotp.lib.util.getParam()[source]¶
- input:
param (hash set): the set, which contains all parameters
which (lteral): the entry lookup
- optional (boolean): defines if this parameter is optional or not
- an exception is thrown if the parameter is required
- otherwise: nothing done!
- return:
- the value (literal) of the parameter if exists or nothing in case the parameter is optional, otherwise throw an exception
- linotp.lib.util.get_client()[source]¶
This function returns the client.
It first tries to get the client as it is passed as the HTTP Client via REMOTE_ADDR.
If this client Address is in a list, that is allowed to overwrite its client address (like e.g. a FreeRADIUS server, which will always pass the FreeRADIUS address but not the address of the RADIUS client) it checks for the existance of the client parameter.
- linotp.lib.util.get_client_from_param()[source]¶
This function returns the client, that is passed with the GET/POST parameter “client”
- linotp.lib.util.get_client_from_request()[source]¶
This function returns the client as it is passed in the HTTP Request. This is the very HTTP client, that contacts the LinOTP server.
- linotp.lib.util.get_copyright_info()[source]¶
This returns the copyright information displayed in the WebUI and selfservice portal.
- linotp.lib.util.get_version()[source]¶
This returns the version, that is displayed in the WebUI and self service portal.
- linotp.lib.util.is_valid_fqdn(hostname, split_port=False)[source]¶
Checks if the hostname is a valid FQDN
- linotp.lib.util.normalize_activation_code(activationcode, upper=True, convert_o=True, convert_0=True)[source]¶
This normalizes the activation code. 1. lower letters are capitaliezed 2. Oh’s in the last two characters are turned to zeros 3. zeros in in the first-2 characters are turned to Ohs
- linotp.lib.util.remove_empty_lines(doc)[source]¶
remove empty lines from the input document
@param doc: documemt containing long multiline text @type doc: string
@return: data without empty lines @rtype: string