-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequesterFactory.py
More file actions
31 lines (24 loc) · 1.31 KB
/
RequesterFactory.py
File metadata and controls
31 lines (24 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from typing import Dict, Union
from otlmow_davie.Enums import AuthenticationType, Environment
from CertRequester import CertRequester
from JWTRequester import JWTRequester
class RequesterFactory:
@staticmethod
def create_requester(settings: Dict, auth_type: AuthenticationType, environment: Environment
) -> Union[CertRequester, JWTRequester]:
auth_info = settings['authentication'][auth_type.name][environment.name]
first_part_url = ''
if environment == Environment.prd:
first_part_url = 'https://services.apps.mow.vlaanderen.be/'
elif environment == Environment.tei:
first_part_url = 'https://services.apps-tei.mow.vlaanderen.be/'
elif environment == Environment.dev:
first_part_url = 'https://services.apps-dev.mow.vlaanderen.be/'
if auth_type == AuthenticationType.JWT:
return JWTRequester(private_key_path=auth_info['key_path'],
client_id=auth_info['client_id'],
first_part_url=first_part_url)
if auth_type == AuthenticationType.cert:
return CertRequester(cert_path=auth_info['cert_path'],
key_path=auth_info['key_path'],
first_part_url=first_part_url)