diff options
Diffstat (limited to 'service/pixelated/config/initialize_leap.py')
-rw-r--r-- | service/pixelated/config/initialize_leap.py | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/service/pixelated/config/initialize_leap.py b/service/pixelated/config/initialize_leap.py index e393ec3f..856c915b 100644 --- a/service/pixelated/config/initialize_leap.py +++ b/service/pixelated/config/initialize_leap.py @@ -1,7 +1,46 @@ from pixelated.config.leap_cert import init_leap_cert +from pixelated.config.config import Config +from pixelated.config.config_ua import config_user_agent +from pixelated.config.dispatcher import config_dispatcher +import pixelated.bitmask_libraries.certs as certs +def initialize_leap(leap_provider_cert, + leap_provider_cert_fingerprint, + config_file, + dispatcher, + dispatcher_stdin): -def initialize_leap(leap_provider_cert, leap_provider_cert_fingerprint): + init_monkeypatches() + + provider, user, password = gather_credentials(dispatcher, + dispatcher_stdin, + config_file) + + config = Config() + config.provider = provider + config.username = user + config.password = password + + init_leap_cert(leap_provider_cert, leap_provider_cert_fingerprint) + + return config + + +def gather_credentials(dispatcher, dispatcher_stdin, config_file): + if dispatcher or dispatcher_stdin: + return config_dispatcher(dispatcher) + else: + return config_user_agent(config_file) + +def init_leap_cert(leap_provider_cert, leap_provider_cert_fingerprint): + if leap_provider_cert_fingerprint is None: + certs.LEAP_CERT = leap_provider_cert or True + certs.LEAP_FINGERPRINT = None + else: + certs.LEAP_FINGERPRINT = leap_provider_cert_fingerprint + certs.LEAP_CERT = False + +def init_monkeypatches(): import pixelated.support.ext_protobuf import pixelated.support.ext_sqlcipher import pixelated.support.ext_esmtp_sender_factory @@ -9,5 +48,3 @@ def initialize_leap(leap_provider_cert, leap_provider_cert_fingerprint): import pixelated.support.ext_sync import pixelated.support.ext_keymanager_fetch_key import pixelated.support.ext_requests_urllib3 - - init_leap_cert(leap_provider_cert, leap_provider_cert_fingerprint) |