ark-sdk-python 1.0.5__py3-none-any.whl → 1.0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ark_sdk_python/ark.py +1 -1
- ark_sdk_python/services/dpa/sso/ark_dpa_sso_service.py +28 -18
- {ark_sdk_python-1.0.5.dist-info → ark_sdk_python-1.0.6.dist-info}/METADATA +1 -1
- ark_sdk_python-1.0.6.dist-info/NOTICES.md +2081 -0
- {ark_sdk_python-1.0.5.dist-info → ark_sdk_python-1.0.6.dist-info}/RECORD +8 -7
- {ark_sdk_python-1.0.5.dist-info → ark_sdk_python-1.0.6.dist-info}/WHEEL +1 -1
- {ark_sdk_python-1.0.5.dist-info → ark_sdk_python-1.0.6.dist-info}/LICENSE.txt +0 -0
- {ark_sdk_python-1.0.5.dist-info → ark_sdk_python-1.0.6.dist-info}/entry_points.txt +0 -0
ark_sdk_python/ark.py
CHANGED
|
@@ -66,9 +66,16 @@ class ArkDPASSOService(ArkService):
|
|
|
66
66
|
postfix=f'{claims["tenant_id"]}_{claims["unique_name"]}_dpa_sso_short_lived_{token_type}',
|
|
67
67
|
)
|
|
68
68
|
|
|
69
|
+
def __expand_folder(self, folder: str) -> str:
|
|
70
|
+
folder_path = os.path.expanduser(folder)
|
|
71
|
+
if not folder_path.endswith('/'):
|
|
72
|
+
folder_path += '/'
|
|
73
|
+
return folder_path
|
|
74
|
+
|
|
69
75
|
def __output_client_certificate(
|
|
70
76
|
self, folder: str, output_format: ArkDPASSOShortLiveClientCertificateFormat, result: ArkDPASSOAcquireTokenResponse
|
|
71
77
|
) -> None:
|
|
78
|
+
folder_path = self.__expand_folder(folder)
|
|
72
79
|
claims = get_unverified_claims(self.__client.session_token)
|
|
73
80
|
client_certificate = result.token['client_certificate']
|
|
74
81
|
private_key = result.token['private_key']
|
|
@@ -82,24 +89,24 @@ class ArkDPASSOService(ArkService):
|
|
|
82
89
|
)
|
|
83
90
|
ArkArgsFormatter.print_normal(f'client-key-data: {base64.b64encode(private_key.encode("utf-8")).decode("utf-8")}')
|
|
84
91
|
elif output_format == ArkDPASSOShortLiveClientCertificateFormat.FILE:
|
|
85
|
-
if not
|
|
92
|
+
if not folder_path:
|
|
86
93
|
raise ArkServiceException(
|
|
87
94
|
f'Folder parameter is required if format is {ArkDPASSOShortLiveClientCertificateFormat.FILE.value}'
|
|
88
95
|
)
|
|
89
|
-
if not os.path.exists(
|
|
90
|
-
os.makedirs(
|
|
91
|
-
with open(f'{
|
|
96
|
+
if not os.path.exists(folder_path):
|
|
97
|
+
os.makedirs(folder_path)
|
|
98
|
+
with open(f'{folder_path}{os.path.sep}{claims["unique_name"]}client_cert.crt', 'w', encoding='utf-8') as file_handle:
|
|
92
99
|
file_handle.write(client_certificate)
|
|
93
|
-
with open(f'{
|
|
100
|
+
with open(f'{folder_path}{os.path.sep}{claims["unique_name"]}client_key.pem', 'w', encoding='utf-8') as file_handle:
|
|
94
101
|
file_handle.write(private_key)
|
|
95
102
|
elif output_format == ArkDPASSOShortLiveClientCertificateFormat.SINGLE_FILE:
|
|
96
103
|
if not folder:
|
|
97
104
|
raise ArkServiceException(
|
|
98
105
|
f'Folder parameter is required if format is {ArkDPASSOShortLiveClientCertificateFormat.FILE.value}'
|
|
99
106
|
)
|
|
100
|
-
if not os.path.exists(
|
|
101
|
-
os.makedirs(
|
|
102
|
-
with open(f'{
|
|
107
|
+
if not os.path.exists(folder_path):
|
|
108
|
+
os.makedirs(folder_path)
|
|
109
|
+
with open(f'{folder_path}{os.path.sep}{claims["unique_name"]}client_cert.pem', 'w', encoding='utf-8') as file_handle:
|
|
103
110
|
file_handle.write(client_certificate)
|
|
104
111
|
file_handle.write('\n')
|
|
105
112
|
file_handle.write(private_key)
|
|
@@ -107,32 +114,35 @@ class ArkDPASSOService(ArkService):
|
|
|
107
114
|
raise ArkServiceException(f'Unknown format {output_format}')
|
|
108
115
|
|
|
109
116
|
def __save_oracle_sso_wallet(self, folder: str, unzip_wallet: bool, result: ArkDPASSOAcquireTokenResponse) -> None:
|
|
117
|
+
folder_path = self.__expand_folder(folder)
|
|
110
118
|
result.token['wallet'] = base64.b64decode(result.token['wallet'])
|
|
111
|
-
if not os.path.exists(
|
|
112
|
-
os.makedirs(
|
|
119
|
+
if not os.path.exists(folder_path):
|
|
120
|
+
os.makedirs(folder_path)
|
|
113
121
|
if not unzip_wallet:
|
|
114
|
-
with open(f'{
|
|
122
|
+
with open(f'{folder_path}{os.path.sep}wallet.zip', 'wb') as file_handle:
|
|
115
123
|
file_handle.write(result.token['wallet'])
|
|
116
124
|
else:
|
|
117
125
|
wallet_bytes = BytesIO(result.token['wallet'])
|
|
118
126
|
with zipfile.ZipFile(wallet_bytes, 'r') as zipf:
|
|
119
|
-
zipf.extractall(
|
|
127
|
+
zipf.extractall(folder_path)
|
|
120
128
|
|
|
121
129
|
def __save_oracle_pem_wallet(self, folder: str, result: ArkDPASSOAcquireTokenResponse) -> None:
|
|
130
|
+
folder_path = self.__expand_folder(folder)
|
|
122
131
|
claims = get_unverified_claims(self.__client.session_token)
|
|
123
132
|
pem_wallet = base64.b64decode(result.token['pem_wallet']).decode('utf-8')
|
|
124
|
-
if not os.path.exists(
|
|
125
|
-
os.makedirs(
|
|
126
|
-
with open(f'{
|
|
133
|
+
if not os.path.exists(folder_path):
|
|
134
|
+
os.makedirs(folder_path)
|
|
135
|
+
with open(f'{folder_path}{os.path.sep}{claims["unique_name"]}ewallet.pem', 'w', encoding='utf-8') as file_handle:
|
|
127
136
|
file_handle.write(pem_wallet)
|
|
128
137
|
|
|
129
138
|
def __save_rdp_file(self, get_short_lived_rdp_file: ArkDPASSOGetShortLivedRDPFile, result: ArkDPASSOAcquireTokenResponse) -> None:
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
folder_path = self.__expand_folder(get_short_lived_rdp_file.folder)
|
|
140
|
+
if not os.path.exists(folder_path):
|
|
141
|
+
os.makedirs(folder_path)
|
|
132
142
|
filename: str = f'dpa _a {get_short_lived_rdp_file.target_address}'
|
|
133
143
|
if get_short_lived_rdp_file.target_domain:
|
|
134
144
|
filename += f' _d {get_short_lived_rdp_file.target_domain}'
|
|
135
|
-
with open(f'{
|
|
145
|
+
with open(f'{folder_path}{filename}.rdp', 'w', encoding='utf-8') as file_handle:
|
|
136
146
|
file_handle.write(result.token['text'])
|
|
137
147
|
|
|
138
148
|
def short_lived_password(self, get_short_lived_password: ArkDPASSOGetShortLivedPassword) -> str:
|