def _importAccount(self, joeyAccountDirName, accountXmlFileName): ravenAccountDirName = self._getRavenAccountDirName(joeyAccountDirName) ravenAccountXmlName = os.path.join(ravenAccountDirName, u"account.xml") #$NON-NLS-1$ os.makedirs(ravenAccountDirName) # Copy over any icons that have been downloaded (or any other resource). fileutil.copyFiles(joeyAccountDirName, ravenAccountDirName) dom = ZDom() dom.load(accountXmlFileName) newDom = dom.transformToXML(self.accountTransformFilename) newDom.setNamespaceMap(ACCOUNT_NSS_MAP) # Encrypt the account password. passwordNode = newDom.selectSingleNode(u"/zns:account/zns:attributes/zns:attribute[@name = 'password']") #$NON-NLS-1$ if passwordNode: password = crypt.encryptPlainText(passwordNode.getText(), PASSWORD_ENCRYPTION_KEY) passwordNode.setText(password) # convert host, port & path combo to a single url attribute; also determine the raven publisher site/type. self._convertApiInfo(newDom) # account id accId = newDom.documentElement.getAttribute(u"account-id") #$NON-NLS-1$ self.validAccounts[accId] = True # convert blog and id format to raven format blogNodeList = newDom.selectNodes(u"/zns:account/zns:blogs/zns:blog") #$NON-NLS-1$ for blogNode in blogNodeList: self._convertAccBlogInfo(accId, blogNode) # Save to disk. newDom.save(ravenAccountXmlName, True) del dom del newDom
def onPasswordChanged(self, event): if self.enableCB.GetValue(): s = getSafeString(self.passwordTxt.GetValue()) if s: s = crypt.encryptPlainText(s, PASSWORD_ENCRYPTION_KEY) self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_PASSWORD, s) self.onSessionChange() event.Skip()
def _serializeProperties(self, storeProperties, parentElem): if storeProperties is None or len(storeProperties) == 0: return propertiesElem = parentElem.ownerDocument.createElement(u"properties", self.namespace) #$NON-NLS-1$ parentElem.appendChild(propertiesElem) for propKey in storeProperties: propVal = storeProperties[propKey] if propKey == u"password": #$NON-NLS-1$ propVal = encryptPlainText(propVal, PASSWORD_ENCRYPTION_KEY) propertyElem = parentElem.ownerDocument.createElement(u"property", self.namespace) #$NON-NLS-1$ propertiesElem.appendChild(propertyElem) propertyElem.setAttribute(u"name", propKey) #$NON-NLS-1$ propertyElem.setText(propVal)
def _serializeProperties(self, storeProperties, parentElem): if storeProperties is None or len(storeProperties) == 0: return propertiesElem = parentElem.ownerDocument.createElement( u"properties", self.namespace) #$NON-NLS-1$ parentElem.appendChild(propertiesElem) for propKey in storeProperties: propVal = storeProperties[propKey] if propKey == u"password": #$NON-NLS-1$ propVal = encryptPlainText(propVal, PASSWORD_ENCRYPTION_KEY) propertyElem = parentElem.ownerDocument.createElement( u"property", self.namespace) #$NON-NLS-1$ propertiesElem.appendChild(propertyElem) propertyElem.setAttribute(u"name", propKey) #$NON-NLS-1$ propertyElem.setText(propVal)
def setPassword(self, clearTextPass): encpass = crypt.encryptPlainText(clearTextPass.strip(), PASSWORD_ENCRYPTION_KEY) self.setAttribute(u"password", encpass) #$NON-NLS-1$