private void GetAllLoginsHandler(Request r, Response resp, Aes aes) { if (!VerifyRequest(r, aes)) { return; } var root = host.Database.RootGroup; var list = root.GetEntries(true); foreach (var entry in list) { var name = entry.Strings.ReadSafe(PwDefs.TitleField); var login = GetUserPass(entry)[0]; var password = GetUserPass(entry)[1]; var uuid = entry.Uuid.ToHexString(); var group = new ResponseGroupField(entry.ParentGroup.GetFullPath("/", true), entry.ParentGroup.Uuid.ToHexString()); var e = new ResponseEntry(name, login, password, uuid, group, null, IsEntryRecycled(entry)); resp.Entries.Add(e); } resp.Success = true; resp.Id = r.Id; SetResponseVerifier(resp, aes); foreach (var entry in resp.Entries) { entry.Name = CryptoTransform(entry.Name, false, true, aes, CMode.ENCRYPT); entry.Login = CryptoTransform(entry.Login, false, true, aes, CMode.ENCRYPT); entry.Password = CryptoTransform(entry.Password, false, true, aes, CMode.ENCRYPT); entry.Uuid = CryptoTransform(entry.Uuid, false, true, aes, CMode.ENCRYPT); entry.IsRecycled = CryptoTransform(entry.IsRecycled, false, true, aes, CMode.ENCRYPT); entry.Group.Name = CryptoTransform(entry.Group.Name, false, true, aes, CMode.ENCRYPT); entry.Group.Uuid = CryptoTransform(entry.Group.Uuid, false, true, aes, CMode.ENCRYPT); } }
public ResponseEntry(string name, string login, string password, string uuid, ResponseGroupField group, List <ResponseStringField> stringFields, string isRecycled) { Login = login; Password = password; Uuid = uuid; Name = name; Group = group; StringFields = stringFields; IsRecycled = isRecycled; }
private ResponseEntry PrepareElementForResponseEntries(ConfigOpt configOpt, PwEntryDatabase entryDatabase) { SprContext ctx = new SprContext(entryDatabase.entry, entryDatabase.database, SprCompileFlags.All, false, false); var name = entryDatabase.entry.Strings.ReadSafe(PwDefs.TitleField); var loginpass = GetUserPass(entryDatabase, ctx); var login = loginpass[0]; var passwd = loginpass[1]; var uuid = entryDatabase.entry.Uuid.ToHexString(); var group = new ResponseGroupField(entryDatabase.entry.ParentGroup.GetFullPath("/", true), entryDatabase.entry.ParentGroup.Uuid.ToHexString()); List <ResponseStringField> fields = null; if (configOpt.ReturnStringFields) { fields = new List <ResponseStringField>(); foreach (var sf in entryDatabase.entry.Strings) { var sfValue = entryDatabase.entry.Strings.ReadSafe(sf.Key); // follow references sfValue = SprEngine.Compile(sfValue, ctx); if (configOpt.ReturnStringFieldsWithKphOnly) { if (sf.Key.StartsWith("KPH: ")) { fields.Add(new ResponseStringField(sf.Key.Substring(5), sfValue)); } } else { fields.Add(new ResponseStringField(sf.Key, sfValue)); } } if (fields.Count > 0) { var fields2 = from e2 in fields orderby e2.Key ascending select e2; fields = fields2.ToList <ResponseStringField>(); } else { fields = null; } } return(new ResponseEntry(name, login, passwd, uuid, group, fields, IsEntryRecycled(entryDatabase.entry))); }