public void GetAllUserRootNodesReturnsOnlyValidRootNodes() { m_treeManager.Initialize(m_database); PwEntry root1 = new PwEntry(true, true); PwEntry root2 = new PwEntry(true, true); PwEntry root3 = new PwEntry(true, true); PwEntry normalEntry1 = new PwEntry(true, true); PwEntry normalEntry2 = new PwEntry(true, true); PwGroup level1 = new PwGroup(); //initial data root1.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString(false, root1.Uuid.ToHexString())); root2.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString(false, root2.Uuid.ToHexString())); root3.Strings.Set(KeeShare.KeeShare.UuidLinkField, new ProtectedString(false, root3.Uuid.ToHexString())); m_database.RootGroup.AddEntry(root1, true); m_database.RootGroup.AddEntry(root2, true); m_database.RootGroup.AddEntry(normalEntry1, true); m_database.RootGroup.AddGroup(level1, true); level1.AddEntry(normalEntry2, true); level1.AddEntry(root3, true); PwObjectList <PwEntry> rootNodes = m_database.GetAllUserNodes(); Assert.AreEqual(3, rootNodes.UCount); Assert.AreEqual(root1, rootNodes.GetAt(0)); Assert.AreEqual(root2, rootNodes.GetAt(1)); Assert.AreEqual(root3, rootNodes.GetAt(2)); }
/// <summary> /// Ensures the all rootNodes for the userEntries are located in the /// usersGroup. /// </summary> private Changes FixSharingNodesForAllUsers() { PwObjectList <PwEntry> userNodes = m_database.GetAllUserNodes(); Changes changeFlag = Changes.None; foreach (PwEntry userNode in userNodes) { changeFlag |= FixSharingNodesFor(userNode); } return(changeFlag); }
private void ExportUsersFolder(PwDatabase database, PwGroup selectedGroup) { //if we try to export for the whole "Users"-folder, we export //the passwords for all users here. if (selectedGroup == database.GetUsersGroup()) { PwObjectList <PwEntry> allRoots = database.GetAllUserNodes(); foreach (PwEntry rootNode in allRoots) { Export(database, rootNode); } } }
/// <summary> /// Checks if the given entry is a proxy of a UserRootNode /// </summary> /// <param name="entry">the entry you want to check</param> /// <returns>True if the entry is a UserProxy</returns> public static bool IsUserProxy(this PwDatabase database, PwEntry entry) { if (!entry.IsProxyNode()) { return(false); } Debug.Assert(database != null); foreach (PwEntry root in database.GetAllUserNodes()) { if (root.Uuid.ToHexString() == entry.Strings.ReadSafe(KeeShare.UuidLinkField)) { return(true); } } return(false); }
/// <summary> /// The function checks if there are any changes and if so, it automatically starts /// to export everything new. /// </summary> public void Export(PwDatabase database) { PwObjectList <PwEntry> allUsers = database.GetAllUserNodes(); foreach (PwEntry root in allUsers) { // Currently there is no way to check, if nodes were added which have a time older than the last export time // using the import tool or our own synchronization - it would be possible to open the last export and only // update the differences, but this would be prone to errorsdue to the complexity - therefore we use the // pessimistic way and export everything at once and let KeePass-MergeIn handle the load //long lastExport; //if( Int64.TryParse(root.Strings.ReadSafe(KeeShare.StringFieldLastExport), out lastExport)) //{ // //we check every shared item for a change after the lastExport // PwObjectList<PwGroup> sharedFolders = GetSharedFolders(database, root); // foreach (PwGroup group in sharedFolders) // { // bool done = false; // foreach (PwEntry entry in group.Entries) // { // //if we find some entry that was changed after the last export, then we create a new delta-container // //and export it. after that we can stop the search and continue with the next user. // if (lastExport < entry.LastModificationTime.Ticks // || lastExport < entry.CreationTime.Ticks) // { // Console.WriteLine("EXPORT TIMED FOR" + root.Strings.ReadSafe(KeeShare.TitleField)); // Export(database, root); // done = true; // break; // } // Console.WriteLine("NO EXPORT TIMED FOR" + root.GetTitle() + " " + lastExport + " " + entry.GetTitle() + " " + entry.LastModificationTime.Ticks); // } // if (done == true) // { // break; // } // } //} //else //{ //if we could not get the lastExportDate we go for sure and export everything for that user! Export(database, root); //} } }