private StringBuffer getUsersPassword() { // get password: final EnterPasswordDialog pwdDialog = new EnterPasswordDialog( (JFrame) getMindMapController().getFrame(), getMindMapController(), true); pwdDialog.setModal(true); pwdDialog.show(); if (pwdDialog.getResult() == EnterPasswordDialog.CANCEL) { return null; } final StringBuffer password = pwdDialog.getPassword(); return password; }
public void setFolded(boolean folded) { if (isDecrypted || folded) { super.setFolded(folded); return; } ControllerAdapter browseController = (ControllerAdapter) mModeController; // get password: final EnterPasswordDialog pwdDialog = new EnterPasswordDialog(null, browseController, false); pwdDialog.setModal(true); pwdDialog.show(); if (pwdDialog.getResult() == EnterPasswordDialog.CANCEL) { return; } SingleDesEncrypter encrypter = new SingleDesEncrypter(pwdDialog.getPassword()); // Decrypt String decrypted = encrypter.decrypt(encryptedContent); if (decrypted == null) return; String[] childs = decrypted.split(ModeController.NODESEPARATOR); // and now? paste it: for (int i = childs.length - 1; i >= 0; i--) { String string = childs[i]; logger.finest("Decrypted '" + string + "'."); // if the encrypted node is empty, we skip the insert. if (string.length() == 0) continue; try { NodeAdapter node = (NodeAdapter) browseController.createNodeTreeFromXml(new StringReader(string)); // now, the import is finished. We can inform others about // the new nodes: browseController.insertNodeInto(node, this); MapAdapter model = browseController.getModel(); browseController.invokeHooksRecursively(node, model); super.setFolded(folded); browseController.nodeChanged(this); browseController.nodeStructureChanged(this); isDecrypted = true; updateIcon(); } catch (XMLParseException e) { freemind.main.Resources.getInstance().logException(e); return; } catch (IOException e) { freemind.main.Resources.getInstance().logException(e); return; } } }