상속: PwCommon
 public void GetEntry()
 {
     PwGroup = _databaserSource.PwDatabase.Tree.FindGroupByUuid(ParentGroupUuid);
     if (EntryUuid != null)
     {
         PwEntry = PwGroup.Entries.SingleOrDefault(e => e.UUID == EntryUuid);
         Title = PwEntry.Title;
         Username = PwEntry.Username;
         Password = PwEntry.Password;
         Url = PwEntry.Url;
         Notes = PwEntry.Notes;
         CustomFields.AddRange(PwEntry.CustomFields.Select(cf => new FieldViewModel(cf)));
     }
     
 }
예제 #2
0
 protected Uri GetPasswordUri(PwEntry password)
 {
     if (password != null)
     {
         Uri parsedUri;
         Uri.TryCreate(password.Url, UriKind.RelativeOrAbsolute, out parsedUri);
         if (parsedUri != null && parsedUri.IsWellFormedOriginalString())
         {
             try
             {
                 string uriScheme = parsedUri.Scheme;
             }
             catch (InvalidOperationException)
             {
                 // I know ... WTF right?!?!? The Scheme property doesn't return null or empty if it wasn't part of the original URL string. It throws an exception.
                 parsedUri = new Uri("http://" + parsedUri.OriginalString);
             }
             return parsedUri;
         }
     }
     return new Uri("");
 }
예제 #3
0
 public void AddEntryToDocument(PwEntry entry)
 {
     var lastEntry = Element.Elements("Entry").LastOrDefault();
     if (lastEntry != null)
     {
         lastEntry.AddAfterSelf(entry.Element);
     }
     else
     {
         Element.Add(entry.Element);
     }
     _entries.Add(entry);
 }
예제 #4
0
        public static PwEntry New(PwGroup parent)     
        {
            var entryTemplate = @"
                <Entry>
                    <UUID>{0}</UUID>
                    <IconID>0</IconID>
                    <Times>
                        <LastModificationTime>{1}</LastModificationTime>
                        <CreationTime>{1}</CreationTime>
                        <LastAccessTime>{1}</LastAccessTime>
                        <ExpiryTime>{1}</ExpiryTime>
                        <LocationChanged>{1}</LocationChanged>
                        <Expires>False</Expires>
                        <UsageCount>0</UsageCount>
                    </Times>
                    <String>
                        <Key>Title</Key>
                        <Value>{2}</Value>
                    </String>
                    <String>
                        <Key>UserName</Key>
                        <Value>{3}</Value>
                    </String>
                    <String>
                        <Key>Password</Key>
                        <Value Protected=""True"">{4}</Value>
                    </String>
                    <String>
                        <Key>URL</Key>
                        <Value>{5}</Value>
                    </String>
                    <String>
                        <Key>Notes</Key>
                        <Value>{6}</Value>
                    </String>
                </Entry>
            ";
            var uuid = new PwUuid(true);

            entryTemplate = String.Format(entryTemplate, 
                Convert.ToBase64String(uuid.UuidBytes), 
                DateTime.Now.ToFormattedUtcTime(), 
                Sanitize("Title"), 
                Sanitize("Username"), 
                Sanitize("Password") ,
                Sanitize("Url") , 
                Sanitize("Notes"));

            var element = XElement.Parse(entryTemplate);
            var pwEntry = new PwEntry(element,parent);
            parent.AddEntryToDocument(pwEntry);
           
            return pwEntry;
        }