summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/bonafide
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/bonafide')
-rw-r--r--src/leap/bitmask/bonafide/_protocol.py4
-rw-r--r--src/leap/bitmask/bonafide/config.py18
-rw-r--r--src/leap/bitmask/bonafide/service.py4
3 files changed, 21 insertions, 5 deletions
diff --git a/src/leap/bitmask/bonafide/_protocol.py b/src/leap/bitmask/bonafide/_protocol.py
index 91b8b24..391aa8d 100644
--- a/src/leap/bitmask/bonafide/_protocol.py
+++ b/src/leap/bitmask/bonafide/_protocol.py
@@ -177,6 +177,10 @@ class BonafideProtocol(object):
provider = config.Provider(provider_id, autoconf=autoconf)
return provider.callWhenMainConfigReady(provider.config)
+ def do_get_service(self, provider_id, service, autoconf=False):
+ provider = config.Provider(provider_id, autoconf=autoconf)
+ return provider.callWhenMainConfigReady(provider.config, service)
+
def do_provider_delete(self, provider_id):
return config.delete_provider(provider_id)
diff --git a/src/leap/bitmask/bonafide/config.py b/src/leap/bitmask/bonafide/config.py
index ba45465..1002edb 100644
--- a/src/leap/bitmask/bonafide/config.py
+++ b/src/leap/bitmask/bonafide/config.py
@@ -234,10 +234,20 @@ class Provider(object):
return False
return True
- def config(self):
- if not self._provider_config:
- self._load_provider_json()
- return self._provider_config.dict()
+ def config(self, service=None):
+ if not service:
+ if not self._provider_config:
+ self._load_provider_json()
+ return self._provider_config.dict()
+
+ path = self._get_service_config_path(service)
+ try:
+ with open(path, 'r') as config:
+ config = Record(**json.load(config))
+ except IOError:
+ raise ValueError("Service " + service +
+ " not found in provider " + self._domain)
+ return config
def bootstrap(self):
domain = self._domain
diff --git a/src/leap/bitmask/bonafide/service.py b/src/leap/bitmask/bonafide/service.py
index dc57917..0a78813 100644
--- a/src/leap/bitmask/bonafide/service.py
+++ b/src/leap/bitmask/bonafide/service.py
@@ -111,7 +111,9 @@ class BonafideService(HookableService):
def do_provider_create(self, domain):
return self._bonafide.do_get_provider(domain, autoconf=True)
- def do_provider_read(self, domain):
+ def do_provider_read(self, domain, service=None):
+ if service:
+ return self._bonafide.do_get_service(domain, service)
return self._bonafide.do_get_provider(domain)
def do_provider_delete(self, domain):