Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
added the read to change the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
vineela-afk committed Jan 30, 2024
1 parent a82b19e commit adcd7d9
Show file tree
Hide file tree
Showing 8 changed files with 359 additions and 217 deletions.
30 changes: 17 additions & 13 deletions g2p_encryption/models/keymanager_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def encrypt_data(self, data):
},
}
response = requests.post(url, json=payload, headers=headers)
print(response.content)
# print(response.content)

return response.json().get("response", {}).get("data", None)

Expand Down Expand Up @@ -137,7 +137,10 @@ def decrypt_data(self, data):
},
}
response = requests.post(url, json=payload, headers=headers)
return response.json().get("response", {}).get("data", None)
response = response.json().get("response", {})
if response:
response = response.get("data", {})
return response

def get_signing_public_key(self):
url = f"{self.base_url}/getSigningPublicKey"
Expand Down Expand Up @@ -201,11 +204,6 @@ def jwt_verify(self, data):
return response.json()

def jwt_sign(self, data):
data_to_sign = data.get("dataToSign", None)

if data_to_sign is None:
print("Data to sign is null. Skipping JWT signing.")
return None
url = f"{self.base_url}/jwtSign"
headers = {"Cookie": f"Authorization={self.access_token}"}
payload = {
Expand All @@ -218,9 +216,9 @@ def jwt_sign(self, data):
"applicationId": data.get("applicationId", "string"),
"referenceId": data.get("referenceId", "string"),
"includePayload": True,
"includeCertificate": True,
"includeCertHash": True,
"certificateUrl": data.get("certificateUrl", "string"),
# "includeCertificate": True,
# "includeCertHash": True,
# "certificateUrl": data.get("certificateUrl", "string"),
},
}
response = requests.post(url, json=payload, headers=headers)
Expand All @@ -229,7 +227,7 @@ def jwt_sign(self, data):
response.json().get("response", {}).get("jwtSignedData", None)
)
except ValueError:
print("Error parsing response JSON. JWT signing failed.")
# print("Error parsing response JSON. JWT signing failed.")
jwt_signed_data = None

return jwt_signed_data
Expand Down Expand Up @@ -351,5 +349,11 @@ def generate_symmetric_key(self, data):
# "dataToSign": "aGVsbG8gd29ybGQ=",
# "certificateUrl": certificate_data,
# }
# encrypted_data = odoo_api.jwt_sign(data_to_encrypt)
# print("Encrypted Data:", encrypted_data)
# data_to_encrypt = {
# "applicationId": "REGISTRATION",
# "referenceId": "",
# "data": "c-UgAvGn5o_iAOpSauP29SAlRRbmEEwhl3UkgK3u_0RR4u_ayqcB5aAuaDD5YDonsNxATVvt9UEqbyHtdTEnIb-U3KcdW7DtgvbT_n1yD4oeIvSK6hTx7bCjrlOrs-4JT8VN6J6heS19cuhtV88wj3Hmr0GBGIpfDSHkW4auOfVDiw8dlVUm6YiwhnGBvF4AJ2Nb7h_Hbm0XbO-JRNKHjIjPXqfJ0qjDSW4Si_d89u9iwNGMZy0xCXJbeBaHf6HTY3uQMwC-dqJgbR-W4kjXrsy8jbSa_PXaMOWoQCKf4AOUZZ6L9Bqv_l7HiaHKPdW_RU-e3r48MMtFLLDLnhy5N9CGpploF5JgKe8_Wnok42m-1lTb2HjwjCI2pJcm6WVvI0tFWV9TUExJVFRFUiOMwXdK6x8x6v2DhUcv434Bl-s88jQ1cFPFwQ",
# }
# decrypted_data = odoo_api.decrypt_data(data_to_encrypt)
# print("Decrypted Data:", decrypted_data)

8 changes: 6 additions & 2 deletions g2p_registry_encryption/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
"website": "https://openg2p.org",
"license": "Other OSI approved licence",
"development_status": "Alpha",
"depends": ["g2p_encryption", "g2p_registry_base"],
"data": [],
"depends": ["g2p_encryption", "g2p_registry_base", "g2p_registry_individual"],
"data": [
"views/decrypt_file.xml",
"views/res_config_view.xml",
"security/security.xml",
],
"assets": {
"web.assets_backend": [],
"web.assets_qweb": [],
Expand Down
2 changes: 1 addition & 1 deletion g2p_registry_encryption/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import partner, phone_number, reg_ids
from . import partner, phone_number, reg_ids, registry_config
Loading

0 comments on commit adcd7d9

Please sign in to comment.