mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Start factorise
This commit is contained in:
@@ -42,7 +42,7 @@ public class PwEntryTestV3 extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testName() {
|
public void testName() {
|
||||||
assertTrue("Name was " + mPE.title, mPE.title.equals("Amazon"));
|
assertTrue("Name was " + mPE.getTitle(), mPE.getTitle().equals("Amazon"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPassword() throws UnsupportedEncodingException {
|
public void testPassword() throws UnsupportedEncodingException {
|
||||||
@@ -54,7 +54,7 @@ public class PwEntryTestV3 extends AndroidTestCase {
|
|||||||
|
|
||||||
public void testCreation() {
|
public void testCreation() {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime(mPE.tCreation.getJDate());
|
cal.setTime(mPE.getCreationTime().getDate());
|
||||||
|
|
||||||
assertEquals("Incorrect year.", cal.get(Calendar.YEAR), 2009);
|
assertEquals("Incorrect year.", cal.get(Calendar.YEAR), 2009);
|
||||||
assertEquals("Incorrect month.", cal.get(Calendar.MONTH), 3);
|
assertEquals("Incorrect month.", cal.get(Calendar.MONTH), 3);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class PwEntryTestV4 extends TestCase {
|
|||||||
entry.parent = new PwGroupV4();
|
entry.parent = new PwGroupV4();
|
||||||
entry.addField("key2", new ProtectedString(false, "value2"));
|
entry.addField("key2", new ProtectedString(false, "value2"));
|
||||||
entry.url = "http://localhost";
|
entry.url = "http://localhost";
|
||||||
entry.uuid = UUID.randomUUID();
|
entry.setUUID(UUID.randomUUID());
|
||||||
|
|
||||||
PwEntryV4 target = new PwEntryV4();
|
PwEntryV4 target = new PwEntryV4();
|
||||||
target.assign(entry);
|
target.assign(entry);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class PwGroupTest extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testGroupName() {
|
public void testGroupName() {
|
||||||
assertTrue("Name was " + mPG.name, mPG.name.equals("Internet"));
|
assertTrue("Name was " + mPG.getName(), mPG.getName().equals("Internet"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ import biz.source_code.base64Coder.Base64Coder;
|
|||||||
import com.keepassdroid.database.PwDatabaseV4;
|
import com.keepassdroid.database.PwDatabaseV4;
|
||||||
import com.keepassdroid.database.PwEntryV4;
|
import com.keepassdroid.database.PwEntryV4;
|
||||||
import com.keepassdroid.database.load.ImporterV4;
|
import com.keepassdroid.database.load.ImporterV4;
|
||||||
import com.keepassdroid.utils.SprEngine;
|
import com.keepassdroid.utils.SprEngineV4;
|
||||||
import com.keepassdroid.utils.Types;
|
import com.keepassdroid.utils.Types;
|
||||||
|
|
||||||
public class SprEngineTest extends AndroidTestCase {
|
public class SprEngineTest extends AndroidTestCase {
|
||||||
private PwDatabaseV4 db;
|
private PwDatabaseV4 db;
|
||||||
private SprEngine spr;
|
private SprEngineV4 spr;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
@@ -51,7 +51,7 @@ public class SprEngineTest extends AndroidTestCase {
|
|||||||
|
|
||||||
is.close();
|
is.close();
|
||||||
|
|
||||||
spr = SprEngine.getInstance(db);
|
spr = new SprEngineV4();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String REF = "{REF:P@I:2B1D56590D961F48A8CE8C392CE6CD35}";
|
private final String REF = "{REF:P@I:2B1D56590D961F48A8CE8C392CE6CD35}";
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
fillData();
|
fillData();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
|
||||||
|
// TODO Start decode
|
||||||
|
|
||||||
// If notifications enabled in settings
|
// If notifications enabled in settings
|
||||||
// Don't if application timeout
|
// Don't if application timeout
|
||||||
if (firstLaunchOfActivity && !App.isShutdown() && isClipboardNotificationsEnable(getApplicationContext())) {
|
if (firstLaunchOfActivity && !App.isShutdown() && isClipboardNotificationsEnable(getApplicationContext())) {
|
||||||
@@ -177,7 +179,7 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
if (mEntry.allowExtraFields()) {
|
if (mEntry.allowExtraFields()) {
|
||||||
try {
|
try {
|
||||||
int anonymousFieldNumber = 0;
|
int anonymousFieldNumber = 0;
|
||||||
for (Map.Entry<String, String> entry : mEntry.getExtraFields(App.getDB().pm).entrySet()) {
|
for (Map.Entry<String, String> entry : mEntry.getExtraFields().entrySet()) {
|
||||||
notificationFields.add(
|
notificationFields.add(
|
||||||
new NotificationField(
|
new NotificationField(
|
||||||
NotificationField.NotificationFieldId.getAnonymousFieldId()[anonymousFieldNumber],
|
NotificationField.NotificationFieldId.getAnonymousFieldId()[anonymousFieldNumber],
|
||||||
@@ -196,6 +198,7 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
|
|
||||||
startService(intent);
|
startService(intent);
|
||||||
}
|
}
|
||||||
|
// TODO end decode
|
||||||
}
|
}
|
||||||
firstLaunchOfActivity = false;
|
firstLaunchOfActivity = false;
|
||||||
}
|
}
|
||||||
@@ -209,34 +212,36 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
Database db = App.getDB();
|
Database db = App.getDB();
|
||||||
PwDatabase pm = db.pm;
|
PwDatabase pm = db.pm;
|
||||||
|
|
||||||
|
mEntry.startToDecodeReference(pm);
|
||||||
|
|
||||||
// Assign title
|
// Assign title
|
||||||
populateTitle(db.drawFactory.getIconDrawable(getResources(), mEntry.getIcon()),
|
populateTitle(db.drawFactory.getIconDrawable(getResources(), mEntry.getIcon()),
|
||||||
mEntry.getTitle(true, pm));
|
mEntry.getTitle());
|
||||||
|
|
||||||
// Assign basic fields
|
// Assign basic fields
|
||||||
entryContentsView.assignUserName(mEntry.getUsername(true, pm));
|
entryContentsView.assignUserName(mEntry.getUsername());
|
||||||
entryContentsView.assignUserNameCopyListener(view ->
|
entryContentsView.assignUserNameCopyListener(view ->
|
||||||
clipboardHelper.timeoutCopyToClipboard(mEntry.getUsername(true, App.getDB().pm),
|
clipboardHelper.timeoutCopyToClipboard(mEntry.getUsername(),
|
||||||
getString(R.string.copy_field, getString(R.string.entry_user_name)))
|
getString(R.string.copy_field, getString(R.string.entry_user_name)))
|
||||||
);
|
);
|
||||||
|
|
||||||
entryContentsView.assignPassword(mEntry.getPassword(true, pm));
|
entryContentsView.assignPassword(mEntry.getPassword());
|
||||||
if (PreferencesUtil.allowCopyPassword(this)) {
|
if (PreferencesUtil.allowCopyPassword(this)) {
|
||||||
entryContentsView.assignPasswordCopyListener(view ->
|
entryContentsView.assignPasswordCopyListener(view ->
|
||||||
clipboardHelper.timeoutCopyToClipboard(mEntry.getPassword(true, App.getDB().pm),
|
clipboardHelper.timeoutCopyToClipboard(mEntry.getPassword(),
|
||||||
getString(R.string.copy_field, getString(R.string.entry_password)))
|
getString(R.string.copy_field, getString(R.string.entry_password)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
entryContentsView.assignURL(mEntry.getUrl(true, pm));
|
entryContentsView.assignURL(mEntry.getUrl());
|
||||||
|
|
||||||
entryContentsView.setHiddenPasswordStyle(!mShowPassword);
|
entryContentsView.setHiddenPasswordStyle(!mShowPassword);
|
||||||
entryContentsView.assignComment(mEntry.getNotes(true, pm));
|
entryContentsView.assignComment(mEntry.getNotes());
|
||||||
|
|
||||||
// Assign custom fields
|
// Assign custom fields
|
||||||
if (mEntry.allowExtraFields()) {
|
if (mEntry.allowExtraFields()) {
|
||||||
entryContentsView.clearExtraFields();
|
entryContentsView.clearExtraFields();
|
||||||
for (Map.Entry<String, String> field : mEntry.getExtraFields(pm).entrySet()) {
|
for (Map.Entry<String, String> field : mEntry.getExtraFields().entrySet()) {
|
||||||
final String label = field.getKey();
|
final String label = field.getKey();
|
||||||
final String value = field.getValue();
|
final String value = field.getValue();
|
||||||
entryContentsView.addExtraField(label, value, view ->
|
entryContentsView.addExtraField(label, value, view ->
|
||||||
@@ -245,15 +250,17 @@ public class EntryActivity extends LockingHideActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assign dates
|
// Assign dates
|
||||||
entryContentsView.assignCreationDate(mEntry.getCreationTime());
|
entryContentsView.assignCreationDate(mEntry.getCreationTime().getDate());
|
||||||
entryContentsView.assignModificationDate(mEntry.getLastModificationTime());
|
entryContentsView.assignModificationDate(mEntry.getLastModificationTime().getDate());
|
||||||
entryContentsView.assignLastAccessDate(mEntry.getLastAccessTime());
|
entryContentsView.assignLastAccessDate(mEntry.getLastAccessTime().getDate());
|
||||||
Date expires = mEntry.getExpiryTime();
|
Date expires = mEntry.getExpiryTime().getDate();
|
||||||
if ( mEntry.expires() ) {
|
if ( mEntry.expires() ) {
|
||||||
entryContentsView.assignExpiresDate(expires);
|
entryContentsView.assignExpiresDate(expires);
|
||||||
} else {
|
} else {
|
||||||
entryContentsView.assignExpiresDate(getString(R.string.never));
|
entryContentsView.assignExpiresDate(getString(R.string.never));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mEntry.endToDecodeReference(pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import com.keepassdroid.app.App;
|
|||||||
import com.keepassdroid.database.Database;
|
import com.keepassdroid.database.Database;
|
||||||
import com.keepassdroid.database.PwDatabase;
|
import com.keepassdroid.database.PwDatabase;
|
||||||
import com.keepassdroid.database.PwDatabaseV4;
|
import com.keepassdroid.database.PwDatabaseV4;
|
||||||
|
import com.keepassdroid.database.PwDate;
|
||||||
import com.keepassdroid.database.PwEntry;
|
import com.keepassdroid.database.PwEntry;
|
||||||
import com.keepassdroid.database.PwEntryV4;
|
import com.keepassdroid.database.PwEntryV4;
|
||||||
import com.keepassdroid.database.PwGroup;
|
import com.keepassdroid.database.PwGroup;
|
||||||
@@ -254,12 +255,14 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
|
|
||||||
PwEntry newEntry = mEntry.clone(true);
|
PwEntry newEntry = mEntry.clone(true);
|
||||||
|
|
||||||
Date now = Calendar.getInstance().getTime();
|
newEntry.setLastAccessTime(new PwDate());
|
||||||
newEntry.setLastAccessTime(now);
|
newEntry.setLastModificationTime(new PwDate());
|
||||||
newEntry.setLastModificationTime(now);
|
|
||||||
|
|
||||||
PwDatabase db = App.getDB().pm;
|
PwDatabase db = App.getDB().pm;
|
||||||
newEntry.setTitle(entryTitleView.getText().toString(), db);
|
|
||||||
|
newEntry.startToDecodeReference(db);
|
||||||
|
|
||||||
|
newEntry.setTitle(entryTitleView.getText().toString());
|
||||||
if(mSelectedIconID != -1)
|
if(mSelectedIconID != -1)
|
||||||
// or TODO icon factory newEntry.setIcon(App.getDB().pm.iconFactory.getIcon(mSelectedIconID));
|
// or TODO icon factory newEntry.setIcon(App.getDB().pm.iconFactory.getIcon(mSelectedIconID));
|
||||||
newEntry.setIcon(new PwIconStandard(mSelectedIconID));
|
newEntry.setIcon(new PwIconStandard(mSelectedIconID));
|
||||||
@@ -272,10 +275,10 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
newEntry.setIcon(mEntry.icon);
|
newEntry.setIcon(mEntry.icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newEntry.setUrl(entryUrlView.getText().toString(), db);
|
newEntry.setUrl(entryUrlView.getText().toString());
|
||||||
newEntry.setUsername(entryUserNameView.getText().toString(), db);
|
newEntry.setUsername(entryUserNameView.getText().toString());
|
||||||
newEntry.setNotes(entryCommentView.getText().toString(), db);
|
newEntry.setNotes(entryCommentView.getText().toString());
|
||||||
newEntry.setPassword(entryPasswordView.getText().toString(), db);
|
newEntry.setPassword(entryPasswordView.getText().toString());
|
||||||
|
|
||||||
if (newEntry.allowExtraFields()) {
|
if (newEntry.allowExtraFields()) {
|
||||||
// Delete all new standard strings
|
// Delete all new standard strings
|
||||||
@@ -290,6 +293,8 @@ public class EntryEditActivity extends LockingHideActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newEntry.endToDecodeReference(db);
|
||||||
|
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public abstract class EntrySearchHandler extends EntryHandler<PwEntry> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sp.excludeExpired && entry.expires() && now.after(entry.getExpiryTime())) {
|
if (sp.excludeExpired && entry.expires() && now.after(entry.getExpiryTime().getDate())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class EntrySearchHandlerAll extends EntryHandler<PwEntry> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sp.excludeExpired && entry.expires() && now.after(entry.getExpiryTime())) {
|
if (sp.excludeExpired && entry.expires() && now.after(entry.getExpiryTime().getDate())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class EntrySearchHandlerV4 extends EntrySearchHandler {
|
|||||||
protected boolean searchID(PwEntry e) {
|
protected boolean searchID(PwEntry e) {
|
||||||
PwEntryV4 entry = (PwEntryV4) e;
|
PwEntryV4 entry = (PwEntryV4) e;
|
||||||
if (sp.searchInUUIDs) {
|
if (sp.searchInUUIDs) {
|
||||||
String hex = UuidUtil.toHexString(entry.uuid);
|
String hex = UuidUtil.toHexString(entry.getUUID());
|
||||||
return StrUtil.indexOfIgnoreCase(hex, sp.searchString, Locale.ENGLISH) >= 0;
|
return StrUtil.indexOfIgnoreCase(hex, sp.searchString, Locale.ENGLISH) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,28 +19,26 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid.database;
|
package com.keepassdroid.database;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public interface ITimeLogger {
|
public interface ITimeLogger {
|
||||||
Date getLastModificationTime();
|
PwDate getLastModificationTime();
|
||||||
void setLastModificationTime(Date date);
|
void setLastModificationTime(PwDate date);
|
||||||
|
|
||||||
Date getCreationTime();
|
PwDate getCreationTime();
|
||||||
void setCreationTime(Date date);
|
void setCreationTime(PwDate date);
|
||||||
|
|
||||||
Date getLastAccessTime();
|
PwDate getLastAccessTime();
|
||||||
void setLastAccessTime(Date date);
|
void setLastAccessTime(PwDate date);
|
||||||
|
|
||||||
Date getExpiryTime();
|
PwDate getExpiryTime();
|
||||||
void setExpiryTime(Date date);
|
void setExpiryTime(PwDate date);
|
||||||
|
|
||||||
boolean expires();
|
boolean expires();
|
||||||
void setExpires(boolean exp);
|
void setExpires(boolean exp);
|
||||||
|
|
||||||
long getUsageCount();
|
long getUsageCount();
|
||||||
void setUsageCount(long count);
|
void setUsageCount(long count);
|
||||||
|
|
||||||
Date getLocationChanged();
|
PwDate getLocationChanged();
|
||||||
void setLocationChanged(Date date);
|
void setLocationChanged(PwDate date);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,8 +317,8 @@ public abstract class PwDatabase {
|
|||||||
|
|
||||||
public void populateGlobals(PwGroup currentGroup) {
|
public void populateGlobals(PwGroup currentGroup) {
|
||||||
|
|
||||||
List<PwGroup> childGroups = currentGroup.childGroups;
|
List<PwGroup> childGroups = currentGroup.getChildGroups();
|
||||||
List<PwEntry> childEntries = currentGroup.childEntries;
|
List<PwEntry> childEntries = currentGroup.getChildEntries();
|
||||||
|
|
||||||
for (int i = 0; i < childEntries.size(); i++ ) {
|
for (int i = 0; i < childEntries.size(); i++ ) {
|
||||||
PwEntry cur = childEntries.get(i);
|
PwEntry cur = childEntries.get(i);
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class PwDatabaseV3 extends PwDatabase {
|
|||||||
List<PwGroup> kids = new ArrayList<PwGroup>();
|
List<PwGroup> kids = new ArrayList<PwGroup>();
|
||||||
for (int i = 0; i < groups.size(); i++) {
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
PwGroupV3 grp = (PwGroupV3) groups.get(i);
|
PwGroupV3 grp = (PwGroupV3) groups.get(i);
|
||||||
if (grp.level == target)
|
if (grp.getLevel() == target)
|
||||||
kids.add(grp);
|
kids.add(grp);
|
||||||
}
|
}
|
||||||
return kids;
|
return kids;
|
||||||
@@ -114,8 +114,8 @@ public class PwDatabaseV3 extends PwDatabase {
|
|||||||
public int getRootGroupId() {
|
public int getRootGroupId() {
|
||||||
for (int i = 0; i < groups.size(); i++) {
|
for (int i = 0; i < groups.size(); i++) {
|
||||||
PwGroupV3 grp = (PwGroupV3) groups.get(i);
|
PwGroupV3 grp = (PwGroupV3) groups.get(i);
|
||||||
if (grp.level == 0) {
|
if (grp.getLevel() == 0) {
|
||||||
return grp.groupId;
|
return grp.getGroupId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,13 +124,13 @@ public class PwDatabaseV3 extends PwDatabase {
|
|||||||
|
|
||||||
public List<PwGroup> getGrpChildren(PwGroupV3 parent) {
|
public List<PwGroup> getGrpChildren(PwGroupV3 parent) {
|
||||||
int idx = groups.indexOf(parent);
|
int idx = groups.indexOf(parent);
|
||||||
int target = parent.level + 1;
|
int target = parent.getLevel() + 1;
|
||||||
List<PwGroup> kids = new ArrayList<PwGroup>();
|
List<PwGroup> kids = new ArrayList<PwGroup>();
|
||||||
while (++idx < groups.size()) {
|
while (++idx < groups.size()) {
|
||||||
PwGroupV3 grp = (PwGroupV3) groups.get(idx);
|
PwGroupV3 grp = (PwGroupV3) groups.get(idx);
|
||||||
if (grp.level < target)
|
if (grp.getLevel() < target)
|
||||||
break;
|
break;
|
||||||
else if (grp.level == target)
|
else if (grp.getLevel() == target)
|
||||||
kids.add(grp);
|
kids.add(grp);
|
||||||
}
|
}
|
||||||
return kids;
|
return kids;
|
||||||
@@ -145,7 +145,7 @@ public class PwDatabaseV3 extends PwDatabase {
|
|||||||
*/
|
*/
|
||||||
for (int i = 0; i < entries.size(); i++) {
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
PwEntryV3 ent = (PwEntryV3) entries.get(i);
|
PwEntryV3 ent = (PwEntryV3) entries.get(i);
|
||||||
if (ent.groupId == parent.groupId)
|
if (ent.getGroupId() == parent.getGroupId())
|
||||||
kids.add(ent);
|
kids.add(ent);
|
||||||
}
|
}
|
||||||
return kids;
|
return kids;
|
||||||
@@ -163,11 +163,11 @@ public class PwDatabaseV3 extends PwDatabase {
|
|||||||
|
|
||||||
List<PwGroup> rootChildGroups = getGrpRoots();
|
List<PwGroup> rootChildGroups = getGrpRoots();
|
||||||
root.setGroups(rootChildGroups);
|
root.setGroups(rootChildGroups);
|
||||||
root.childEntries = new ArrayList<>();
|
root.setEntries(new ArrayList<>());
|
||||||
root.level = -1;
|
root.setLevel(-1);
|
||||||
for (int i = 0; i < rootChildGroups.size(); i++) {
|
for (int i = 0; i < rootChildGroups.size(); i++) {
|
||||||
PwGroupV3 grp = (PwGroupV3) rootChildGroups.get(i);
|
PwGroupV3 grp = (PwGroupV3) rootChildGroups.get(i);
|
||||||
grp.parent = root;
|
grp.setParent(root);
|
||||||
constructTree(grp);
|
constructTree(grp);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -176,18 +176,18 @@ public class PwDatabaseV3 extends PwDatabase {
|
|||||||
// I'm in non-root
|
// I'm in non-root
|
||||||
// get child groups
|
// get child groups
|
||||||
currentGroup.setGroups(getGrpChildren(currentGroup));
|
currentGroup.setGroups(getGrpChildren(currentGroup));
|
||||||
currentGroup.childEntries = getEntries(currentGroup);
|
currentGroup.setEntries(getEntries(currentGroup));
|
||||||
|
|
||||||
// set parent in child entries
|
// set parent in child entries
|
||||||
for (int i = 0; i < currentGroup.numbersOfChildEntries(); i++) {
|
for (int i = 0; i < currentGroup.numbersOfChildEntries(); i++) {
|
||||||
PwEntryV3 entry = (PwEntryV3) currentGroup.childEntries.get(i);
|
PwEntryV3 entry = (PwEntryV3) currentGroup.getChildEntryAt(i);
|
||||||
entry.parent = currentGroup;
|
entry.setParent(currentGroup);
|
||||||
}
|
}
|
||||||
// recursively construct child groups
|
// recursively construct child groups
|
||||||
for (int i = 0; i < currentGroup.numbersOfChildGroups(); i++) {
|
for (int i = 0; i < currentGroup.numbersOfChildGroups(); i++) {
|
||||||
PwGroupV3 grp = (PwGroupV3) currentGroup.childGroups.get(i);
|
PwGroupV3 grp = (PwGroupV3) currentGroup.getChildGroupAt(i);
|
||||||
grp.parent = currentGroup;
|
grp.setParent(currentGroup);
|
||||||
constructTree((PwGroupV3) currentGroup.childGroups.get(i));
|
constructTree((PwGroupV3) currentGroup.getChildGroupAt(i));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -316,11 +316,11 @@ public class PwDatabaseV3 extends PwDatabase {
|
|||||||
public boolean isBackup(PwGroup group) {
|
public boolean isBackup(PwGroup group) {
|
||||||
PwGroupV3 g = (PwGroupV3) group;
|
PwGroupV3 g = (PwGroupV3) group;
|
||||||
while (g != null) {
|
while (g != null) {
|
||||||
if (g.level == 0 && g.name.equalsIgnoreCase("Backup")) {
|
if (g.getLevel() == 0 && g.getName().equalsIgnoreCase("Backup")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
g = g.parent;
|
g = (PwGroupV3) g.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -338,7 +338,7 @@ public class PwDatabaseV3 extends PwDatabase {
|
|||||||
private void initAndAddGroup(String name, int iconId, PwGroup parent) {
|
private void initAndAddGroup(String name, int iconId, PwGroup parent) {
|
||||||
PwGroup group = createGroup();
|
PwGroup group = createGroup();
|
||||||
group.initNewGroup(name, newGroupId());
|
group.initNewGroup(name, newGroupId());
|
||||||
group.icon = iconFactory.getIcon(iconId);
|
group.setIcon(iconFactory.getIcon(iconId));
|
||||||
addGroupTo(group, parent);
|
addGroupTo(group, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ import biz.source_code.base64Coder.Base64Coder;
|
|||||||
|
|
||||||
public class PwDatabaseV4 extends PwDatabase {
|
public class PwDatabaseV4 extends PwDatabase {
|
||||||
|
|
||||||
public static final Date DEFAULT_NOW = new Date();
|
|
||||||
public static final UUID UUID_ZERO = new UUID(0,0);
|
public static final UUID UUID_ZERO = new UUID(0,0);
|
||||||
public static final int DEFAULT_ROUNDS = 6000;
|
public static final int DEFAULT_ROUNDS = 6000;
|
||||||
private static final int DEFAULT_HISTORY_MAX_ITEMS = 10; // -1 unlimited
|
private static final int DEFAULT_HISTORY_MAX_ITEMS = 10; // -1 unlimited
|
||||||
@@ -71,14 +70,14 @@ public class PwDatabaseV4 extends PwDatabase {
|
|||||||
public PwCompressionAlgorithm compressionAlgorithm = PwCompressionAlgorithm.Gzip;
|
public PwCompressionAlgorithm compressionAlgorithm = PwCompressionAlgorithm.Gzip;
|
||||||
// TODO: Refactor me away to get directly from kdfParameters
|
// TODO: Refactor me away to get directly from kdfParameters
|
||||||
public long numKeyEncRounds = 6000;
|
public long numKeyEncRounds = 6000;
|
||||||
public Date nameChanged = DEFAULT_NOW;
|
public Date nameChanged = new Date();
|
||||||
public Date settingsChanged = DEFAULT_NOW;
|
public Date settingsChanged = new Date();
|
||||||
public String description = "";
|
public String description = "";
|
||||||
public Date descriptionChanged = DEFAULT_NOW;
|
public Date descriptionChanged = new Date();
|
||||||
public String defaultUserName = "";
|
public String defaultUserName = "";
|
||||||
public Date defaultUserNameChanged = DEFAULT_NOW;
|
public Date defaultUserNameChanged = new Date();
|
||||||
|
|
||||||
public Date keyLastChanged = DEFAULT_NOW;
|
public Date keyLastChanged = new Date();
|
||||||
public long keyChangeRecDays = -1;
|
public long keyChangeRecDays = -1;
|
||||||
public long keyChangeForceDays = 1;
|
public long keyChangeForceDays = 1;
|
||||||
public boolean keyChangeForceOnce = false;
|
public boolean keyChangeForceOnce = false;
|
||||||
@@ -87,17 +86,17 @@ public class PwDatabaseV4 extends PwDatabase {
|
|||||||
public String color = "";
|
public String color = "";
|
||||||
public boolean recycleBinEnabled = true;
|
public boolean recycleBinEnabled = true;
|
||||||
public UUID recycleBinUUID = UUID_ZERO;
|
public UUID recycleBinUUID = UUID_ZERO;
|
||||||
public Date recycleBinChanged = DEFAULT_NOW;
|
public Date recycleBinChanged = new Date();
|
||||||
public UUID entryTemplatesGroup = UUID_ZERO;
|
public UUID entryTemplatesGroup = UUID_ZERO;
|
||||||
public Date entryTemplatesGroupChanged = DEFAULT_NOW;
|
public Date entryTemplatesGroupChanged = new Date();
|
||||||
public int historyMaxItems = DEFAULT_HISTORY_MAX_ITEMS;
|
public int historyMaxItems = DEFAULT_HISTORY_MAX_ITEMS;
|
||||||
public long historyMaxSize = DEFAULT_HISTORY_MAX_SIZE;
|
public long historyMaxSize = DEFAULT_HISTORY_MAX_SIZE;
|
||||||
public UUID lastSelectedGroup = UUID_ZERO;
|
public UUID lastSelectedGroup = UUID_ZERO;
|
||||||
public UUID lastTopVisibleGroup = UUID_ZERO;
|
public UUID lastTopVisibleGroup = UUID_ZERO;
|
||||||
public MemoryProtectionConfig memoryProtection = new MemoryProtectionConfig();
|
public MemoryProtectionConfig memoryProtection = new MemoryProtectionConfig();
|
||||||
public List<PwDeletedObject> deletedObjects = new ArrayList<PwDeletedObject>();
|
public List<PwDeletedObject> deletedObjects = new ArrayList<>();
|
||||||
public List<PwIconCustom> customIcons = new ArrayList<PwIconCustom>();
|
public List<PwIconCustom> customIcons = new ArrayList<>();
|
||||||
public Map<String, String> customData = new HashMap<String, String>();
|
public Map<String, String> customData = new HashMap<>();
|
||||||
public KdfParameters kdfParameters = KdfFactory.getDefaultParameters();
|
public KdfParameters kdfParameters = KdfFactory.getDefaultParameters();
|
||||||
public VariantDictionary publicCustomData = new VariantDictionary();
|
public VariantDictionary publicCustomData = new VariantDictionary();
|
||||||
public BinaryPool binPool = new BinaryPool();
|
public BinaryPool binPool = new BinaryPool();
|
||||||
@@ -276,7 +275,7 @@ public class PwDatabaseV4 extends PwDatabase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PwGroup> getGrpRoots() {
|
public List<PwGroup> getGrpRoots() {
|
||||||
return rootGroup.childGroups;
|
return rootGroup.getChildGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -351,7 +350,7 @@ public class PwDatabaseV4 extends PwDatabase {
|
|||||||
if (getRecycleBin() == null) {
|
if (getRecycleBin() == null) {
|
||||||
// Create recycle bin
|
// Create recycle bin
|
||||||
|
|
||||||
PwGroupV4 recycleBin = new PwGroupV4(true, true, RECYCLEBIN_NAME, iconFactory.getIcon(PwIconStandard.TRASH_BIN));
|
PwGroupV4 recycleBin = new PwGroupV4(true, RECYCLEBIN_NAME, iconFactory.getIcon(PwIconStandard.TRASH_BIN));
|
||||||
recycleBin.enableAutoType = false;
|
recycleBin.enableAutoType = false;
|
||||||
recycleBin.enableSearching = false;
|
recycleBin.enableSearching = false;
|
||||||
recycleBin.isExpanded = false;
|
recycleBin.isExpanded = false;
|
||||||
@@ -480,7 +479,7 @@ public class PwDatabaseV4 extends PwDatabase {
|
|||||||
public void initNew(String dbPath) {
|
public void initNew(String dbPath) {
|
||||||
String filename = URLUtil.guessFileName(dbPath, null, null);
|
String filename = URLUtil.guessFileName(dbPath, null, null);
|
||||||
|
|
||||||
rootGroup = new PwGroupV4(true, true, dbNameFromPath(dbPath), iconFactory.getIcon(PwIconStandard.FOLDER));
|
rootGroup = new PwGroupV4(true, dbNameFromPath(dbPath), iconFactory.getIcon(PwIconStandard.FOLDER));
|
||||||
groups.put(rootGroup.getId(), rootGroup);
|
groups.put(rootGroup.getId(), rootGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import com.keepassdroid.utils.Types;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PwDate implements Cloneable, Serializable {
|
public class PwDate implements Cloneable, Serializable {
|
||||||
|
|
||||||
private static final int DATE_SIZE = 5;
|
private static final int DATE_SIZE = 5;
|
||||||
|
|
||||||
private boolean cDateBuilt = false;
|
private boolean cDateBuilt = false;
|
||||||
@@ -42,6 +42,56 @@ public class PwDate implements Cloneable, Serializable {
|
|||||||
|
|
||||||
private Date jDate;
|
private Date jDate;
|
||||||
private byte[] cDate;
|
private byte[] cDate;
|
||||||
|
|
||||||
|
public static final Date NEVER_EXPIRE = getNeverExpire();
|
||||||
|
public static final Date NEVER_EXPIRE_BUG = getNeverExpireBug();
|
||||||
|
|
||||||
|
public static final Date DEFAULT_DATE = getDefaultDate();
|
||||||
|
public static final PwDate PW_NEVER_EXPIRE = new PwDate(NEVER_EXPIRE);
|
||||||
|
public static final PwDate PW_NEVER_EXPIRE_BUG = new PwDate(NEVER_EXPIRE_BUG);
|
||||||
|
public static final PwDate DEFAULT_PWDATE = new PwDate(DEFAULT_DATE);
|
||||||
|
|
||||||
|
private static Date getDefaultDate() {
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.set(Calendar.YEAR, 2004);
|
||||||
|
cal.set(Calendar.MONTH, Calendar.JANUARY);
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
cal.set(Calendar.HOUR, 0);
|
||||||
|
cal.set(Calendar.MINUTE, 0);
|
||||||
|
cal.set(Calendar.SECOND, 0);
|
||||||
|
|
||||||
|
return cal.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Date getNeverExpire() {
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.set(Calendar.YEAR, 2999);
|
||||||
|
cal.set(Calendar.MONTH, 11);
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, 28);
|
||||||
|
cal.set(Calendar.HOUR, 23);
|
||||||
|
cal.set(Calendar.MINUTE, 59);
|
||||||
|
cal.set(Calendar.SECOND, 59);
|
||||||
|
|
||||||
|
return cal.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This date was was accidentally being written
|
||||||
|
* out when an entry was supposed to be marked as
|
||||||
|
* expired. We'll use this to silently correct those
|
||||||
|
* entries.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static Date getNeverExpireBug() {
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.set(Calendar.YEAR, 2999);
|
||||||
|
cal.set(Calendar.MONTH, 11);
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, 30);
|
||||||
|
cal.set(Calendar.HOUR, 23);
|
||||||
|
cal.set(Calendar.MINUTE, 59);
|
||||||
|
cal.set(Calendar.SECOND, 59);
|
||||||
|
|
||||||
|
return cal.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
public PwDate(byte[] buf, int offset) {
|
public PwDate(byte[] buf, int offset) {
|
||||||
cDate = new byte[DATE_SIZE];
|
cDate = new byte[DATE_SIZE];
|
||||||
@@ -59,8 +109,9 @@ public class PwDate implements Cloneable, Serializable {
|
|||||||
jDateBuilt = true;
|
jDateBuilt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PwDate() {
|
public PwDate() {
|
||||||
|
jDate = new Date();
|
||||||
|
jDateBuilt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,9 +133,7 @@ public class PwDate implements Cloneable, Serializable {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
|
||||||
public Date getJDate() {
|
|
||||||
if ( ! jDateBuilt ) {
|
if ( ! jDateBuilt ) {
|
||||||
jDate = readTime(cDate, 0, App.getCalendar());
|
jDate = readTime(cDate, 0, App.getCalendar());
|
||||||
jDateBuilt = true;
|
jDateBuilt = true;
|
||||||
@@ -102,7 +151,6 @@ public class PwDate implements Cloneable, Serializable {
|
|||||||
return cDate;
|
return cDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpack date from 5 byte format. The five bytes at 'offset' are unpacked
|
* Unpack date from 5 byte format. The five bytes at 'offset' are unpacked
|
||||||
* to a java.util.Date instance.
|
* to a java.util.Date instance.
|
||||||
@@ -189,7 +237,7 @@ public class PwDate implements Cloneable, Serializable {
|
|||||||
} else if ( cDateBuilt && date.jDateBuilt ) {
|
} else if ( cDateBuilt && date.jDateBuilt ) {
|
||||||
return Arrays.equals(date.getCDate(), cDate);
|
return Arrays.equals(date.getCDate(), cDate);
|
||||||
} else {
|
} else {
|
||||||
return IsSameDate(date.getJDate(), jDate);
|
return IsSameDate(date.getDate(), jDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,52 +69,30 @@ public abstract class PwEntry extends PwNode implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void assign(PwEntry source) {
|
public void assign(PwEntry source) {
|
||||||
|
super.assign(source);
|
||||||
icon = source.icon;
|
icon = source.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract UUID getUUID();
|
public abstract UUID getUUID();
|
||||||
public abstract void setUUID(UUID u);
|
public abstract void setUUID(UUID u);
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return getTitle(false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return getUsername(false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
public void startToDecodeReference(PwDatabase db) {}
|
||||||
return getPassword(false, null);
|
public void endToDecodeReference(PwDatabase db) {}
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return getUrl(false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNotes() {
|
public abstract String getTitle();
|
||||||
return getNotes(false, null);
|
public abstract void setTitle(String title);
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getTitle(boolean decodeRef, PwDatabase db);
|
public abstract String getUsername();
|
||||||
public abstract String getUsername(boolean decodeRef, PwDatabase db);
|
public abstract void setUsername(String user);
|
||||||
public abstract String getPassword(boolean decodeRef, PwDatabase db);
|
|
||||||
public abstract String getUrl(boolean decodeRef, PwDatabase db);
|
public abstract String getPassword();
|
||||||
public abstract String getNotes(boolean decodeRef, PwDatabase db);
|
public abstract void setPassword(String pass);
|
||||||
public abstract Date getLastModificationTime();
|
|
||||||
public abstract Date getLastAccessTime();
|
public abstract String getUrl();
|
||||||
public abstract Date getExpiryTime();
|
public abstract void setUrl(String url);
|
||||||
public abstract boolean expires();
|
|
||||||
|
public abstract String getNotes();
|
||||||
public abstract void setTitle(String title, PwDatabase db);
|
public abstract void setNotes(String notes);
|
||||||
public abstract void setUsername(String user, PwDatabase db);
|
|
||||||
public abstract void setPassword(String pass, PwDatabase db);
|
|
||||||
public abstract void setUrl(String url, PwDatabase db);
|
|
||||||
public abstract void setNotes(String notes, PwDatabase db);
|
|
||||||
public abstract void setCreationTime(Date create);
|
|
||||||
public abstract void setLastModificationTime(Date mod);
|
|
||||||
public abstract void setLastAccessTime(Date access);
|
|
||||||
public abstract void setExpires(boolean exp);
|
|
||||||
public abstract void setExpiryTime(Date expires);
|
|
||||||
|
|
||||||
public PwIcon getIcon() {
|
public PwIcon getIcon() {
|
||||||
return icon;
|
return icon;
|
||||||
@@ -148,10 +126,9 @@ public abstract class PwEntry extends PwNode implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve extra fields to show, key is the label, value is the value of field
|
* Retrieve extra fields to show, key is the label, value is the value of field
|
||||||
* @param pm Database
|
|
||||||
* @return Map of label/value
|
* @return Map of label/value
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getExtraFields(PwDatabase pm) {
|
public Map<String, String> getExtraFields() {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,8 +173,8 @@ public abstract class PwEntry extends PwNode implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void touch(boolean modified, boolean touchParents) {
|
public void touch(boolean modified, boolean touchParents) {
|
||||||
Date now = new Date();
|
PwDate now = new PwDate();
|
||||||
|
|
||||||
setLastAccessTime(now);
|
setLastAccessTime(now);
|
||||||
|
|
||||||
if (modified) {
|
if (modified) {
|
||||||
@@ -282,7 +259,8 @@ public abstract class PwEntry extends PwNode implements Cloneable {
|
|||||||
if (object1.equals(object2))
|
if (object1.equals(object2))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int entryCreationComp = object1.getCreationTime().compareTo(object2.getCreationTime());
|
int entryCreationComp = object1.getCreationTime().getDate()
|
||||||
|
.compareTo(object2.getCreationTime().getDate());
|
||||||
// If same creation, can be different
|
// If same creation, can be different
|
||||||
if (entryCreationComp == 0) {
|
if (entryCreationComp == 0) {
|
||||||
return object1.hashCode() - object2.hashCode();
|
return object1.hashCode() - object2.hashCode();
|
||||||
|
|||||||
@@ -42,12 +42,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||||||
|
|
||||||
package com.keepassdroid.database;
|
package com.keepassdroid.database;
|
||||||
|
|
||||||
// PhoneID
|
|
||||||
import com.keepassdroid.utils.Types;
|
import com.keepassdroid.utils.Types;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -74,134 +71,159 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class PwEntryV3 extends PwEntry {
|
public class PwEntryV3 extends PwEntry {
|
||||||
|
|
||||||
public static final Date NEVER_EXPIRE = getNeverExpire();
|
|
||||||
public static final Date NEVER_EXPIRE_BUG = getNeverExpireBug();
|
|
||||||
public static final Date DEFAULT_DATE = getDefaultDate();
|
|
||||||
public static final PwDate PW_NEVER_EXPIRE = new PwDate(NEVER_EXPIRE);
|
|
||||||
public static final PwDate PW_NEVER_EXPIRE_BUG = new PwDate(NEVER_EXPIRE_BUG);
|
|
||||||
public static final PwDate DEFAULT_PWDATE = new PwDate(DEFAULT_DATE);
|
|
||||||
|
|
||||||
|
|
||||||
/** Size of byte buffer needed to hold this struct. */
|
/** Size of byte buffer needed to hold this struct. */
|
||||||
public static final String PMS_ID_BINDESC = "bin-stream";
|
private static final String PMS_ID_BINDESC = "bin-stream";
|
||||||
public static final String PMS_ID_TITLE = "Meta-Info";
|
private static final String PMS_ID_TITLE = "Meta-Info";
|
||||||
public static final String PMS_ID_USER = "SYSTEM";
|
private static final String PMS_ID_USER = "SYSTEM";
|
||||||
public static final String PMS_ID_URL = "$";
|
private static final String PMS_ID_URL = "$";
|
||||||
|
|
||||||
|
// for tree traversing
|
||||||
|
private PwGroupV3 parent = null;
|
||||||
|
private int groupId;
|
||||||
|
|
||||||
|
private byte[] uuid;
|
||||||
public int groupId;
|
private String username;
|
||||||
public String username;
|
private byte[] password;
|
||||||
private byte[] password;
|
private String title;
|
||||||
private byte[] uuid;
|
private String url;
|
||||||
public String title;
|
private String additional;
|
||||||
public String url;
|
|
||||||
public String additional;
|
|
||||||
|
|
||||||
|
|
||||||
public PwDate tCreation;
|
|
||||||
public PwDate tLastMod;
|
|
||||||
public PwDate tLastAccess;
|
|
||||||
public PwDate tExpire;
|
|
||||||
|
|
||||||
/** A string describing what is in pBinaryData */
|
/** A string describing what is in pBinaryData */
|
||||||
public String binaryDesc;
|
private String binaryDesc;
|
||||||
private byte[] binaryData;
|
private byte[] binaryData;
|
||||||
|
|
||||||
private static Date getDefaultDate() {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.set(Calendar.YEAR, 2004);
|
|
||||||
cal.set(Calendar.MONTH, Calendar.JANUARY);
|
|
||||||
cal.set(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
cal.set(Calendar.HOUR, 0);
|
|
||||||
cal.set(Calendar.MINUTE, 0);
|
|
||||||
cal.set(Calendar.SECOND, 0);
|
|
||||||
|
|
||||||
return cal.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Date getNeverExpire() {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.set(Calendar.YEAR, 2999);
|
|
||||||
cal.set(Calendar.MONTH, 11);
|
|
||||||
cal.set(Calendar.DAY_OF_MONTH, 28);
|
|
||||||
cal.set(Calendar.HOUR, 23);
|
|
||||||
cal.set(Calendar.MINUTE, 59);
|
|
||||||
cal.set(Calendar.SECOND, 59);
|
|
||||||
|
|
||||||
return cal.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This date was was accidentally being written
|
|
||||||
* out when an entry was supposed to be marked as
|
|
||||||
* expired. We'll use this to silently correct those
|
|
||||||
* entries.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static Date getNeverExpireBug() {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.set(Calendar.YEAR, 2999);
|
|
||||||
cal.set(Calendar.MONTH, 11);
|
|
||||||
cal.set(Calendar.DAY_OF_MONTH, 30);
|
|
||||||
cal.set(Calendar.HOUR, 23);
|
|
||||||
cal.set(Calendar.MINUTE, 59);
|
|
||||||
cal.set(Calendar.SECOND, 59);
|
|
||||||
|
|
||||||
return cal.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean IsNever(Date date) {
|
|
||||||
return PwDate.IsSameDate(NEVER_EXPIRE, date);
|
|
||||||
}
|
|
||||||
|
|
||||||
// for tree traversing
|
|
||||||
public PwGroupV3 parent = null;
|
|
||||||
|
|
||||||
|
|
||||||
public PwEntryV3() {
|
public PwEntryV3() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public PwEntryV3(PwEntryV3 source) {
|
|
||||||
assign(source);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public PwEntryV3(PwGroupV3 p) {
|
public PwEntryV3(PwGroupV3 p) {
|
||||||
this(p, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PwEntryV3(PwGroupV3 p, boolean initId, boolean initDates) {
|
|
||||||
|
|
||||||
parent = p;
|
parent = p;
|
||||||
groupId = ((PwGroupIdV3)parent.getId()).getId();
|
groupId = ((PwGroupIdV3)parent.getId()).getId();
|
||||||
|
|
||||||
if (initId) {
|
Random random = new Random();
|
||||||
Random random = new Random();
|
uuid = new byte[16];
|
||||||
uuid = new byte[16];
|
random.nextBytes(uuid);
|
||||||
random.nextBytes(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initDates) {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
Date now = cal.getTime();
|
|
||||||
tCreation = new PwDate(now);
|
|
||||||
tLastAccess = new PwDate(now);
|
|
||||||
tLastMod = new PwDate(now);
|
|
||||||
tExpire = new PwDate(NEVER_EXPIRE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PwGroupV3 getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParent(PwGroup parent) {
|
||||||
|
this.parent = (PwGroupV3) parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(int groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID() {
|
||||||
|
return Types.bytestoUUID(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUUID(UUID u) {
|
||||||
|
uuid = Types.UUIDtoBytes(u);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsername() {
|
||||||
|
if (username == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUsername(String user) {
|
||||||
|
username = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNotes() {
|
||||||
|
return additional;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNotes(String notes) {
|
||||||
|
additional = notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void populateBlankFields(PwDatabaseV3 db) {
|
||||||
|
if (icon == null) {
|
||||||
|
icon = db.iconFactory.getIcon(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (username == null) {
|
||||||
|
username = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password == null) {
|
||||||
|
password = new byte[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uuid == null) {
|
||||||
|
uuid = Types.UUIDtoBytes(UUID.randomUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title == null) {
|
||||||
|
title = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url == null) {
|
||||||
|
url = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additional == null) {
|
||||||
|
additional = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binaryDesc == null) {
|
||||||
|
binaryDesc = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binaryData == null) {
|
||||||
|
binaryData = new byte[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the actual password byte array.
|
* @return the actual password byte array.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getPassword(boolean decodeRef, PwDatabase db) {
|
public String getPassword() {
|
||||||
if (password == null) {
|
if (password == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return new String(password);
|
return new String(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +231,6 @@ public class PwEntryV3 extends PwEntry {
|
|||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill byte array
|
* fill byte array
|
||||||
*/
|
*/
|
||||||
@@ -230,10 +251,8 @@ public class PwEntryV3 extends PwEntry {
|
|||||||
System.arraycopy( buf, offset, password, 0, len );
|
System.arraycopy( buf, offset, password, 0, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassword(String pass, PwDatabase db) {
|
public void setPassword(String pass) {
|
||||||
byte[] password;
|
byte[] password;
|
||||||
try {
|
try {
|
||||||
password = pass.getBytes("UTF-8");
|
password = pass.getBytes("UTF-8");
|
||||||
@@ -252,8 +271,6 @@ public class PwEntryV3 extends PwEntry {
|
|||||||
return binaryData;
|
return binaryData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Securely erase old data before copying new. */
|
/** Securely erase old data before copying new. */
|
||||||
public void setBinaryData( byte[] buf, int offset, int len ) {
|
public void setBinaryData( byte[] buf, int offset, int len ) {
|
||||||
if( binaryData != null ) {
|
if( binaryData != null ) {
|
||||||
@@ -264,6 +281,14 @@ public class PwEntryV3 extends PwEntry {
|
|||||||
System.arraycopy( buf, offset, binaryData, 0, len );
|
System.arraycopy( buf, offset, binaryData, 0, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBinaryDesc() {
|
||||||
|
return binaryDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBinaryDesc(String binaryDesc) {
|
||||||
|
this.binaryDesc = binaryDesc;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine if this is a MetaStream entry
|
// Determine if this is a MetaStream entry
|
||||||
@Override
|
@Override
|
||||||
public boolean isMetaStream() {
|
public boolean isMetaStream() {
|
||||||
@@ -292,7 +317,6 @@ public class PwEntryV3 extends PwEntry {
|
|||||||
|
|
||||||
PwEntryV3 src = (PwEntryV3) source;
|
PwEntryV3 src = (PwEntryV3) source;
|
||||||
assign(src);
|
assign(src);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assign(PwEntryV3 source) {
|
private void assign(PwEntryV3 source) {
|
||||||
@@ -307,10 +331,10 @@ public class PwEntryV3 extends PwEntry {
|
|||||||
password = new byte[passLen];
|
password = new byte[passLen];
|
||||||
System.arraycopy(source.password, 0, password, 0, passLen);
|
System.arraycopy(source.password, 0, password, 0, passLen);
|
||||||
|
|
||||||
tCreation = (PwDate) source.tCreation.clone();
|
setCreationTime( (PwDate) source.getCreationTime().clone() );
|
||||||
tLastMod = (PwDate) source.tLastMod.clone();
|
setLastModificationTime( (PwDate) source.getLastModificationTime().clone() );
|
||||||
tLastAccess = (PwDate) source.tLastAccess.clone();
|
setLastAccessTime( (PwDate) source.getLastAccessTime().clone() );
|
||||||
tExpire = (PwDate) source.tExpire.clone();
|
setExpiryTime( (PwDate) source.getExpiryTime().clone() );
|
||||||
|
|
||||||
binaryDesc = source.binaryDesc;
|
binaryDesc = source.binaryDesc;
|
||||||
|
|
||||||
@@ -334,10 +358,10 @@ public class PwEntryV3 extends PwEntry {
|
|||||||
System.arraycopy(password, 0, newEntry.password, 0, passLen);
|
System.arraycopy(password, 0, newEntry.password, 0, passLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
newEntry.tCreation = (PwDate) tCreation.clone();
|
newEntry.setCreationTime( (PwDate) getCreationTime().clone() );
|
||||||
newEntry.tLastMod = (PwDate) tLastMod.clone();
|
newEntry.setLastModificationTime( (PwDate) getLastModificationTime().clone() );
|
||||||
newEntry.tLastAccess = (PwDate) tLastAccess.clone();
|
newEntry.setLastAccessTime( (PwDate) getLastAccessTime().clone() );
|
||||||
newEntry.tExpire = (PwDate) tExpire.clone();
|
newEntry.setExpiryTime( (PwDate) getExpiryTime().clone() );
|
||||||
|
|
||||||
newEntry.binaryDesc = binaryDesc;
|
newEntry.binaryDesc = binaryDesc;
|
||||||
|
|
||||||
@@ -349,180 +373,6 @@ public class PwEntryV3 extends PwEntry {
|
|||||||
|
|
||||||
newEntry.parent = parent;
|
newEntry.parent = parent;
|
||||||
|
|
||||||
|
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getLastAccessTime() {
|
|
||||||
return tLastAccess.getJDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getCreationTime() {
|
|
||||||
return tCreation.getJDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getExpiryTime() {
|
|
||||||
return tExpire.getJDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getLastModificationTime() {
|
|
||||||
return tLastMod.getJDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCreationTime(Date create) {
|
|
||||||
tCreation = new PwDate(create);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastModificationTime(Date mod) {
|
|
||||||
tLastMod = new PwDate(mod);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastAccessTime(Date access) {
|
|
||||||
tLastAccess = new PwDate(access);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpires(boolean expires) {
|
|
||||||
if (!expires) {
|
|
||||||
tExpire = PW_NEVER_EXPIRE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setExpiryTime(Date expires) {
|
|
||||||
tExpire = new PwDate(expires);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwGroupV3 getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getUUID() {
|
|
||||||
return Types.bytestoUUID(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUUID(UUID u) {
|
|
||||||
uuid = Types.UUIDtoBytes(u);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsername(boolean decodeRef, PwDatabase db) {
|
|
||||||
if (username == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUsername(String user, PwDatabase db) {
|
|
||||||
username = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle(boolean decodeRef, PwDatabase db) {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTitle(String title, PwDatabase db) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNotes(boolean decodeRef, PwDatabase db) {
|
|
||||||
return additional;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNotes(String notes, PwDatabase db) {
|
|
||||||
additional = notes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUrl(boolean decodeRef, PwDatabase db) {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUrl(String url, PwDatabase db) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean expires() {
|
|
||||||
return ! IsNever(tExpire.getJDate());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void populateBlankFields(PwDatabaseV3 db) {
|
|
||||||
if (icon == null) {
|
|
||||||
icon = db.iconFactory.getIcon(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (username == null) {
|
|
||||||
username = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (password == null) {
|
|
||||||
password = new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uuid == null) {
|
|
||||||
uuid = Types.UUIDtoBytes(UUID.randomUUID());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (title == null) {
|
|
||||||
title = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url == null) {
|
|
||||||
url = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additional == null) {
|
|
||||||
additional = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tCreation == null) {
|
|
||||||
tCreation = DEFAULT_PWDATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tLastMod == null) {
|
|
||||||
tLastMod = DEFAULT_PWDATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tLastAccess == null) {
|
|
||||||
tLastAccess = DEFAULT_PWDATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tExpire == null) {
|
|
||||||
tExpire = PW_NEVER_EXPIRE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (binaryDesc == null) {
|
|
||||||
binaryDesc = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (binaryData == null) {
|
|
||||||
binaryData = new byte[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setParent(PwGroup parent) {
|
|
||||||
this.parent = (PwGroupV3) parent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,10 @@ package com.keepassdroid.database;
|
|||||||
|
|
||||||
import com.keepassdroid.database.security.ProtectedBinary;
|
import com.keepassdroid.database.security.ProtectedBinary;
|
||||||
import com.keepassdroid.database.security.ProtectedString;
|
import com.keepassdroid.database.security.ProtectedString;
|
||||||
import com.keepassdroid.utils.SprEngine;
|
import com.keepassdroid.utils.SprEngineV4;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -40,9 +39,13 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
public static final String STR_PASSWORD = "Password";
|
public static final String STR_PASSWORD = "Password";
|
||||||
public static final String STR_URL = "URL";
|
public static final String STR_URL = "URL";
|
||||||
public static final String STR_NOTES = "Notes";
|
public static final String STR_NOTES = "Notes";
|
||||||
|
|
||||||
|
// To decode each field not serializable
|
||||||
|
private transient PwDatabase mDatabase = null;
|
||||||
|
private transient boolean mDecodeRef = false;
|
||||||
|
|
||||||
public PwGroupV4 parent;
|
public PwGroupV4 parent;
|
||||||
public UUID uuid = PwDatabaseV4.UUID_ZERO;
|
private UUID uuid = PwDatabaseV4.UUID_ZERO;
|
||||||
private HashMap<String, ProtectedString> fields = new HashMap<>();
|
private HashMap<String, ProtectedString> fields = new HashMap<>();
|
||||||
public HashMap<String, ProtectedBinary> binaries = new HashMap<>();
|
public HashMap<String, ProtectedBinary> binaries = new HashMap<>();
|
||||||
public PwIconCustom customIcon = PwIconCustom.ZERO;
|
public PwIconCustom customIcon = PwIconCustom.ZERO;
|
||||||
@@ -52,17 +55,12 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
public AutoType autoType = new AutoType();
|
public AutoType autoType = new AutoType();
|
||||||
public ArrayList<PwEntryV4> history = new ArrayList<>();
|
public ArrayList<PwEntryV4> history = new ArrayList<>();
|
||||||
|
|
||||||
private Date parentGroupLastMod = PwDatabaseV4.DEFAULT_NOW;
|
private PwDate parentGroupLastMod = new PwDate();
|
||||||
private Date creation = PwDatabaseV4.DEFAULT_NOW;
|
|
||||||
private Date lastMod = PwDatabaseV4.DEFAULT_NOW;
|
|
||||||
private Date lastAccess = PwDatabaseV4.DEFAULT_NOW;
|
|
||||||
private Date expireDate = PwDatabaseV4.DEFAULT_NOW;
|
|
||||||
private boolean expires = false;
|
|
||||||
private long usageCount = 0;
|
private long usageCount = 0;
|
||||||
public String url = "";
|
public String url = "";
|
||||||
public String additional = "";
|
public String additional = "";
|
||||||
public String tags = "";
|
public String tags = "";
|
||||||
public Map<String, String> customData = new HashMap<String, String>();
|
public Map<String, String> customData = new HashMap<>();
|
||||||
|
|
||||||
public class AutoType implements Cloneable, Serializable {
|
public class AutoType implements Cloneable, Serializable {
|
||||||
private static final long OBF_OPT_NONE = 0;
|
private static final long OBF_OPT_NONE = 0;
|
||||||
@@ -71,7 +69,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
public long obfuscationOptions = OBF_OPT_NONE;
|
public long obfuscationOptions = OBF_OPT_NONE;
|
||||||
public String defaultSequence = "";
|
public String defaultSequence = "";
|
||||||
|
|
||||||
private HashMap<String, String> windowSeqPairs = new HashMap<String, String>();
|
private HashMap<String, String> windowSeqPairs = new HashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
@@ -80,7 +78,6 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
auto = (AutoType) super.clone();
|
auto = (AutoType) super.clone();
|
||||||
}
|
}
|
||||||
catch (CloneNotSupportedException e) {
|
catch (CloneNotSupportedException e) {
|
||||||
assert(false);
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,28 +98,11 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PwEntryV4() {
|
public PwEntryV4() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwEntryV4(PwGroupV4 p) {
|
public PwEntryV4(PwGroupV4 p) {
|
||||||
this(p, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PwEntryV4(PwGroupV4 p, boolean initId, boolean initDates) {
|
|
||||||
parent = p;
|
parent = p;
|
||||||
|
uuid = UUID.randomUUID();
|
||||||
if (initId) {
|
|
||||||
uuid = UUID.randomUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initDates) {
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
Date now = cal.getTime();
|
|
||||||
creation = now;
|
|
||||||
lastAccess = now;
|
|
||||||
lastMod = now;
|
|
||||||
expires = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -152,6 +132,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assign(PwEntryV4 source) {
|
private void assign(PwEntryV4 source) {
|
||||||
|
super.assign(source);
|
||||||
parent = source.parent;
|
parent = source.parent;
|
||||||
uuid = source.uuid;
|
uuid = source.uuid;
|
||||||
fields = source.fields;
|
fields = source.fields;
|
||||||
@@ -163,131 +144,98 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
autoType = source.autoType;
|
autoType = source.autoType;
|
||||||
history = source.history;
|
history = source.history;
|
||||||
parentGroupLastMod = source.parentGroupLastMod;
|
parentGroupLastMod = source.parentGroupLastMod;
|
||||||
creation = source.creation;
|
|
||||||
lastMod = source.lastMod;
|
|
||||||
lastAccess = source.lastAccess;
|
|
||||||
expireDate = source.expireDate;
|
|
||||||
expires = source.expires;
|
|
||||||
usageCount = source.usageCount;
|
usageCount = source.usageCount;
|
||||||
url = source.url;
|
url = source.url;
|
||||||
additional = source.additional;
|
additional = source.additional;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
PwEntryV4 newEntry = (PwEntryV4) super.clone();
|
PwEntryV4 newEntry = (PwEntryV4) super.clone();
|
||||||
|
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startToDecodeReference(PwDatabase db) {
|
||||||
|
this.mDatabase = db;
|
||||||
|
this.mDecodeRef = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endToDecodeReference(PwDatabase db) {
|
||||||
|
this.mDatabase = null;
|
||||||
|
this.mDecodeRef = false;
|
||||||
|
}
|
||||||
|
|
||||||
private String decodeRefKey(boolean decodeRef, String key, PwDatabase db) {
|
private String decodeRefKey(boolean decodeRef, String key) {
|
||||||
String text = getString(key);
|
String text = getString(key);
|
||||||
if (decodeRef) {
|
if (decodeRef) {
|
||||||
text = decodeRef(text, db);
|
text = decodeRef(text, mDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String decodeRef(String text, PwDatabase db) {
|
private String decodeRef(String text, PwDatabase db) {
|
||||||
if (db == null) { return text; }
|
if (db == null) { return text; }
|
||||||
|
SprEngineV4 spr = new SprEngineV4();
|
||||||
SprEngine spr = SprEngine.getInstance(db);
|
|
||||||
return spr.compile(text, this, db);
|
return spr.compile(text, this, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsername(boolean decodeRef, PwDatabase db) {
|
public String getUsername() {
|
||||||
return decodeRefKey(decodeRef, STR_USERNAME, db);
|
return decodeRefKey(mDecodeRef, STR_USERNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle(boolean decodeRef, PwDatabase db) {
|
public String getTitle() {
|
||||||
return decodeRefKey(decodeRef, STR_TITLE, db);
|
return decodeRefKey(mDecodeRef, STR_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPassword(boolean decodeRef, PwDatabase db) {
|
public String getPassword() {
|
||||||
return decodeRefKey(decodeRef, STR_PASSWORD, db);
|
return decodeRefKey(mDecodeRef, STR_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getLastAccessTime() {
|
public void setTitle(String title) {
|
||||||
return lastAccess;
|
PwDatabaseV4 db = (PwDatabaseV4) mDatabase;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getCreationTime() {
|
|
||||||
return creation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getExpiryTime() {
|
|
||||||
return expireDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getLastModificationTime() {
|
|
||||||
return lastMod;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTitle(String title, PwDatabase d) {
|
|
||||||
PwDatabaseV4 db = (PwDatabaseV4) d;
|
|
||||||
boolean protect = db.memoryProtection.protectTitle;
|
boolean protect = db.memoryProtection.protectTitle;
|
||||||
|
|
||||||
setString(STR_TITLE, title, protect);
|
setString(STR_TITLE, title, protect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUsername(String user, PwDatabase d) {
|
public void setUsername(String user) {
|
||||||
PwDatabaseV4 db = (PwDatabaseV4) d;
|
PwDatabaseV4 db = (PwDatabaseV4) mDatabase;
|
||||||
boolean protect = db.memoryProtection.protectUserName;
|
boolean protect = db.memoryProtection.protectUserName;
|
||||||
|
|
||||||
setString(STR_USERNAME, user, protect);
|
setString(STR_USERNAME, user, protect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassword(String pass, PwDatabase d) {
|
public void setPassword(String pass) {
|
||||||
PwDatabaseV4 db = (PwDatabaseV4) d;
|
PwDatabaseV4 db = (PwDatabaseV4) mDatabase;
|
||||||
boolean protect = db.memoryProtection.protectPassword;
|
boolean protect = db.memoryProtection.protectPassword;
|
||||||
|
|
||||||
setString(STR_PASSWORD, pass, protect);
|
setString(STR_PASSWORD, pass, protect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUrl(String url, PwDatabase d) {
|
public void setUrl(String url) {
|
||||||
PwDatabaseV4 db = (PwDatabaseV4) d;
|
PwDatabaseV4 db = (PwDatabaseV4) mDatabase;
|
||||||
boolean protect = db.memoryProtection.protectUrl;
|
boolean protect = db.memoryProtection.protectUrl;
|
||||||
|
|
||||||
setString(STR_URL, url, protect);
|
setString(STR_URL, url, protect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNotes(String notes, PwDatabase d) {
|
public void setNotes(String notes) {
|
||||||
PwDatabaseV4 db = (PwDatabaseV4) d;
|
PwDatabaseV4 db = (PwDatabaseV4) mDatabase;
|
||||||
boolean protect = db.memoryProtection.protectNotes;
|
boolean protect = db.memoryProtection.protectNotes;
|
||||||
|
|
||||||
setString(STR_NOTES, notes, protect);
|
setString(STR_NOTES, notes, protect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreationTime(Date date) {
|
|
||||||
creation = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpiryTime(Date date) {
|
|
||||||
expireDate = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastAccessTime(Date date) {
|
|
||||||
lastAccess = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastModificationTime(Date date) {
|
|
||||||
lastMod = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PwGroupV4 getParent() {
|
public PwGroupV4 getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
@@ -303,11 +251,11 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
public void setUUID(UUID u) {
|
public void setUUID(UUID u) {
|
||||||
uuid = u;
|
uuid = u;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(String key) {
|
public String getString(String key) {
|
||||||
ProtectedString value = fields.get(key);
|
ProtectedString value = fields.get(key);
|
||||||
|
|
||||||
if ( value == null ) return new String("");
|
if ( value == null ) return "";
|
||||||
|
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
@@ -317,7 +265,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
fields.put(key, ps);
|
fields.put(key, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getLocationChanged() {
|
public PwDate getLocationChanged() {
|
||||||
return parentGroupLastMod;
|
return parentGroupLastMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,31 +273,22 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
return usageCount;
|
return usageCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocationChanged(Date date) {
|
public void setLocationChanged(PwDate date) {
|
||||||
parentGroupLastMod = date;
|
parentGroupLastMod = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsageCount(long count) {
|
public void setUsageCount(long count) {
|
||||||
usageCount = count;
|
usageCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean expires() {
|
|
||||||
return expires;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpires(boolean exp) {
|
@Override
|
||||||
expires = exp;
|
public String getNotes() {
|
||||||
|
return decodeRefKey(mDecodeRef, STR_NOTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNotes(boolean decodeRef, PwDatabase db) {
|
public String getUrl() {
|
||||||
return decodeRefKey(decodeRef, STR_NOTES, db);
|
return decodeRefKey(mDecodeRef, STR_URL);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUrl(boolean decodeRef, PwDatabase db) {
|
|
||||||
return decodeRefKey(decodeRef, STR_URL, db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -417,7 +356,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
|
|
||||||
for (int i = 0; i < history.size(); i++) {
|
for (int i = 0; i < history.size(); i++) {
|
||||||
PwEntry entry = history.get(i);
|
PwEntry entry = history.get(i);
|
||||||
Date lastMod = entry.getLastModificationTime();
|
Date lastMod = entry.getLastModificationTime().getDate();
|
||||||
if ((min == null) || lastMod.before(min)) {
|
if ((min == null) || lastMod.before(min)) {
|
||||||
index = i;
|
index = i;
|
||||||
min = lastMod;
|
min = lastMod;
|
||||||
@@ -453,16 +392,16 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getExtraFields(PwDatabase pm) {
|
public Map<String, String> getExtraFields() {
|
||||||
Map<String, String> extraFields = super.getExtraFields(pm);
|
Map<String, String> extraFields = super.getExtraFields();
|
||||||
SprEngine spr = SprEngine.getInstance(pm);
|
SprEngineV4 spr = new SprEngineV4();
|
||||||
// Display custom fields
|
// Display custom fields
|
||||||
if (fields.size() > 0) {
|
if (fields.size() > 0) {
|
||||||
for (Map.Entry<String, ProtectedString> pair : fields.entrySet()) {
|
for (Map.Entry<String, ProtectedString> pair : fields.entrySet()) {
|
||||||
String key = pair.getKey();
|
String key = pair.getKey();
|
||||||
// TODO Add hidden style for protection field
|
// TODO Add hidden style for protection field
|
||||||
if (!PwEntryV4.IsStandardField(key)) {
|
if (!PwEntryV4.IsStandardField(key)) {
|
||||||
extraFields.put(key, spr.compile(pair.getValue().toString(), this, pm));
|
extraFields.put(key, spr.compile(pair.getValue().toString(), this, mDatabase));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -529,7 +468,7 @@ public class PwEntryV4 extends PwEntry implements ITimeLogger {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void touchLocation() {
|
public void touchLocation() {
|
||||||
parentGroupLastMod = new Date();
|
parentGroupLastMod = new PwDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,24 +24,40 @@ import com.keepassdroid.utils.StrUtil;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class PwGroup extends PwNode {
|
public abstract class PwGroup extends PwNode {
|
||||||
|
|
||||||
// TODO Change dependency and make private
|
// TODO Change dependency and make private
|
||||||
public List<PwGroup> childGroups = new ArrayList<>();
|
|
||||||
public List<PwEntry> childEntries = new ArrayList<>();
|
|
||||||
public String name = "";
|
|
||||||
public PwIconStandard icon;
|
|
||||||
|
|
||||||
private List<PwNode> children = new ArrayList<>();
|
protected String name = "";
|
||||||
|
protected PwIconStandard icon;
|
||||||
|
|
||||||
|
protected List<PwGroup> childGroups = new ArrayList<>();
|
||||||
|
protected List<PwEntry> childEntries = new ArrayList<>();
|
||||||
|
private transient List<PwNode> children = new ArrayList<>();
|
||||||
|
|
||||||
public void initNewGroup(String nm, PwGroupId newId) {
|
public void initNewGroup(String nm, PwGroupId newId) {
|
||||||
setId(newId);
|
setId(newId);
|
||||||
name = nm;
|
name = nm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PwGroup> getChildGroups() {
|
||||||
|
return childGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PwEntry> getChildEntries() {
|
||||||
|
return childEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroups(List<PwGroup> groups) {
|
||||||
|
childGroups = groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntries(List<PwEntry> entries) {
|
||||||
|
childEntries = entries;
|
||||||
|
}
|
||||||
|
|
||||||
public void addChildGroup(PwGroup group) {
|
public void addChildGroup(PwGroup group) {
|
||||||
this.childGroups.add(group);
|
this.childGroups.add(group);
|
||||||
}
|
}
|
||||||
@@ -50,6 +66,15 @@ public abstract class PwGroup extends PwNode {
|
|||||||
this.childEntries.add(entry);
|
this.childEntries.add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Todo parameter type
|
||||||
|
public PwGroup getChildGroupAt(int number) {
|
||||||
|
return this.childGroups.get(number);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PwEntry getChildEntryAt(int number) {
|
||||||
|
return this.childEntries.get(number);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeChildGroup(PwGroup group) {
|
public void removeChildGroup(PwGroup group) {
|
||||||
this.childGroups.remove(group);
|
this.childGroups.remove(group);
|
||||||
}
|
}
|
||||||
@@ -112,24 +137,33 @@ public abstract class PwGroup extends PwNode {
|
|||||||
return getName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getName();
|
public String getName() {
|
||||||
|
return name;
|
||||||
public abstract Date getLastMod();
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public PwIcon getIcon() {
|
public PwIcon getIcon() {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void setLastAccessTime(Date date);
|
|
||||||
|
|
||||||
public abstract void setLastModificationTime(Date date);
|
public PwIconStandard getIconStandard() {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(PwIconStandard icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean allowAddEntryIfIsRoot() {
|
public boolean allowAddEntryIfIsRoot() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void touch(boolean modified, boolean touchParents) {
|
public void touch(boolean modified, boolean touchParents) {
|
||||||
Date now = new Date();
|
PwDate now = new PwDate();
|
||||||
setLastAccessTime(now);
|
setLastAccessTime(now);
|
||||||
|
|
||||||
if (modified) {
|
if (modified) {
|
||||||
@@ -299,7 +333,8 @@ public abstract class PwGroup extends PwNode {
|
|||||||
if (object1.equals(object2))
|
if (object1.equals(object2))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int groupCreationComp = object1.getCreationTime().compareTo(object2.getCreationTime());
|
int groupCreationComp = object1.getCreationTime().getDate()
|
||||||
|
.compareTo(object2.getCreationTime().getDate());
|
||||||
// If same creation, can be different
|
// If same creation, can be different
|
||||||
if (groupCreationComp == 0) {
|
if (groupCreationComp == 0) {
|
||||||
return object1.hashCode() - object2.hashCode();
|
return object1.hashCode() - object2.hashCode();
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||||
|
|
||||||
This file was derived from
|
|
||||||
|
|
||||||
Copyright 2007 Naomaru Itoi <nao@phoneid.org>
|
|
||||||
|
|
||||||
This file was derived from
|
|
||||||
|
|
||||||
Java clone of KeePass - A KeePass file viewer for Java
|
|
||||||
Copyright 2006 Bill Zwicky <billzwicky@users.sourceforge.net>
|
|
||||||
|
|
||||||
*
|
*
|
||||||
* This file is part of KeePass DX.
|
* This file is part of KeePass DX.
|
||||||
*
|
*
|
||||||
@@ -30,15 +20,6 @@ Copyright 2006 Bill Zwicky <billzwicky@users.sourceforge.net>
|
|||||||
|
|
||||||
package com.keepassdroid.database;
|
package com.keepassdroid.database;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import com.keepassdroid.utils.Types;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brian Pellin <bpellin@gmail.com>
|
* @author Brian Pellin <bpellin@gmail.com>
|
||||||
* @author Naomaru Itoi <nao@phoneid.org>
|
* @author Naomaru Itoi <nao@phoneid.org>
|
||||||
@@ -47,39 +28,43 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class PwGroupV3 extends PwGroup {
|
public class PwGroupV3 extends PwGroup {
|
||||||
|
|
||||||
public String toString() {
|
// TODO Same as PwEntryV3
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Date NEVER_EXPIRE = PwEntryV3.NEVER_EXPIRE;
|
|
||||||
|
|
||||||
/** Size of byte buffer needed to hold this struct. */
|
|
||||||
public static final int BUF_SIZE = 124;
|
|
||||||
|
|
||||||
// for tree traversing
|
// for tree traversing
|
||||||
public PwGroupV3 parent = null;
|
private PwGroupV3 parent = null;
|
||||||
|
private int groupId;
|
||||||
|
|
||||||
public int groupId;
|
private int level = 0; // short
|
||||||
|
|
||||||
public PwDate tCreation;
|
|
||||||
public PwDate tLastMod;
|
|
||||||
public PwDate tLastAccess;
|
|
||||||
public PwDate tExpire;
|
|
||||||
|
|
||||||
public int level; // short
|
|
||||||
|
|
||||||
/** Used by KeePass internally, don't use */
|
/** Used by KeePass internally, don't use */
|
||||||
public int flags;
|
private int flags;
|
||||||
|
|
||||||
public void setGroups(List<PwGroup> groups) {
|
|
||||||
childGroups = groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PwGroup getParent() {
|
public PwGroup getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParent(PwGroup prt) {
|
||||||
|
parent = (PwGroupV3) prt;
|
||||||
|
level = parent.getLevel() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(int groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevel(int level) {
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PwGroupId getId() {
|
public PwGroupId getId() {
|
||||||
return new PwGroupIdV3(groupId);
|
return new PwGroupIdV3(groupId);
|
||||||
@@ -90,35 +75,6 @@ public class PwGroupV3 extends PwGroup {
|
|||||||
PwGroupIdV3 id3 = (PwGroupIdV3) id;
|
PwGroupIdV3 id3 = (PwGroupIdV3) id;
|
||||||
groupId = id3.getId();
|
groupId = id3.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getLastMod() {
|
|
||||||
return tLastMod.getJDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setParent(PwGroup prt) {
|
|
||||||
parent = (PwGroupV3) prt;
|
|
||||||
level = parent.level + 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initNewGroup(String nm, PwGroupId newId) {
|
|
||||||
super.initNewGroup(nm, newId);
|
|
||||||
|
|
||||||
Date now = Calendar.getInstance().getTime();
|
|
||||||
tCreation = new PwDate(now);
|
|
||||||
tLastAccess = new PwDate(now);
|
|
||||||
tLastMod = new PwDate(now);
|
|
||||||
tExpire = new PwDate(PwGroupV3.NEVER_EXPIRE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void populateBlankFields(PwDatabaseV3 db) {
|
public void populateBlankFields(PwDatabaseV3 db) {
|
||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
@@ -128,39 +84,18 @@ public class PwGroupV3 extends PwGroup {
|
|||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = "";
|
name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tCreation == null) {
|
|
||||||
tCreation = PwEntryV3.DEFAULT_PWDATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tLastMod == null) {
|
|
||||||
tLastMod = PwEntryV3.DEFAULT_PWDATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tLastAccess == null) {
|
|
||||||
tLastAccess = PwEntryV3.DEFAULT_PWDATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tExpire == null) {
|
|
||||||
tExpire = PwEntryV3.DEFAULT_PWDATE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getFlags() {
|
||||||
public void setLastAccessTime(Date date) {
|
return flags;
|
||||||
tLastAccess = new PwDate(date);
|
}
|
||||||
}
|
|
||||||
|
public void setFlags(int flags) {
|
||||||
|
this.flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLastModificationTime(Date date) {
|
public String toString() {
|
||||||
tLastMod = new PwDate(date);
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getCreationTime() {
|
|
||||||
if(tCreation != null)
|
|
||||||
return tCreation.getJDate();
|
|
||||||
else
|
|
||||||
return new Date();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.keepassdroid.database;
|
package com.keepassdroid.database;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -27,7 +26,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class PwGroupV4 extends PwGroup implements ITimeLogger {
|
public class PwGroupV4 extends PwGroup implements ITimeLogger {
|
||||||
|
|
||||||
//public static final int FOLDER_ICON = 48;
|
|
||||||
public static final boolean DEFAULT_SEARCHING_ENABLED = true;
|
public static final boolean DEFAULT_SEARCHING_ENABLED = true;
|
||||||
|
|
||||||
public PwGroupV4 parent = null;
|
public PwGroupV4 parent = null;
|
||||||
@@ -39,26 +37,19 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger {
|
|||||||
public Boolean enableAutoType = null;
|
public Boolean enableAutoType = null;
|
||||||
public Boolean enableSearching = null;
|
public Boolean enableSearching = null;
|
||||||
public UUID lastTopVisibleEntry = PwDatabaseV4.UUID_ZERO;
|
public UUID lastTopVisibleEntry = PwDatabaseV4.UUID_ZERO;
|
||||||
private Date parentGroupLastMod = PwDatabaseV4.DEFAULT_NOW;
|
private PwDate parentGroupLastMod = new PwDate();
|
||||||
private Date creation = PwDatabaseV4.DEFAULT_NOW;
|
|
||||||
private Date lastMod = PwDatabaseV4.DEFAULT_NOW;
|
|
||||||
private Date lastAccess = PwDatabaseV4.DEFAULT_NOW;
|
|
||||||
private Date expireDate = PwDatabaseV4.DEFAULT_NOW;
|
|
||||||
private boolean expires = false;
|
private boolean expires = false;
|
||||||
private long usageCount = 0;
|
private long usageCount = 0;
|
||||||
public Map<String, String> customData = new HashMap<String, String>();
|
public Map<String, String> customData = new HashMap<>();
|
||||||
|
|
||||||
public PwGroupV4() {}
|
public PwGroupV4() {}
|
||||||
|
|
||||||
public PwGroupV4(boolean createUUID, boolean setTimes, String name, PwIconStandard icon) {
|
public PwGroupV4(boolean createUUID, String name, PwIconStandard icon) {
|
||||||
if (createUUID) {
|
if (createUUID) {
|
||||||
uuid = UUID.randomUUID();
|
uuid = UUID.randomUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setTimes) {
|
|
||||||
creation = lastMod = lastAccess = new Date();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
}
|
}
|
||||||
@@ -67,7 +58,7 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger {
|
|||||||
public void initNewGroup(String nm, PwGroupId newId) {
|
public void initNewGroup(String nm, PwGroupId newId) {
|
||||||
super.initNewGroup(nm, newId);
|
super.initNewGroup(nm, newId);
|
||||||
|
|
||||||
lastAccess = lastMod = creation = parentGroupLastMod = new Date();
|
parentGroupLastMod = new PwDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddGroup(PwGroupV4 subGroup, boolean takeOwnership) {
|
public void AddGroup(PwGroupV4 subGroup, boolean takeOwnership) {
|
||||||
@@ -81,7 +72,7 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger {
|
|||||||
|
|
||||||
if ( takeOwnership ) subGroup.parent = this;
|
if ( takeOwnership ) subGroup.parent = this;
|
||||||
|
|
||||||
if ( updateLocationChanged ) subGroup.parentGroupLastMod = new Date(System.currentTimeMillis());
|
if ( updateLocationChanged ) subGroup.parentGroupLastMod = new PwDate(System.currentTimeMillis());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +87,7 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger {
|
|||||||
|
|
||||||
if ( takeOwnership ) pe.parent = this;
|
if ( takeOwnership ) pe.parent = this;
|
||||||
|
|
||||||
if ( updateLocationChanged ) pe.setLocationChanged(new Date(System.currentTimeMillis()));
|
if ( updateLocationChanged ) pe.setLocationChanged(new PwDate(System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -138,69 +129,31 @@ public class PwGroupV4 extends PwGroup implements ITimeLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public PwDate getLocationChanged() {
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getLastMod() {
|
|
||||||
return parentGroupLastMod;
|
return parentGroupLastMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreationTime() {
|
|
||||||
return creation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getExpiryTime() {
|
|
||||||
return expireDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLastAccessTime() {
|
|
||||||
return lastAccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLastModificationTime() {
|
|
||||||
return lastMod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLocationChanged() {
|
|
||||||
return parentGroupLastMod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getUsageCount() {
|
|
||||||
return usageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreationTime(Date date) {
|
|
||||||
creation = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpiryTime(Date date) {
|
|
||||||
expireDate = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLastAccessTime(Date date) {
|
public void setLocationChanged(PwDate date) {
|
||||||
lastAccess = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastModificationTime(Date date) {
|
|
||||||
lastMod = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocationChanged(Date date) {
|
|
||||||
parentGroupLastMod = date;
|
parentGroupLastMod = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getUsageCount() {
|
||||||
|
return usageCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setUsageCount(long count) {
|
public void setUsageCount(long count) {
|
||||||
usageCount = count;
|
usageCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean expires() {
|
public boolean expires() {
|
||||||
return expires;
|
return expires;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setExpires(boolean exp) {
|
public void setExpires(boolean exp) {
|
||||||
expires = exp;
|
expires = exp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,4 @@ public abstract class PwIcon implements Serializable {
|
|||||||
public boolean isMetaStreamIcon() {
|
public boolean isMetaStreamIcon() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeBytes() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,19 @@ package com.keepassdroid.database;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static com.keepassdroid.database.PwDate.NEVER_EXPIRE;
|
||||||
|
import static com.keepassdroid.database.PwDate.PW_NEVER_EXPIRE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class who manage Groups and Entries
|
* Abstract class who manage Groups and Entries
|
||||||
*/
|
*/
|
||||||
public abstract class PwNode implements Serializable {
|
public abstract class PwNode implements Serializable {
|
||||||
|
|
||||||
|
private PwDate creation = new PwDate();
|
||||||
|
private PwDate lastMod = new PwDate();
|
||||||
|
private PwDate lastAccess = new PwDate();
|
||||||
|
private PwDate expireDate = new PwDate(NEVER_EXPIRE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of available Nodes
|
* Type of available Nodes
|
||||||
*/
|
*/
|
||||||
@@ -50,11 +58,6 @@ public abstract class PwNode implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public abstract PwIcon getIcon();
|
public abstract PwIcon getIcon();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Creation date and time of the node
|
|
||||||
*/
|
|
||||||
public abstract Date getCreationTime();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the parent node
|
* Retrieve the parent node
|
||||||
* @return PwGroup parent as group
|
* @return PwGroup parent as group
|
||||||
@@ -85,4 +88,53 @@ public abstract class PwNode implements Serializable {
|
|||||||
boolean isSameType(PwNode otherNode) {
|
boolean isSameType(PwNode otherNode) {
|
||||||
return getType() != null ? getType().equals(otherNode.getType()) : otherNode.getType() == null;
|
return getType() != null ? getType().equals(otherNode.getType()) : otherNode.getType() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void assign(PwNode source) {
|
||||||
|
this.creation = source.creation;
|
||||||
|
this.lastMod = source.lastMod;
|
||||||
|
this.lastAccess = source.lastAccess;
|
||||||
|
this.expireDate = source.expireDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PwDate getCreationTime() {
|
||||||
|
return creation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreationTime(PwDate date) {
|
||||||
|
creation = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PwDate getLastModificationTime() {
|
||||||
|
return lastMod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastModificationTime(PwDate date) {
|
||||||
|
lastMod = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PwDate getLastAccessTime() {
|
||||||
|
return lastAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastAccessTime(PwDate date) {
|
||||||
|
lastAccess = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PwDate getExpiryTime() {
|
||||||
|
return expireDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiryTime(PwDate date) {
|
||||||
|
expireDate = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpires(boolean expires) {
|
||||||
|
if (!expires) {
|
||||||
|
expireDate = PW_NEVER_EXPIRE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean expires() {
|
||||||
|
return ! PwDate.IsSameDate(NEVER_EXPIRE, expireDate.getDate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,8 +164,8 @@ public enum SortNodeEnum {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int nodeCreationComp = object1.getCreationTime()
|
int nodeCreationComp = object1.getCreationTime().getDate()
|
||||||
.compareTo(object2.getCreationTime());
|
.compareTo(object2.getCreationTime().getDate());
|
||||||
// If same creation, can be different
|
// If same creation, can be different
|
||||||
if (nodeCreationComp == 0) {
|
if (nodeCreationComp == 0) {
|
||||||
return object1.hashCode() - object2.hashCode();
|
return object1.hashCode() - object2.hashCode();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class AddGroup extends RunnableOnFinish {
|
|||||||
// Generate new group
|
// Generate new group
|
||||||
mGroup = pm.createGroup();
|
mGroup = pm.createGroup();
|
||||||
mGroup.initNewGroup(mName, pm.newGroupId());
|
mGroup.initNewGroup(mName, pm.newGroupId());
|
||||||
mGroup.icon = mDb.pm.iconFactory.getIcon(mIconID);
|
mGroup.setIcon(mDb.pm.iconFactory.getIcon(mIconID));
|
||||||
pm.addGroupTo(mGroup, mParent);
|
pm.addGroupTo(mGroup, mParent);
|
||||||
|
|
||||||
// Commit to disk
|
// Commit to disk
|
||||||
|
|||||||
@@ -72,14 +72,14 @@ public class DeleteGroup extends RunnableOnFinish {
|
|||||||
else {
|
else {
|
||||||
// TODO tests
|
// TODO tests
|
||||||
// Remove child entries
|
// Remove child entries
|
||||||
List<PwEntry> childEnt = new ArrayList<>(mGroup.childEntries);
|
List<PwEntry> childEnt = new ArrayList<>(mGroup.getChildEntries());
|
||||||
for ( int i = 0; i < childEnt.size(); i++ ) {
|
for ( int i = 0; i < childEnt.size(); i++ ) {
|
||||||
DeleteEntry task = new DeleteEntry(mContext, mDb, childEnt.get(i), null, true);
|
DeleteEntry task = new DeleteEntry(mContext, mDb, childEnt.get(i), null, true);
|
||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove child groups
|
// Remove child groups
|
||||||
List<PwGroup> childGrp = new ArrayList<>(mGroup.childGroups);
|
List<PwGroup> childGrp = new ArrayList<>(mGroup.getChildGroups());
|
||||||
for ( int i = 0; i < childGrp.size(); i++ ) {
|
for ( int i = 0; i < childGrp.size(); i++ ) {
|
||||||
DeleteGroup task = new DeleteGroup(mContext, mDb, childGrp.get(i), null, true);
|
DeleteGroup task = new DeleteGroup(mContext, mDb, childGrp.get(i), null, true);
|
||||||
task.run();
|
task.run();
|
||||||
|
|||||||
@@ -340,31 +340,31 @@ public class ImporterV3 extends Importer {
|
|||||||
// Ignore field
|
// Ignore field
|
||||||
break;
|
break;
|
||||||
case 0x0001 :
|
case 0x0001 :
|
||||||
grp.groupId = LEDataInputStream.readInt(buf, offset);
|
grp.setGroupId(LEDataInputStream.readInt(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0002 :
|
case 0x0002 :
|
||||||
grp.name = Types.readCString(buf, offset);
|
grp.setName(Types.readCString(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0003 :
|
case 0x0003 :
|
||||||
grp.tCreation = new PwDate(buf, offset);
|
grp.setCreationTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0004 :
|
case 0x0004 :
|
||||||
grp.tLastMod = new PwDate(buf, offset);
|
grp.setLastModificationTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0005 :
|
case 0x0005 :
|
||||||
grp.tLastAccess = new PwDate(buf, offset);
|
grp.setLastAccessTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0006 :
|
case 0x0006 :
|
||||||
grp.tExpire = new PwDate(buf, offset);
|
grp.setExpiryTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0007 :
|
case 0x0007 :
|
||||||
grp.icon = db.iconFactory.getIcon(LEDataInputStream.readInt(buf, offset));
|
grp.setIcon(db.iconFactory.getIcon(LEDataInputStream.readInt(buf, offset)));
|
||||||
break;
|
break;
|
||||||
case 0x0008 :
|
case 0x0008 :
|
||||||
grp.level = LEDataInputStream.readUShort(buf, offset);
|
grp.setLevel(LEDataInputStream.readUShort(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0009 :
|
case 0x0009 :
|
||||||
grp.flags = LEDataInputStream.readInt(buf, offset);
|
grp.setFlags(LEDataInputStream.readInt(buf, offset));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +387,7 @@ public class ImporterV3 extends Importer {
|
|||||||
ent.setUUID(Types.bytestoUUID(buf, offset));
|
ent.setUUID(Types.bytestoUUID(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0002 :
|
case 0x0002 :
|
||||||
ent.groupId = LEDataInputStream.readInt(buf, offset);
|
ent.setGroupId(LEDataInputStream.readInt(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0003 :
|
case 0x0003 :
|
||||||
int iconId = LEDataInputStream.readInt(buf, offset);
|
int iconId = LEDataInputStream.readInt(buf, offset);
|
||||||
@@ -400,34 +400,34 @@ public class ImporterV3 extends Importer {
|
|||||||
ent.icon = db.iconFactory.getIcon(iconId);
|
ent.icon = db.iconFactory.getIcon(iconId);
|
||||||
break;
|
break;
|
||||||
case 0x0004 :
|
case 0x0004 :
|
||||||
ent.title = Types.readCString(buf, offset);
|
ent.setTitle(Types.readCString(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0005 :
|
case 0x0005 :
|
||||||
ent.url = Types.readCString(buf, offset);
|
ent.setUrl(Types.readCString(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0006 :
|
case 0x0006 :
|
||||||
ent.username = Types.readCString(buf, offset);
|
ent.setUsername(Types.readCString(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0007 :
|
case 0x0007 :
|
||||||
ent.setPassword(buf, offset, Types.strlen(buf, offset));
|
ent.setPassword(buf, offset, Types.strlen(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0008 :
|
case 0x0008 :
|
||||||
ent.additional = Types.readCString(buf, offset);
|
ent.setNotes(Types.readCString(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x0009 :
|
case 0x0009 :
|
||||||
ent.tCreation = new PwDate(buf, offset);
|
ent.setCreationTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x000A :
|
case 0x000A :
|
||||||
ent.tLastMod = new PwDate(buf, offset);
|
ent.setLastModificationTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x000B :
|
case 0x000B :
|
||||||
ent.tLastAccess = new PwDate(buf, offset);
|
ent.setLastAccessTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x000C :
|
case 0x000C :
|
||||||
ent.tExpire = new PwDate(buf, offset);
|
ent.setExpiryTime(new PwDate(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x000D :
|
case 0x000D :
|
||||||
ent.binaryDesc = Types.readCString(buf, offset);
|
ent.setBinaryDesc(Types.readCString(buf, offset));
|
||||||
break;
|
break;
|
||||||
case 0x000E :
|
case 0x000E :
|
||||||
ent.setBinaryData(buf, offset, fieldSize);
|
ent.setBinaryData(buf, offset, fieldSize);
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import org.xmlpull.v1.XmlPullParserFactory;
|
|||||||
|
|
||||||
import biz.source_code.base64Coder.Base64Coder;
|
import biz.source_code.base64Coder.Base64Coder;
|
||||||
|
|
||||||
|
import com.keepassdroid.database.PwDate;
|
||||||
import com.keepassdroid.tasks.UpdateStatus;
|
import com.keepassdroid.tasks.UpdateStatus;
|
||||||
import com.keepassdroid.crypto.CipherFactory;
|
import com.keepassdroid.crypto.CipherFactory;
|
||||||
import com.keepassdroid.crypto.PwStreamCipherFactory;
|
import com.keepassdroid.crypto.PwStreamCipherFactory;
|
||||||
@@ -559,11 +560,11 @@ public class ImporterV4 extends Importer {
|
|||||||
if ( name.equalsIgnoreCase(ElemUuid) ) {
|
if ( name.equalsIgnoreCase(ElemUuid) ) {
|
||||||
ctxGroup.uuid = ReadUuid(xpp);
|
ctxGroup.uuid = ReadUuid(xpp);
|
||||||
} else if ( name.equalsIgnoreCase(ElemName) ) {
|
} else if ( name.equalsIgnoreCase(ElemName) ) {
|
||||||
ctxGroup.name = ReadString(xpp);
|
ctxGroup.setName(ReadString(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(ElemNotes) ) {
|
} else if ( name.equalsIgnoreCase(ElemNotes) ) {
|
||||||
ctxGroup.notes = ReadString(xpp);
|
ctxGroup.notes = ReadString(xpp);
|
||||||
} else if ( name.equalsIgnoreCase(ElemIcon) ) {
|
} else if ( name.equalsIgnoreCase(ElemIcon) ) {
|
||||||
ctxGroup.icon = db.iconFactory.getIcon((int)ReadUInt(xpp, 0));
|
ctxGroup.setIcon(db.iconFactory.getIcon((int)ReadUInt(xpp, 0)));
|
||||||
} else if ( name.equalsIgnoreCase(ElemCustomIconID) ) {
|
} else if ( name.equalsIgnoreCase(ElemCustomIconID) ) {
|
||||||
ctxGroup.customIcon = db.iconFactory.getIcon(ReadUuid(xpp));
|
ctxGroup.customIcon = db.iconFactory.getIcon(ReadUuid(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(ElemTimes) ) {
|
} else if ( name.equalsIgnoreCase(ElemTimes) ) {
|
||||||
@@ -679,19 +680,19 @@ public class ImporterV4 extends Importer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( name.equalsIgnoreCase(ElemLastModTime) ) {
|
if ( name.equalsIgnoreCase(ElemLastModTime) ) {
|
||||||
tl.setLastModificationTime(ReadTime(xpp));
|
tl.setLastModificationTime(ReadPwTime(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(ElemCreationTime) ) {
|
} else if ( name.equalsIgnoreCase(ElemCreationTime) ) {
|
||||||
tl.setCreationTime(ReadTime(xpp));
|
tl.setCreationTime(ReadPwTime(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(ElemLastAccessTime) ) {
|
} else if ( name.equalsIgnoreCase(ElemLastAccessTime) ) {
|
||||||
tl.setLastAccessTime(ReadTime(xpp));
|
tl.setLastAccessTime(ReadPwTime(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(ElemExpiryTime) ) {
|
} else if ( name.equalsIgnoreCase(ElemExpiryTime) ) {
|
||||||
tl.setExpiryTime(ReadTime(xpp));
|
tl.setExpiryTime(ReadPwTime(xpp));
|
||||||
} else if ( name.equalsIgnoreCase(ElemExpires) ) {
|
} else if ( name.equalsIgnoreCase(ElemExpires) ) {
|
||||||
tl.setExpires(ReadBool(xpp, false));
|
tl.setExpires(ReadBool(xpp, false));
|
||||||
} else if ( name.equalsIgnoreCase(ElemUsageCount) ) {
|
} else if ( name.equalsIgnoreCase(ElemUsageCount) ) {
|
||||||
tl.setUsageCount(ReadULong(xpp, 0));
|
tl.setUsageCount(ReadULong(xpp, 0));
|
||||||
} else if ( name.equalsIgnoreCase(ElemLocationChanged) ) {
|
} else if ( name.equalsIgnoreCase(ElemLocationChanged) ) {
|
||||||
tl.setLocationChanged(ReadTime(xpp));
|
tl.setLocationChanged(ReadPwTime(xpp));
|
||||||
} else {
|
} else {
|
||||||
ReadUnknown(xpp);
|
ReadUnknown(xpp);
|
||||||
}
|
}
|
||||||
@@ -849,8 +850,8 @@ public class ImporterV4 extends Importer {
|
|||||||
return KdbContext.GroupCustomData;
|
return KdbContext.GroupCustomData;
|
||||||
|
|
||||||
} else if ( ctx == KdbContext.Entry && name.equalsIgnoreCase(ElemEntry) ) {
|
} else if ( ctx == KdbContext.Entry && name.equalsIgnoreCase(ElemEntry) ) {
|
||||||
if ( ctxEntry.uuid == null || ctxEntry.uuid.equals(PwDatabaseV4.UUID_ZERO) ) {
|
if ( ctxEntry.getUUID() == null || ctxEntry.getUUID().equals(PwDatabaseV4.UUID_ZERO) ) {
|
||||||
ctxEntry.uuid = UUID.randomUUID();
|
ctxEntry.setUUID(UUID.randomUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( entryInHistory ) {
|
if ( entryInHistory ) {
|
||||||
@@ -912,6 +913,10 @@ public class ImporterV4 extends Importer {
|
|||||||
throw new RuntimeException("Invalid end element: Context " + contextName + "End element: " + name);
|
throw new RuntimeException("Invalid end element: Context " + contextName + "End element: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PwDate ReadPwTime(XmlPullParser xpp) throws IOException, XmlPullParserException {
|
||||||
|
return new PwDate(ReadTime(xpp));
|
||||||
|
}
|
||||||
|
|
||||||
private Date ReadTime(XmlPullParser xpp) throws IOException, XmlPullParserException {
|
private Date ReadTime(XmlPullParser xpp) throws IOException, XmlPullParserException {
|
||||||
String sDate = ReadString(xpp);
|
String sDate = ReadString(xpp);
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ public class PwDbV3Output extends PwDbOutput {
|
|||||||
|
|
||||||
// Recurse over children
|
// Recurse over children
|
||||||
for ( int i = 0; i < group.numbersOfChildGroups(); i++ ) {
|
for ( int i = 0; i < group.numbersOfChildGroups(); i++ ) {
|
||||||
sortGroup((PwGroupV3) group.childGroups.get(i), groupList);
|
sortGroup((PwGroupV3) group.getChildGroupAt(i), groupList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -435,9 +435,9 @@ public class PwDbV4Output extends PwDbOutput {
|
|||||||
private void startGroup(PwGroupV4 group) throws IllegalArgumentException, IllegalStateException, IOException {
|
private void startGroup(PwGroupV4 group) throws IllegalArgumentException, IllegalStateException, IOException {
|
||||||
xml.startTag(null, ElemGroup);
|
xml.startTag(null, ElemGroup);
|
||||||
writeObject(ElemUuid, group.uuid);
|
writeObject(ElemUuid, group.uuid);
|
||||||
writeObject(ElemName, group.name);
|
writeObject(ElemName, group.getName());
|
||||||
writeObject(ElemNotes, group.notes);
|
writeObject(ElemNotes, group.notes);
|
||||||
writeObject(ElemIcon, group.icon.iconId);
|
writeObject(ElemIcon, group.getIconStandard().iconId);
|
||||||
|
|
||||||
if (!group.customIcon.equals(PwIconCustom.ZERO)) {
|
if (!group.customIcon.equals(PwIconCustom.ZERO)) {
|
||||||
writeObject(ElemCustomIconID, group.customIcon.uuid);
|
writeObject(ElemCustomIconID, group.customIcon.uuid);
|
||||||
@@ -461,7 +461,7 @@ public class PwDbV4Output extends PwDbOutput {
|
|||||||
|
|
||||||
xml.startTag(null, ElemEntry);
|
xml.startTag(null, ElemEntry);
|
||||||
|
|
||||||
writeObject(ElemUuid, entry.uuid);
|
writeObject(ElemUuid, entry.getUUID());
|
||||||
writeObject(ElemIcon, entry.icon.iconId);
|
writeObject(ElemIcon, entry.icon.iconId);
|
||||||
|
|
||||||
if (!entry.customIcon.equals(PwIconCustom.ZERO)) {
|
if (!entry.customIcon.equals(PwIconCustom.ZERO)) {
|
||||||
@@ -755,13 +755,13 @@ public class PwDbV4Output extends PwDbOutput {
|
|||||||
|
|
||||||
xml.startTag(null, name);
|
xml.startTag(null, name);
|
||||||
|
|
||||||
writeObject(ElemLastModTime, it.getLastModificationTime());
|
writeObject(ElemLastModTime, it.getLastModificationTime().getDate());
|
||||||
writeObject(ElemCreationTime, it.getCreationTime());
|
writeObject(ElemCreationTime, it.getCreationTime().getDate());
|
||||||
writeObject(ElemLastAccessTime, it.getLastAccessTime());
|
writeObject(ElemLastAccessTime, it.getLastAccessTime().getDate());
|
||||||
writeObject(ElemExpiryTime, it.getExpiryTime());
|
writeObject(ElemExpiryTime, it.getExpiryTime().getDate());
|
||||||
writeObject(ElemExpires, it.expires());
|
writeObject(ElemExpires, it.expires());
|
||||||
writeObject(ElemUsageCount, it.getUsageCount());
|
writeObject(ElemUsageCount, it.getUsageCount());
|
||||||
writeObject(ElemLocationChanged, it.getLocationChanged());
|
writeObject(ElemLocationChanged, it.getLocationChanged().getDate());
|
||||||
|
|
||||||
xml.endTag(null, name);
|
xml.endTag(null, name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class PwEntryOutputV3 {
|
|||||||
// Group ID
|
// Group ID
|
||||||
mOS.write(GROUPID_FIELD_TYPE);
|
mOS.write(GROUPID_FIELD_TYPE);
|
||||||
mOS.write(LONG_FOUR);
|
mOS.write(LONG_FOUR);
|
||||||
mOS.write(LEDataOutputStream.writeIntBuf(mPE.groupId));
|
mOS.write(LEDataOutputStream.writeIntBuf(mPE.getGroupId()));
|
||||||
|
|
||||||
// Image ID
|
// Image ID
|
||||||
mOS.write(IMAGEID_FIELD_TYPE);
|
mOS.write(IMAGEID_FIELD_TYPE);
|
||||||
@@ -89,17 +89,17 @@ public class PwEntryOutputV3 {
|
|||||||
// Title
|
// Title
|
||||||
//byte[] title = mPE.title.getBytes("UTF-8");
|
//byte[] title = mPE.title.getBytes("UTF-8");
|
||||||
mOS.write(TITLE_FIELD_TYPE);
|
mOS.write(TITLE_FIELD_TYPE);
|
||||||
int titleLen = Types.writeCString(mPE.title, mOS);
|
int titleLen = Types.writeCString(mPE.getTitle(), mOS);
|
||||||
outputBytes += titleLen;
|
outputBytes += titleLen;
|
||||||
|
|
||||||
// URL
|
// URL
|
||||||
mOS.write(URL_FIELD_TYPE);
|
mOS.write(URL_FIELD_TYPE);
|
||||||
int urlLen = Types.writeCString(mPE.url, mOS);
|
int urlLen = Types.writeCString(mPE.getUrl(), mOS);
|
||||||
outputBytes += urlLen;
|
outputBytes += urlLen;
|
||||||
|
|
||||||
// Username
|
// Username
|
||||||
mOS.write(USERNAME_FIELD_TYPE);
|
mOS.write(USERNAME_FIELD_TYPE);
|
||||||
int userLen = Types.writeCString(mPE.username, mOS);
|
int userLen = Types.writeCString(mPE.getUsername(), mOS);
|
||||||
outputBytes += userLen;
|
outputBytes += userLen;
|
||||||
|
|
||||||
// Password
|
// Password
|
||||||
@@ -112,24 +112,24 @@ public class PwEntryOutputV3 {
|
|||||||
|
|
||||||
// Additional
|
// Additional
|
||||||
mOS.write(ADDITIONAL_FIELD_TYPE);
|
mOS.write(ADDITIONAL_FIELD_TYPE);
|
||||||
int addlLen = Types.writeCString(mPE.additional, mOS);
|
int addlLen = Types.writeCString(mPE.getNotes(), mOS);
|
||||||
outputBytes += addlLen;
|
outputBytes += addlLen;
|
||||||
|
|
||||||
// Create date
|
// Create date
|
||||||
writeDate(CREATE_FIELD_TYPE, mPE.tCreation.getCDate());
|
writeDate(CREATE_FIELD_TYPE, mPE.getCreationTime().getCDate());
|
||||||
|
|
||||||
// Modification date
|
// Modification date
|
||||||
writeDate(MOD_FIELD_TYPE, mPE.tLastMod.getCDate());
|
writeDate(MOD_FIELD_TYPE, mPE.getLastModificationTime().getCDate());
|
||||||
|
|
||||||
// Access date
|
// Access date
|
||||||
writeDate(ACCESS_FIELD_TYPE, mPE.tLastAccess.getCDate());
|
writeDate(ACCESS_FIELD_TYPE, mPE.getLastAccessTime().getCDate());
|
||||||
|
|
||||||
// Expiration date
|
// Expiration date
|
||||||
writeDate(EXPIRE_FIELD_TYPE, mPE.tExpire.getCDate());
|
writeDate(EXPIRE_FIELD_TYPE, mPE.getExpiryTime().getCDate());
|
||||||
|
|
||||||
// Binary desc
|
// Binary desc
|
||||||
mOS.write(BINARY_DESC_FIELD_TYPE);
|
mOS.write(BINARY_DESC_FIELD_TYPE);
|
||||||
int descLen = Types.writeCString(mPE.binaryDesc, mOS);
|
int descLen = Types.writeCString(mPE.getBinaryDesc(), mOS);
|
||||||
outputBytes += descLen;
|
outputBytes += descLen;
|
||||||
|
|
||||||
// Binary data
|
// Binary data
|
||||||
|
|||||||
@@ -65,46 +65,46 @@ public class PwGroupOutputV3 {
|
|||||||
// Group ID
|
// Group ID
|
||||||
mOS.write(GROUPID_FIELD_TYPE);
|
mOS.write(GROUPID_FIELD_TYPE);
|
||||||
mOS.write(GROUPID_FIELD_SIZE);
|
mOS.write(GROUPID_FIELD_SIZE);
|
||||||
mOS.write(LEDataOutputStream.writeIntBuf(mPG.groupId));
|
mOS.write(LEDataOutputStream.writeIntBuf(mPG.getGroupId()));
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
mOS.write(NAME_FIELD_TYPE);
|
mOS.write(NAME_FIELD_TYPE);
|
||||||
Types.writeCString(mPG.name, mOS);
|
Types.writeCString(mPG.getName(), mOS);
|
||||||
|
|
||||||
// Create date
|
// Create date
|
||||||
mOS.write(CREATE_FIELD_TYPE);
|
mOS.write(CREATE_FIELD_TYPE);
|
||||||
mOS.write(DATE_FIELD_SIZE);
|
mOS.write(DATE_FIELD_SIZE);
|
||||||
mOS.write(mPG.tCreation.getCDate());
|
mOS.write(mPG.getCreationTime().getCDate());
|
||||||
|
|
||||||
// Modification date
|
// Modification date
|
||||||
mOS.write(MOD_FIELD_TYPE);
|
mOS.write(MOD_FIELD_TYPE);
|
||||||
mOS.write(DATE_FIELD_SIZE);
|
mOS.write(DATE_FIELD_SIZE);
|
||||||
mOS.write(mPG.tLastMod.getCDate());
|
mOS.write(mPG.getLastModificationTime().getCDate());
|
||||||
|
|
||||||
// Access date
|
// Access date
|
||||||
mOS.write(ACCESS_FIELD_TYPE);
|
mOS.write(ACCESS_FIELD_TYPE);
|
||||||
mOS.write(DATE_FIELD_SIZE);
|
mOS.write(DATE_FIELD_SIZE);
|
||||||
mOS.write(mPG.tLastAccess.getCDate());
|
mOS.write(mPG.getLastAccessTime().getCDate());
|
||||||
|
|
||||||
// Expiration date
|
// Expiration date
|
||||||
mOS.write(EXPIRE_FIELD_TYPE);
|
mOS.write(EXPIRE_FIELD_TYPE);
|
||||||
mOS.write(DATE_FIELD_SIZE);
|
mOS.write(DATE_FIELD_SIZE);
|
||||||
mOS.write(mPG.tExpire.getCDate());
|
mOS.write(mPG.getExpiryTime().getCDate());
|
||||||
|
|
||||||
// Image ID
|
// Image ID
|
||||||
mOS.write(IMAGEID_FIELD_TYPE);
|
mOS.write(IMAGEID_FIELD_TYPE);
|
||||||
mOS.write(IMAGEID_FIELD_SIZE);
|
mOS.write(IMAGEID_FIELD_SIZE);
|
||||||
mOS.write(LEDataOutputStream.writeIntBuf(mPG.icon.iconId));
|
mOS.write(LEDataOutputStream.writeIntBuf(mPG.getIconStandard().iconId));
|
||||||
|
|
||||||
// Level
|
// Level
|
||||||
mOS.write(LEVEL_FIELD_TYPE);
|
mOS.write(LEVEL_FIELD_TYPE);
|
||||||
mOS.write(LEVEL_FIELD_SIZE);
|
mOS.write(LEVEL_FIELD_SIZE);
|
||||||
mOS.write(LEDataOutputStream.writeUShortBuf(mPG.level));
|
mOS.write(LEDataOutputStream.writeUShortBuf(mPG.getLevel()));
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
mOS.write(FLAGS_FIELD_TYPE);
|
mOS.write(FLAGS_FIELD_TYPE);
|
||||||
mOS.write(FLAGS_FIELD_SIZE);
|
mOS.write(FLAGS_FIELD_SIZE);
|
||||||
mOS.write(LEDataOutputStream.writeIntBuf(mPG.flags));
|
mOS.write(LEDataOutputStream.writeIntBuf(mPG.getFlags()));
|
||||||
|
|
||||||
// End
|
// End
|
||||||
mOS.write(END_FIELD_TYPE);
|
mOS.write(END_FIELD_TYPE);
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ public class SearchDbHelper {
|
|||||||
Log.d("SearchDbHelper", "Tried to search with unknown db");
|
Log.d("SearchDbHelper", "Tried to search with unknown db");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
group.name = mCtx.getString(R.string.search_results);
|
group.setName(mCtx.getString(R.string.search_results));
|
||||||
group.childEntries = new ArrayList<PwEntry>();
|
group.setEntries(new ArrayList<>());
|
||||||
|
|
||||||
// Search all entries
|
// Search all entries
|
||||||
Locale loc = Locale.getDefault();
|
Locale loc = Locale.getDefault();
|
||||||
@@ -83,11 +83,11 @@ public class SearchDbHelper {
|
|||||||
PwGroup top = worklist.remove();
|
PwGroup top = worklist.remove();
|
||||||
|
|
||||||
if (pm.isGroupSearchable(top, isOmitBackup)) {
|
if (pm.isGroupSearchable(top, isOmitBackup)) {
|
||||||
for (PwEntry entry : top.childEntries) {
|
for (PwEntry entry : top.getChildEntries()) {
|
||||||
processEntries(entry, group.childEntries, qStr, loc);
|
processEntries(entry, group.getChildEntries(), qStr, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PwGroup childGroup : top.childGroups) {
|
for (PwGroup childGroup : top.getChildGroups()) {
|
||||||
if (childGroup != null) {
|
if (childGroup != null) {
|
||||||
worklist.add(childGroup);
|
worklist.add(childGroup);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ package com.keepassdroid.utils;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import com.keepassdroid.database.PwDate;
|
import com.keepassdroid.database.PwDate;
|
||||||
import com.keepassdroid.database.PwEntryV3;
|
|
||||||
|
import static com.keepassdroid.database.PwDate.DEFAULT_PWDATE;
|
||||||
|
|
||||||
public class EmptyUtils {
|
public class EmptyUtils {
|
||||||
public static boolean isNullOrEmpty(String str) {
|
public static boolean isNullOrEmpty(String str) {
|
||||||
@@ -34,7 +35,7 @@ public class EmptyUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNullOrEmpty(PwDate date) {
|
public static boolean isNullOrEmpty(PwDate date) {
|
||||||
return (date == null) || date.equals(PwEntryV3.DEFAULT_PWDATE);
|
return (date == null) || date.equals(DEFAULT_PWDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNullOrEmpty(Uri uri) {
|
public static boolean isNullOrEmpty(Uri uri) {
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
|
||||||
*
|
|
||||||
* This file is part of KeePass DX.
|
|
||||||
*
|
|
||||||
* KeePass DX is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* KeePass DX is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.keepassdroid.utils;
|
|
||||||
|
|
||||||
import com.keepassdroid.database.PwDatabase;
|
|
||||||
import com.keepassdroid.database.PwDatabaseV4;
|
|
||||||
import com.keepassdroid.database.PwEntry;
|
|
||||||
|
|
||||||
public class SprEngine {
|
|
||||||
|
|
||||||
private static SprEngineV4 sprV4 = new SprEngineV4();
|
|
||||||
private static SprEngine spr = new SprEngine();
|
|
||||||
|
|
||||||
public static SprEngine getInstance(PwDatabase db) {
|
|
||||||
if (db instanceof PwDatabaseV4) {
|
|
||||||
return sprV4;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return spr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String compile(String text, PwEntry entry, PwDatabase database) {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -30,7 +30,7 @@ import com.keepassdroid.database.PwEntry;
|
|||||||
import com.keepassdroid.database.PwEntryV4;
|
import com.keepassdroid.database.PwEntryV4;
|
||||||
import com.keepassdroid.database.SearchParametersV4;
|
import com.keepassdroid.database.SearchParametersV4;
|
||||||
|
|
||||||
public class SprEngineV4 extends SprEngine {
|
public class SprEngineV4 {
|
||||||
private final int MAX_RECURSION_DEPTH = 12;
|
private final int MAX_RECURSION_DEPTH = 12;
|
||||||
private final String STR_REF_START = "{REF:";
|
private final String STR_REF_START = "{REF:";
|
||||||
private final String STR_REF_END = "}";
|
private final String STR_REF_END = "}";
|
||||||
@@ -45,7 +45,6 @@ public class SprEngineV4 extends SprEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String compile(String text, PwEntry entry, PwDatabase database) {
|
public String compile(String text, PwEntry entry, PwDatabase database) {
|
||||||
SprContextV4 ctx = new SprContextV4((PwDatabaseV4)database, (PwEntryV4)entry);
|
SprContextV4 ctx = new SprContextV4((PwDatabaseV4)database, (PwEntryV4)entry);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user