-
Notifications
You must be signed in to change notification settings - Fork 30
/
Configuration.py
146 lines (140 loc) · 8.41 KB
/
Configuration.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import os
from CyberSource.logging.log_configuration import LogConfiguration
class Configuration:
def __init__(self):
self.authentication_type ="http_signature"
self.merchantid = "testrest"
self.alternative_merchantid = "testrest_cpctv"
self.run_environment = "apitest.cybersource.com"
# new property has been added for user to configure the base path so that request can route the API calls via Azure Management URL.
# Example: If intermediate url is https://manage.windowsazure.com then in property input can be same url or manage.windowsazure.com.
self.IntermediateHost="https://manage.windowsazure.com"
self.request_json_path = ""
# JWT PARAMETERS
self.key_alias = "testrest"
self.key_pass = "testrest"
self.key_file_name = "testrest"
self.alternative_key_alias = "testrest_cpctv"
self.alternative_key_pass = "Ap!C38tp12@"
self.alternative_key_file_name = "testrest_cpctv"
self.keys_directory = os.path.join(os.getcwd(), "resources")
# HTTP PARAMETERS
self.merchant_keyid = "08c94330-f618-42a3-b09d-e1e43be5efda"
self.merchant_secretkey = "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE="
self.alternative_merchant_keyid = "964f2ecc-96f0-4432-a742-db0b44e6a73a"
self.alternative_merchant_secretkey = "zXKpCqMQPmOR/JRldSlkQUtvvIzOewUVqsUP0sBHpxQ="
# META KEY PARAMETERS
self.use_metakey = False
self.portfolio_id = ''
# CONNECTION TIMEOUT PARAMETER
self.timeout = 1000
# LOG PARAMETERS
self.enable_log = True
self.log_file_name = "cybs"
self.log_maximum_size = 10487560
self.log_directory = os.path.join(os.getcwd(), "Logs")
self.log_level = "Debug"
self.enable_masking = False
self.log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
self.log_date_format = "%Y-%m-%d %H:%M:%S"
# PROXY PARAMETERS
#self.proxy_address = "userproxy.com"
#self.proxy_port = ""
#Optional default Axa/Client Headers- Client can add additional headers
self.default_headers ={ "Ocp-Apim-Subscription-Key":"=fchgfchgvjhvjh5536hg",
"Ocp-Apim-Trace":"dfgcjgvjkhbkjkjhnkjvjgchdxh",
"Host":"manage.windowsazure.com"}
# PEM Key file path for decoding JWE Response Enter the folder path where the .pem file is located.
# It is optional property, require adding only during JWE decryption.
self.JWEPemFIleDirectory = os.path.join(os.getcwd(), "resources", "NetworkTokenCert.pem")
# Assigning the configuration properties in the configuration dictionary
def get_configuration(self):
configuration_dictionary = ({})
configuration_dictionary["authentication_type"] = self.authentication_type
configuration_dictionary["merchantid"] = self.merchantid
configuration_dictionary["run_environment"] = self.run_environment
configuration_dictionary["request_json_path"] = self.request_json_path
configuration_dictionary["key_alias"] = self.key_alias
configuration_dictionary["key_password"] = self.key_pass
configuration_dictionary["key_file_name"] = self.key_file_name
configuration_dictionary["keys_directory"] = self.keys_directory
configuration_dictionary["merchant_keyid"] = self.merchant_keyid
configuration_dictionary["merchant_secretkey"] = self.merchant_secretkey
configuration_dictionary["use_metakey"] = self.use_metakey
configuration_dictionary["portfolio_id"] = self.portfolio_id
configuration_dictionary["timeout"] = self.timeout
configuration_dictionary['jwePEMFileDirectory'] = self.JWEPemFIleDirectory
log_config = LogConfiguration()
log_config.set_enable_log(self.enable_log)
log_config.set_log_directory(self.log_directory)
log_config.set_log_file_name(self.log_file_name)
log_config.set_log_maximum_size(self.log_maximum_size)
log_config.set_log_level(self.log_level)
log_config.set_enable_masking(self.enable_masking)
log_config.set_log_format(self.log_format)
log_config.set_log_date_format(self.log_date_format)
configuration_dictionary["log_config"] = log_config
#configuration_dictionary["proxy_address"] = self.proxy_address
#configuration_dictionary["proxy_port"] = self.proxy_port
return configuration_dictionary
def get_alternative_configuration(self):
configuration_dictionary = ({})
configuration_dictionary["authentication_type"] = self.authentication_type
configuration_dictionary["merchantid"] = self.alternative_merchantid
configuration_dictionary["run_environment"] = self.run_environment
configuration_dictionary["request_json_path"] = self.request_json_path
configuration_dictionary["key_alias"] = self.alternative_key_alias
configuration_dictionary["key_password"] = self.alternative_key_pass
configuration_dictionary["key_file_name"] = self.alternative_key_file_name
configuration_dictionary["keys_directory"] = self.keys_directory
configuration_dictionary["merchant_keyid"] = self.alternative_merchant_keyid
configuration_dictionary["merchant_secretkey"] = self.alternative_merchant_secretkey
configuration_dictionary["use_metakey"] = self.use_metakey
configuration_dictionary["portfolio_id"] = self.portfolio_id
configuration_dictionary["timeout"] = self.timeout
log_config = LogConfiguration()
log_config.set_enable_log(self.enable_log)
log_config.set_log_directory(self.log_directory)
log_config.set_log_file_name(self.log_file_name)
log_config.set_log_maximum_size(self.log_maximum_size)
log_config.set_log_level(self.log_level)
log_config.set_enable_masking(self.enable_masking)
log_config.set_log_format(self.log_format)
log_config.set_log_date_format(self.log_date_format)
configuration_dictionary["log_config"] = log_config
#configuration_dictionary["proxy_address"] = self.proxy_address
#configuration_dictionary["proxy_port"] = self.proxy_port
return configuration_dictionary
# Assigning the configuration properties in the configuration dictionary
def get_indermediate_configuration(self):
configuration_dictionary = ({})
configuration_dictionary["authentication_type"] = self.authentication_type
configuration_dictionary["merchantid"] = self.merchantid
configuration_dictionary["run_environment"] = self.run_environment
# new property has been added for user to configure the base path so that request can route the API calls via Azure Management URL.
# Example: If intermediate url is https://manage.windowsazure.com then in property input can be same url or manage.windowsazure.com.
configuration_dictionary["IntermediateHost"] = self.IntermediateHost
configuration_dictionary["default_headers"] = self.default_headers
configuration_dictionary["request_json_path"] = self.request_json_path
configuration_dictionary["key_alias"] = self.key_alias
configuration_dictionary["key_password"] = self.key_pass
configuration_dictionary["key_file_name"] = self.key_file_name
configuration_dictionary["keys_directory"] = self.keys_directory
configuration_dictionary["merchant_keyid"] = self.merchant_keyid
configuration_dictionary["merchant_secretkey"] = self.merchant_secretkey
configuration_dictionary["use_metakey"] = self.use_metakey
configuration_dictionary["portfolio_id"] = self.portfolio_id
configuration_dictionary["timeout"] = self.timeout
log_config = LogConfiguration()
log_config.set_enable_log(self.enable_log)
log_config.set_log_directory(self.log_directory)
log_config.set_log_file_name(self.log_file_name)
log_config.set_log_maximum_size(self.log_maximum_size)
log_config.set_log_level(self.log_level)
log_config.set_enable_masking(self.enable_masking)
log_config.set_log_format(self.log_format)
log_config.set_log_date_format(self.log_date_format)
configuration_dictionary["log_config"] = log_config
#configuration_dictionary["proxy_address"] = self.proxy_address
#configuration_dictionary["proxy_port"] = self.proxy_port
return configuration_dictionary