def decryptPassword(encryptedpassword, key): secretKey = Base64.decodeBase64(key) seckeySpec = SecretKeySpec(secretKey, "AES") if encryptedpassword is not None and encryptedpassword is not ' ': encData = Base64.decodeBase64(encryptedpassword) cipher.init(Cipher.DECRYPT_MODE, seckeySpec) decrypted = cipher.doFinal(encData) originalString = decrypted.tostring() return originalString
def authenticate_user_in_azure(tenant_id, user_name, pwd, client_id, client_secret): post_params_json = { 'resource': AZURE_AD_GRAPH_RESOURCE_ENDPOINT, 'client_id': client_id, 'client_secret': client_secret, 'username': user_name, 'password': pwd, 'grant_type': 'password', 'scope': 'openid' } post_params_url_encoded = urllib.urlencode(post_params_json) headers_json = { 'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'application/json' } conn = httplib.HTTPSConnection(MICROSOFT_AUTHORITY_URL + ':443') relative_url = '/' + tenant_id + '/oauth2/token' conn.request('POST', relative_url, post_params_url_encoded, headers_json) response = conn.getresponse() # print response.status, response.reason azure_response = response.read() conn.close() # print "Response Data: %s" % azure_response azure_response_json = json.loads(azure_response) if 'id_token' in azure_response_json: id_token = azure_response_json['id_token'] id_token_array = String(id_token).split("\\.") id_token_payload = id_token_array[1] id_token_payload_str = String( Base64.decodeBase64(id_token_payload), 'UTF-8') return str(id_token_payload_str) else: return azure_response
def retrieveBody(delivery): if delivery.properties.contentEncoding == "DEF": compressed = Base64.decodeBase64(String(delivery.body).getBytes("UTF-8")) inflated = ByteArrayOutputStream() inflatedOs = InflaterOutputStream(inflated) inflatedOs.write(compressed) inflatedOs.close() return inflated.toString("UTF-8") else: return String(delivery.body, "UTF-8")
def decodeMessage(wrapper, message): result = "" decoded = Base64.decodeBase64(message) try: Z = String(decoded, "UTF-8") result = Z.split(wrapper)[1] except Exception as ex: # Error decoding a Tango message. pass return result
def decodeMessage(wrapper, message): result = "" decoded = Base64.decodeBase64(message) try: Z = String(decoded, "UTF-8") result = Z.split(wrapper)[1] except Exception as ex: self._logger.log(Level.SEVERE, "Error decoding a Tango message", ex) self._logger.log(Level.SEVERE, traceback.format_exc()) return result
def retrieveBody(delivery): if delivery.properties.contentEncoding == "DEF": compressed = Base64.decodeBase64( String(delivery.body).getBytes("UTF-8")) inflated = ByteArrayOutputStream() inflatedOs = InflaterOutputStream(inflated) inflatedOs.write(compressed) inflatedOs.close() return inflated.toString("UTF-8") else: return String(delivery.body, "UTF-8")
# # Copyright 2019 XEBIALABS # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # from java.io import ByteArrayInputStream from org.apache.commons.codec.binary import Base64 from org.apache.poi.xssf.usermodel import XSSFWorkbook from templateImportExcel.TemplateImportExcelClientUtil import Template_Import_Excel_Client_Util logger.info("Executing templateImportExcel/import-rest.py") targetFolderId = request.entity['data']['targetFolderId'] templateName = request.entity['data']['templateName'] workbook = XSSFWorkbook( ByteArrayInputStream(Base64.decodeBase64( request.entity['data']['result']))) print "created workbook\n" client = Template_Import_Excel_Client_Util.create_client( workbook, targetFolderId, templateName, templateApi, phaseApi, taskApi) client.convertWorkbookToTemplate() logger.info("Exiting import-rest.py")
azure_response = response.read() conn.close() print "Response Data: %s" % azure_response azure_response_json = json.loads(azure_response) if 'id_token' in azure_response_json: id_token = azure_response_json['id_token'] id_token_array = String(id_token).split("\\.") id_token_payload = id_token_array[1] id_token_payload_str = String(Base64.decodeBase64(id_token_payload), 'UTF-8') return str(id_token_payload_str) else: return azure_response print "Start Time: %s" % datetime.now() pwd = String(Base64.decodeBase64('UHJhbWF0aUAxMjM='), 'UTF-8') auth_response = authenticate_user_in_azure(AZURE_TENANT_ID, AZURE_USER_NAME, pwd, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET) print "End Time: %s" % datetime.now() print "Auth response: %s" % auth_response azure_auth_response_json = json.loads(auth_response) if 'upn' in azure_auth_response_json: name = azure_auth_response_json['upn'] print "upn is present: %s" % name elif 'error' in azure_auth_response_json: error = azure_auth_response_json['error'] error_msg = azure_auth_response_json['error_description'] print "Error is %s" % error print "Error Message is %s" % error_msg # azureAuthConnector = AzureAuthConnector()