/// <summary> /// initializes the Usermanager. /// for now it only creates the relevant PwGroups if they are not existing yet. /// </summary> public void Initialize(PwDatabase database) { Debug.Assert(null != database); m_database = database; //====================== autocreating the neccassary groups ================================== m_database.GetUsersGroup(); m_database.GetGroupsGroup(); }
/// <summary> /// The functions tests if a group is a special group which was created for /// PwdSahre only. /// </summary> /// <param name="group">The group we want to test.</param> /// <returns>True if the specified group was a special KeeShare group.</returns> private bool IsKeeShareFolder(PwDatabase database, PwGroup group) { Debug.Assert(group != null); //only three groups are interesting for us: "Users" / "Groups" / "SyncGroup" return(group.ParentGroup != null && (group.IsInsideParent(database.GetUsersGroup()) || group.IsInsideParent(database.GetGroupsGroup()) || group.IsInsideParent(database.GetSyncGroup()))); }
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); } } }
public void MoveUserHomeToAnotheruserShoudlBeReverted() { m_treeManager.Initialize(m_database); m_treeManager.CreateNewUser("mrY"); m_treeManager.CreateNewUser("mrZ"); PwGroup homeY = TestHelper.GetUserHomeNodeByNameFor(m_database, "mrY"); PwGroup homeZ = TestHelper.GetUserHomeNodeByNameFor(m_database, "mrZ"); PwUuid homeYid = homeY.Uuid; PwUuid homeZid = homeZ.Uuid; homeY.ParentGroup.Groups.Remove(homeY); homeZ.AddGroup(homeY, true); Assert.AreEqual(1, m_database.GetUsersGroup().Groups.UCount); m_treeManager.CorrectStructure(); Assert.AreEqual(2, m_database.GetUsersGroup().Groups.UCount); homeY = TestHelper.GetGroupByUuidFor(m_database, homeYid); homeZ = TestHelper.GetGroupByUuidFor(m_database, homeZid); Assert.AreEqual(1, homeY.Entries.UCount); Assert.AreEqual(0, homeY.Groups.UCount); Assert.AreEqual(1, homeZ.Entries.UCount); Assert.AreEqual(0, homeZ.Groups.UCount); Assert.AreEqual(4, NumberOfEntriesIn(m_database)); }
/// <summary> /// a fuction which returns a list of all folder which are shared to a specified user /// </summary> /// <param name="userRoot">The rootNode of the user you want to export you data to.</param> /// <returns>A <c>PwObjectList<PwGroup></c> which contains all PwGroups which are shared to /// the given user.</returns> public PwObjectList <PwGroup> GetSharedFolders(PwDatabase database, PwEntry userRoot) { PwObjectList <PwGroup> sharedFolders = new PwObjectList <PwGroup>(); foreach (PwEntry proxy in database.GetAllProxyNodes()) { if (userRoot.Uuid.ToHexString() == proxy.Strings.ReadSafe(KeeShare.UuidLinkField)) { PwGroup group = proxy.ParentGroup; //we don't want to share the "Users"-folder, so if we find it, we skip it! if (group == database.GetUsersGroup()) { continue; } sharedFolders.Add(group); //include all subfolders sharedFolders.Add(group.GetGroups(true)); } } //find the homeFolder and add it to the sharedList sharedFolders.Add(database.GetUserHomeFor(userRoot)); return(sharedFolders); }
/// <summary> /// The <c>CreateNewUser</c> function creates a new user you /// later can share passwords with. /// This includes a proxy in the UsersGroupName group and also /// creates a new user-specific group in the tree UsersGroupName /// </summary> /// <param name="name">oldUserName of the new user</param> /// <returns>True if all is done properly! False otherwise!</returns> protected Changes CreateNewUser(string name, PwGroup useAsHome = null) { PwEntry newUser = CreateUserNode(name); PwGroup newUserGroup = useAsHome; if (newUserGroup == null) //create a new home for that user { newUserGroup = m_database.GetUserHomeFor(newUser, true); } else { newUserGroup.IconId = PwIcon.UserKey; newUserGroup.Notes += newUser.Uuid.ToHexString(); } //put the userRootNode into his homefolder newUser.SetParent(newUserGroup); //due to better userHandling while dragNdrop we create a proxyNode in the usersGroup PwEntry proxy = newUser.CreateProxyNode(); proxy.SetParent(m_database.GetUsersGroup()); return(Changes.GroupCreated | Changes.EntryCreated); }
private void FillInFixture() { PwGroup rootGroup = m_database.RootGroup; m_treeManager.CreateNewUser("mrX"); m_treeManager.CreateNewUser("mrY"); m_standardKey = SyncSource.CreateKeyFor(STANDARD_PASSWORD); PwEntry mrX = TestHelper.GetUserRootNodeByNameFor(m_database, "mrX"); PwEntry mrY = TestHelper.GetUserRootNodeByNameFor(m_database, "mrY"); mrX.SetPassword(STANDARD_PASSWORD); mrY.SetPassword(STANDARD_PASSWORD); PwGroup mrXhome = m_database.GetUsersGroup().Groups.GetAt(0); //normal entries PwEntry normalEntry1 = new PwEntry(true, false); normalEntry1.SetTitle("normalEntry1"); Uuid1 = normalEntry1.Uuid; PwEntry normalEntry2 = new PwEntry(true, false); normalEntry2.SetTitle("normalEntry2"); Uuid2 = normalEntry2.Uuid; PwEntry normalEntry3 = new PwEntry(true, false); normalEntry3.SetTitle("normalEntry3"); Uuid3 = normalEntry3.Uuid; PwEntry normalEntry4 = new PwEntry(true, false); normalEntry4.SetTitle("normalEntry4"); Uuid4 = normalEntry4.Uuid; PwEntry normalEntry5 = new PwEntry(true, false); normalEntry5.SetTitle("normalEntry5"); Uuid5 = normalEntry5.Uuid; PwEntry normalEntry6 = new PwEntry(true, false); normalEntry6.SetTitle("normalEntry6"); Uuid6 = normalEntry6.Uuid; //pwdProxies PwEntry pwdProxyTo1 = normalEntry1.CreateProxyNode(); PwEntry pwdProxyTo3 = normalEntry3.CreateProxyNode(); //userProxies PwEntry userProxyToMrX = mrX.CreateProxyNode(); PwGroup grp1 = new PwGroup(true, true, "grp1", PwIcon.BlackBerry); rootGroup.AddEntry(normalEntry1, true); rootGroup.AddEntry(normalEntry2, true); rootGroup.AddEntry(normalEntry3, true); rootGroup.AddGroup(grp1, true); grp1.AddEntry(normalEntry4, true); grp1.AddEntry(normalEntry5, true); grp1.AddEntry(userProxyToMrX, true); grp1.AddEntry(pwdProxyTo1, true); mrXhome.AddEntry(normalEntry6, true); mrXhome.AddEntry(pwdProxyTo3, true); Assert.AreEqual(13, rootGroup.GetEntries(true).UCount); }