Skip to content

Commit

Permalink
Modification of MysticCryptEntryModelBean for adapting with keepass f…
Browse files Browse the repository at this point in the history
…ormat
  • Loading branch information
astrapi69 committed Aug 24, 2023
1 parent 648dafe commit 07c9967
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
package io.github.astrapi69.mystic.crypt.panel.dbtree;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import io.github.astrapi69.collection.list.ListExtensions;
import io.github.astrapi69.collection.pair.KeySetPair;
import io.github.astrapi69.collection.set.SetExtensions;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -64,4 +68,36 @@ public class MysticCryptEntryModelBean

@Builder.Default
List<KeyValuePair<String, String>> properties = new ArrayList<>();

public String getProperty(String name) {
String property = KeyValuePair.toMap(properties).get(name);
return property;
}

public void setProperty(String name, String value){
properties.add(KeyValuePair.<String, String>builder().key(name).value(value).build());
}

public boolean removeProperty(String name) {
String value = getProperty(name);
KeyValuePair<String, String> remove = KeyValuePair.<String, String>builder().key(name).value(value).build();
int indexToRemove = properties.indexOf(remove);
if(-1 < indexToRemove) {
properties.remove(indexToRemove);
return true;
}
return false;
}

public List<String> getPropertyNames() {
return ListExtensions.toList(KeyValuePair.toMap(properties).keySet());
}

public KeySetPair<String, LocalDateTime> getKeySetPair(){
return null;
}

public String getPath(){
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public void testKeePass2() throws Exception {

}

public static List<Group> getAllGroups(Group someA) {
public static List<Group> getAllGroups(Group group) {
List<Group> returnList = new ArrayList<>();
returnList.addAll(someA.getGroups());
returnList.addAll(group.getGroups());

for(Object otherA: someA.getGroups()) {
returnList.addAll(getAllGroups((Group)otherA));
for(Object currentGroup: group.getGroups()) {
returnList.addAll(getAllGroups((Group)currentGroup));
}

return returnList;
Expand Down

0 comments on commit 07c9967

Please sign in to comment.