本文整理汇总了C++中CItemData::SetPassword方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemData::SetPassword方法的具体用法?C++ CItemData::SetPassword怎么用?C++ CItemData::SetPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemData
的用法示例。
在下文中一共展示了CItemData::SetPassword方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void FileV3Test::SetUp()
{
fullItem.CreateUUID();
fullItem.SetTitle(title);
fullItem.SetPassword(password);
fullItem.SetUser(user);
fullItem.SetNotes(notes);
fullItem.SetGroup(group);
fullItem.SetURL(url);
fullItem.SetAutoType(at);
fullItem.SetEmail(email);
fullItem.SetPolicyName(polname);
fullItem.SetSymbols(symbols);
fullItem.SetRunCommand(runcmd);
fullItem.SetATime(aTime);
fullItem.SetCTime(cTime);
fullItem.SetXTime(xTime);
fullItem.SetPMTime(pmTime);
fullItem.SetRMTime(rmTime);
fullItem.SetDCA(iDCA);
fullItem.SetShiftDCA(iSDCA);
fullItem.SetKBShortcut(kbs);
smallItem.CreateUUID();
smallItem.SetTitle(_T("picollo"));
smallItem.SetPassword(_T("tiny-passw"));
}
示例2:
TEST_F(ItemDataTest, PasswordHistory)
{
size_t pwh_max, num_err;
PWHistList pwhl;
const StringX pw1(L"banana-0rchid");
const StringX pw2(L"banana-1rchid");
const StringX pw3(L"banana-2rchid");
const StringX pw4(L"banana-5rchid");
PWSprefs *prefs = PWSprefs::GetInstance();
prefs->SetPref(PWSprefs::SavePasswordHistory, true);
prefs->SetPref(PWSprefs::NumPWHistoryDefault, 3);
CItemData di;
di.SetCTime();
di.SetPassword(pw1); // first time must be Set, not Update!
di.UpdatePassword(pw2);
EXPECT_FALSE(di.GetPWHistory().empty());
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(1, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
di.UpdatePassword(pw3);
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(2, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
EXPECT_EQ(pw2, pwhl[1].password);
di.UpdatePassword(pw4);
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(3, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
EXPECT_EQ(pw2, pwhl[1].password);
EXPECT_EQ(pw3, pwhl[2].password);
di.UpdatePassword(L"Last1");
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(3, pwhl.size());
EXPECT_EQ(pw2, pwhl[0].password);
EXPECT_EQ(pw3, pwhl[1].password);
EXPECT_EQ(pw4, pwhl[2].password);
}
示例3: SetUp
void AliasShortcutTest::SetUp()
{
base.CreateUUID();
base.SetTitle(L"base");
base.SetPassword(L"base-password");
base.SetUser(L"base-user");
base.SetNotes(L"base-notes");
base.SetGroup(L"G");
base.SetURL(L"http://base-url.com");
base.SetAutoType(L"base-autotype");
base.SetEmail(L"[email protected]");
base.SetRunCommand(L"Run base, run");
}
示例4: testAttFile
void FileV4Test::SetUp()
{
hdr.m_prefString = _T("aPrefString");
hdr.m_whenlastsaved = 1413129351; // overwritten in Open()
hdr.m_lastsavedby = _T("aUser");
hdr.m_lastsavedon = _T("aMachine");
hdr.m_whatlastsaved = _T("PasswordSafe test framework");
hdr.m_DB_Name = fname.c_str();
hdr.m_DB_Description = _T("Test the header's persistency");
fullItem.CreateUUID();
fullItem.SetTitle(title);
fullItem.SetPassword(password);
fullItem.SetUser(user);
fullItem.SetNotes(notes);
fullItem.SetGroup(group);
fullItem.SetURL(url);
fullItem.SetAutoType(at);
fullItem.SetEmail(email);
fullItem.SetSymbols(symbols);
fullItem.SetRunCommand(runcmd);
fullItem.SetATime(aTime);
fullItem.SetCTime(cTime);
fullItem.SetXTime(xTime);
fullItem.SetPMTime(pmTime);
fullItem.SetRMTime(rmTime);
fullItem.SetDCA(iDCA);
fullItem.SetShiftDCA(iSDCA);
smallItem.CreateUUID();
smallItem.SetTitle(_T("picollo"));
smallItem.SetPassword(_T("tiny-passw"));
attItem.CreateUUID();
attItem.SetTitle(L"I'm an attachment");
const stringT testAttFile(L"data/image1.jpg");
int status = attItem.Import(testAttFile);
ASSERT_EQ(PWSfile::SUCCESS, status);
}
示例5:
TEST_F(AliasShortcutTest, Alias)
{
CItemData al;
al.CreateUUID();
al.SetTitle(L"alias");
al.SetPassword(L"alias-password-not-used");
al.SetUser(L"alias-user");
al.SetNotes(L"alias-notes");
al.SetGroup(L"Galias");
al.SetURL(L"http://alias-url.com");
al.SetAutoType(L"alias-autotype");
al.SetEmail(L"[email protected]");
al.SetRunCommand(L"Run alias, run");
al.SetAlias();
const pws_os::CUUID base_uuid = base.GetUUID();
MultiCommands *pmulticmds = MultiCommands::Create(&core);
pmulticmds->Add(AddEntryCommand::Create(&core, base));
pmulticmds->Add(AddEntryCommand::Create(&core, al, base_uuid));
core.Execute(pmulticmds);
EXPECT_EQ(2, core.GetNumEntries());
const CItemData al2 = core.GetEntry(core.Find(al.GetUUID()));
StringX sx_group, sx_title, sx_user, sx_pswd, sx_lastpswd, sx_notes, sx_url, sx_email, sx_autotype, sx_runcmd;
bool status = PWSAuxParse::GetEffectiveValues(&al2, &base,
sx_group, sx_title, sx_user, sx_pswd, sx_lastpswd, sx_notes,
sx_url, sx_email, sx_autotype, sx_runcmd);
EXPECT_TRUE(status);
// Password should be from base:
EXPECT_EQ(sx_pswd, base.GetPassword());
// All the rest should be from alias:
EXPECT_EQ(sx_group, al.GetGroup());
EXPECT_EQ(sx_title, al.GetTitle());
EXPECT_EQ(sx_user, al.GetUser());
EXPECT_EQ(sx_lastpswd, L"");
EXPECT_EQ(sx_notes, al.GetNotes());
EXPECT_EQ(sx_url, al.GetURL());
EXPECT_EQ(sx_email, al.GetEmail());
EXPECT_EQ(sx_autotype, al.GetAutoType());
EXPECT_EQ(sx_runcmd, al.GetRunCommand());
}
示例6:
TEST_F(CommandsTest, AddItem)
{
CItemData di;
di.CreateUUID();
di.SetTitle(L"a title");
di.SetPassword(L"a password");
const pws_os::CUUID uuid = di.GetUUID();
AddEntryCommand *pcmd = AddEntryCommand::Create(&core, di);
core.Execute(pcmd);
ItemListConstIter iter = core.Find(uuid);
ASSERT_NE(core.GetEntryEndIter(), iter);
EXPECT_EQ(di, core.GetEntry(iter));
core.Undo();
EXPECT_EQ(0, core.GetNumEntries());
delete pcmd;
}
示例7: rname
int PWSfileV1V2::WriteV2Header()
{
CItemData header;
// Fill out with V2-specific info
// To make a dictionary attack a little harder, we make the length
// of the first record (Name) variable, by appending variable length randomness
// to the fixed string
// OOPS - can't do this yet, since previous versions (pre-2.14) read the name
// (in ReadV2Header)
// and compare it directly to VersionString to check version - a small
// mistake that would cause a pre-2.14 executable to barf reading a database
// written by 2.14 and later.
// #idef-ing this out, while correcting the code
// in ReadV2Header. Perhaps this can be fixed a year from now?
#ifdef BREAK_PRE_2_14_COMPATIBILITY
unsigned int rlen = RangeRand(62) + 2; // 64 is a trade-off...
char *rbuf = new char[rlen];
PWSrand::GetInstance()->GetRandomData(rbuf, rlen-1);
rbuf[rlen-1] = TCHAR('\0'); // although zero may be there before - who cares?
stringT rname(V2ItemName);
rname += rbuf;
delete[] rbuf;
header.SetName(rname, _T(""));
#else
header.SetName(V2ItemName, _T(""));
#endif /* BREAK_PRE_2_14_COMPATIBILITY */
header.SetPassword(VersionString);
header.SetNotes(m_hdr.m_prefString);
// need to fallback to V17, since the record
// won't be readable otherwise!
VERSION sv = m_curversion;
m_curversion = V17;
int status = WriteRecord(header);
// restore after writing V17-format header
m_curversion = sv;
m_hdr.m_nCurrentMajorVersion = 2;
m_hdr.m_nCurrentMinorVersion = 0;
return status;
}
示例8: SetUp
void ItemDataTest::SetUp()
{
fullItem.SetTitle(title);
fullItem.SetPassword(password);
fullItem.SetUser(user);
fullItem.SetNotes(notes);
fullItem.SetGroup(group);
fullItem.SetURL(url);
fullItem.SetAutoType(at);
fullItem.SetEmail(email);
fullItem.SetPolicyName(polname);
fullItem.SetSymbols(symbols);
fullItem.SetRunCommand(runcmd);
fullItem.SetATime(aTime);
fullItem.SetCTime(cTime);
fullItem.SetXTime(xTime);
fullItem.SetPMTime(pmTime);
fullItem.SetRMTime(rmTime);
fullItem.SetDCA(iDCA);
fullItem.SetShiftDCA(iSDCA);
fullItem.SetXTimeInt(xTimeInt);
fullItem.SetKBShortcut(kbs);
}
示例9: ASSERT
int PWSfileV1V2::ReadRecord(CItemData &item)
{
ASSERT(m_fd != NULL);
ASSERT(m_curversion != UNKNOWN_VERSION);
StringX tempdata;
signed long numread = 0;
unsigned char type;
switch (m_curversion) {
case V17:
{
// type is meaningless, but why write two versions of ReadCBC?
numread += static_cast<signed long>(ReadCBC(type, tempdata));
item.SetName(tempdata, m_defusername);
numread += static_cast<signed long>(ReadCBC(type, tempdata));
item.SetPassword(tempdata);
numread += static_cast<signed long>(ReadCBC(type, tempdata));
item.SetNotes(tempdata);
// No UUID, so we create one here
item.CreateUUID();
// No Group - currently leave empty
return (numread > 0) ? SUCCESS : END_OF_FILE;
}
case V20:
{
int emergencyExit = 255; // to avoid endless loop.
signed long fieldLen; // zero means end of file reached
bool endFound = false; // set to true when record end detected - happy end
do {
fieldLen = static_cast<signed long>(ReadCBC(type, tempdata));
if (signed(fieldLen) > 0) {
numread += fieldLen;
switch (type) {
case CItemData::TITLE:
item.SetTitle(tempdata); break;
case CItemData::USER:
item.SetUser(tempdata); break;
case CItemData::PASSWORD:
item.SetPassword(tempdata); break;
case CItemData::NOTES:
{
StringX autotypeStr, URLStr;
ExtractAutoTypeCmd(tempdata, autotypeStr);
ExtractURL(tempdata, URLStr);
item.SetNotes(tempdata);
if (!autotypeStr.empty())
item.SetAutoType(autotypeStr);
if (!URLStr.empty())
item.SetURL(URLStr);
break;
}
case CItemData::END:
endFound = true; break;
case CItemData::UUID:
{
LPCTSTR ptr = tempdata.c_str();
uuid_array_t uuid_array;
for (size_t i = 0; i < sizeof(uuid_array_t); i++)
uuid_array[i] = static_cast<unsigned char>(ptr[i]);
item.SetUUID(uuid_array);
break;
}
case CItemData::GROUP:
item.SetGroup(tempdata); break;
// just silently ignore fields we don't support.
// this is forward compatability...
case CItemData::CTIME:
case CItemData::PMTIME:
case CItemData::ATIME:
case CItemData::XTIME:
case CItemData::RMTIME:
case CItemData::POLICY:
case CItemData::XTIME_INT:
default:
break;
} // switch
} // if (fieldLen > 0)
} while (!endFound && fieldLen > 0 && --emergencyExit > 0);
return (numread > 0 && endFound) ? SUCCESS : END_OF_FILE;
}
default:
ASSERT(0);
return UNSUPPORTED_VERSION;
}
}