mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-22 23:09:13 +00:00
Strip a biometric slot when a backup is made
This commit is contained in:
parent
1201b505f7
commit
62f25d9ae9
2 changed files with 20 additions and 23 deletions
|
@ -75,6 +75,7 @@ public class SlotList extends UUIDMap<Slot> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a copy of this SlotList that is suitable for exporting.
|
* Returns a copy of this SlotList that is suitable for exporting.
|
||||||
|
* Strips biometric slots.
|
||||||
* In case there's a backup password slot, any regular password slots are stripped.
|
* In case there's a backup password slot, any regular password slots are stripped.
|
||||||
*/
|
*/
|
||||||
public SlotList exportable() {
|
public SlotList exportable() {
|
||||||
|
@ -85,18 +86,16 @@ public class SlotList extends UUIDMap<Slot> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasBackupSlots) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
SlotList slots = new SlotList();
|
SlotList slots = new SlotList();
|
||||||
for (Slot slot : this) {
|
for (Slot slot : this) {
|
||||||
if (!(slot instanceof PasswordSlot) || ((PasswordSlot) slot).isBackup()) {
|
if (slot instanceof BiometricSlot) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (hasBackupSlots && slot instanceof PasswordSlot && !((PasswordSlot) slot).isBackup()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
slots.add(slot);
|
slots.add(slot);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return slots;
|
return slots;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.beemdevelopment.aegis.vault.slots;
|
package com.beemdevelopment.aegis.vault.slots;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.crypto.CryptoUtils;
|
import com.beemdevelopment.aegis.crypto.CryptoUtils;
|
||||||
|
@ -96,22 +95,21 @@ public class SlotTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPasswordSlotExclusion() {
|
public void testNonExportableSlotsExclusion() {
|
||||||
SlotList slots = new SlotList();
|
Slot rawSlot = new RawSlot();
|
||||||
PasswordSlot passSlot = new PasswordSlot();
|
Slot passwordSlot = new PasswordSlot();
|
||||||
PasswordSlot passSlot2 = new PasswordSlot();
|
Slot biometricSlot = new BiometricSlot();
|
||||||
slots.add(passSlot);
|
|
||||||
slots.add(passSlot2);
|
|
||||||
|
|
||||||
assertArrayEquals(slots.getValues().toArray(), slots.exportable().getValues().toArray());
|
|
||||||
|
|
||||||
SlotList backupSlots = new SlotList();
|
|
||||||
PasswordSlot backupSlot = new PasswordSlot();
|
PasswordSlot backupSlot = new PasswordSlot();
|
||||||
backupSlot.setIsBackup(true);
|
backupSlot.setIsBackup(true);
|
||||||
|
SlotList slots = new SlotList();
|
||||||
|
slots.add(rawSlot);
|
||||||
|
slots.add(passwordSlot);
|
||||||
|
slots.add(biometricSlot);
|
||||||
slots.add(backupSlot);
|
slots.add(backupSlot);
|
||||||
backupSlots.add(backupSlot);
|
SlotList actual = slots.exportable();
|
||||||
|
SlotList expected = new SlotList();
|
||||||
assertArrayEquals(backupSlots.getValues().toArray(), slots.exportable().getValues().toArray());
|
expected.add(rawSlot);
|
||||||
assertNotEquals(slots.getValues().toArray(), slots.exportable().getValues().toArray());
|
expected.add(backupSlot);
|
||||||
|
assertArrayEquals(expected.getValues().toArray(), actual.getValues().toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue