diff --git a/tcllib/__init__.py b/tcllib/__init__.py index a5f83ec..53e1b21 100644 --- a/tcllib/__init__.py +++ b/tcllib/__init__.py @@ -9,7 +9,7 @@ import enum import requests -from . import (credentials, devlist, dumpmgr, servervote, tclcheck, +from . import (dumpmgr, servervote, tclcheck, tclchecksum, tclencheader, tclrequest, xmltools) @@ -24,7 +24,6 @@ class FotaCheck( tclchecksum.TclChecksumMixin, tclencheader.TclEncHeaderMixin, servervote.ServerVoteMixin, - credentials.CredentialsMixin, dumpmgr.DumpMgrMixin ): """Main API handler class.""" diff --git a/tcllib/credentials.py b/tcllib/credentials.py index de15c73..8a6ec8c 100644 --- a/tcllib/credentials.py +++ b/tcllib/credentials.py @@ -8,24 +8,20 @@ import base64 -class CredentialsMixin: - """A mixin component to provide authentication.""" - @staticmethod - def get_creds(): - """Return main authentication.""" - creds = { - b"YWNjb3VudA==": b"emhlbmdodWEuZ2Fv", - b"cGFzc3dvcmQ=": b"cWFydUQ0b2s=", - } - params = {base64.b64decode(key): base64.b64decode(val) for key, val in creds.items()} - return params +def get_creds(): + """Return main authentication.""" + creds = { + b"YWNjb3VudA==": b"emhlbmdodWEuZ2Fv", + b"cGFzc3dvcmQ=": b"cWFydUQ0b2s=", + } + params = {base64.b64decode(key): base64.b64decode(val) for key, val in creds.items()} + return params - @staticmethod - def get_creds2(): - """Return alternate authentication.""" - creds = { - b"YWNjb3VudA==": b"VGVsZUV4dFRlc3Q=", - b"cGFzc3dvcmQ=": b"dDA1MjM=", - } - params = {base64.b64decode(key): base64.b64decode(val) for key, val in creds.items()} - return params +def get_creds2(): + """Return alternate authentication.""" + creds = { + b"YWNjb3VudA==": b"VGVsZUV4dFRlc3Q=", + b"cGFzc3dvcmQ=": b"dDA1MjM=", + } + params = {base64.b64decode(key): base64.b64decode(val) for key, val in creds.items()} + return params diff --git a/tcllib/tclchecksum.py b/tcllib/tclchecksum.py index 4c6c016..9030bc9 100644 --- a/tcllib/tclchecksum.py +++ b/tcllib/tclchecksum.py @@ -8,14 +8,14 @@ import json from defusedxml import ElementTree - +from . import credentials class TclChecksumMixin: """A mixin component for TCL's checksum API.""" def do_checksum(self, encslave, address, uri): """Perform checksum request with given parameters.""" url = "http://" + encslave + "/checksum.php" - params = self.get_creds2() + params = credentials.get_creds2() payload = {address: uri} payload_json = json.dumps(payload) diff --git a/tcllib/tclencheader.py b/tcllib/tclencheader.py index 2053a1a..4499d63 100644 --- a/tcllib/tclencheader.py +++ b/tcllib/tclencheader.py @@ -5,12 +5,14 @@ """Tools to interface with TCL's encrypted header API.""" +from . import credentials + class TclEncHeaderMixin: """A mixin component for TCL's encrypted header API..""" def do_encrypt_header(self, encslave, address): """Perform encrypted header request with given parameters.""" - params = self.get_creds2() + params = credentials.get_creds2() params[b"address"] = bytes(address, "utf-8") url = "http://" + encslave + "/encrypt_header.php" req = self.sess.post(url, data=params, verify=False)