mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-23 23:39:14 +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.
|
||||
* Strips biometric slots.
|
||||
* In case there's a backup password slot, any regular password slots are stripped.
|
||||
*/
|
||||
public SlotList exportable() {
|
||||
|
@ -85,18 +86,16 @@ public class SlotList extends UUIDMap<Slot> {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasBackupSlots) {
|
||||
return this;
|
||||
}
|
||||
|
||||
SlotList slots = new SlotList();
|
||||
for (Slot slot : this) {
|
||||
if (!(slot instanceof PasswordSlot) || ((PasswordSlot) slot).isBackup()) {
|
||||
slots.add(slot);
|
||||
if (slot instanceof BiometricSlot) {
|
||||
continue;
|
||||
}
|
||||
if (hasBackupSlots && slot instanceof PasswordSlot && !((PasswordSlot) slot).isBackup()) {
|
||||
continue;
|
||||
}
|
||||
slots.add(slot);
|
||||
}
|
||||
|
||||
return slots;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.beemdevelopment.aegis.vault.slots;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import com.beemdevelopment.aegis.crypto.CryptoUtils;
|
||||
|
@ -96,22 +95,21 @@ public class SlotTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPasswordSlotExclusion() {
|
||||
SlotList slots = new SlotList();
|
||||
PasswordSlot passSlot = new PasswordSlot();
|
||||
PasswordSlot passSlot2 = new PasswordSlot();
|
||||
slots.add(passSlot);
|
||||
slots.add(passSlot2);
|
||||
|
||||
assertArrayEquals(slots.getValues().toArray(), slots.exportable().getValues().toArray());
|
||||
|
||||
SlotList backupSlots = new SlotList();
|
||||
public void testNonExportableSlotsExclusion() {
|
||||
Slot rawSlot = new RawSlot();
|
||||
Slot passwordSlot = new PasswordSlot();
|
||||
Slot biometricSlot = new BiometricSlot();
|
||||
PasswordSlot backupSlot = new PasswordSlot();
|
||||
backupSlot.setIsBackup(true);
|
||||
SlotList slots = new SlotList();
|
||||
slots.add(rawSlot);
|
||||
slots.add(passwordSlot);
|
||||
slots.add(biometricSlot);
|
||||
slots.add(backupSlot);
|
||||
backupSlots.add(backupSlot);
|
||||
|
||||
assertArrayEquals(backupSlots.getValues().toArray(), slots.exportable().getValues().toArray());
|
||||
assertNotEquals(slots.getValues().toArray(), slots.exportable().getValues().toArray());
|
||||
SlotList actual = slots.exportable();
|
||||
SlotList expected = new SlotList();
|
||||
expected.add(rawSlot);
|
||||
expected.add(backupSlot);
|
||||
assertArrayEquals(expected.getValues().toArray(), actual.getValues().toArray());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue