From 4a007f3e6cd14a2d826e719210c77f7a2de8cf7f Mon Sep 17 00:00:00 2001 From: Jo Rabin Date: Thu, 24 Aug 2023 15:16:41 +0100 Subject: [PATCH] Various tidies --- .../pwdb/kdbx/validation/Issue33Test.java | 7 +++++++ jackson/pom.xml | 5 +++++ .../linguafranca/pwdb/kdbx/jackson/JacksonEntry.java | 6 +++--- .../linguafranca/pwdb/kdbx/jackson/JacksonGroup.java | 11 ++++++----- .../pwdb/kdbx/jackson/JacksonHistory.java | 4 ++-- .../kdbx/jackson/converter/ValueDeserializer.java | 12 ++++++------ .../pwdb/kdbx/jackson/model/EntryClasses.java | 2 +- .../pwdb/kdbx/jaxb/JaxbSerializableDatabase.java | 2 +- 8 files changed, 31 insertions(+), 18 deletions(-) diff --git a/example/src/test/java/org/linguafranca/pwdb/kdbx/validation/Issue33Test.java b/example/src/test/java/org/linguafranca/pwdb/kdbx/validation/Issue33Test.java index 09486d82..322ee10a 100644 --- a/example/src/test/java/org/linguafranca/pwdb/kdbx/validation/Issue33Test.java +++ b/example/src/test/java/org/linguafranca/pwdb/kdbx/validation/Issue33Test.java @@ -10,6 +10,7 @@ import org.linguafranca.pwdb.kdbx.KdbxCreds; import org.linguafranca.pwdb.kdbx.Util; import org.linguafranca.pwdb.kdbx.dom.DomDatabaseWrapper; +import org.linguafranca.pwdb.kdbx.jackson.JacksonDatabase; import org.linguafranca.pwdb.kdbx.jaxb.JaxbDatabase; import org.linguafranca.pwdb.kdbx.simple.SimpleDatabase; @@ -59,4 +60,10 @@ public void testSimpleDatabase() throws IOException { SimpleDatabase database = SimpleDatabase.load(CREDENTIALS, inputStream); database.save(new StreamFormat.None(), new Credentials.None(), Files.newOutputStream(Paths.get(TEST_OUTPUT_DIR, "Issue33Simple.xml"))); } + + @Test + public void testJacksonDatabase() throws IOException { + JacksonDatabase database = JacksonDatabase.load(CREDENTIALS, inputStream); + database.save(new StreamFormat.None(), new Credentials.None(), Files.newOutputStream(Paths.get(TEST_OUTPUT_DIR, "Issue33Jackson.xml"))); + } } diff --git a/jackson/pom.xml b/jackson/pom.xml index 1e63cf51..0f1d8021 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -38,6 +38,11 @@ jackson-dataformat-xml 2.15.0 + + com.fasterxml.woodstox + woodstox-core + 6.5.0 + org.linguafranca.pwdb test diff --git a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonEntry.java b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonEntry.java index c3110e0e..92bee42e 100644 --- a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonEntry.java +++ b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonEntry.java @@ -94,18 +94,18 @@ public class JacksonEntry extends AbstractEntry string; - @JacksonXmlProperty(localName = "Binary") /** Workaround jackson **/ + @JacksonXmlProperty(localName = "Binary") /* Workaround jackson */ @JacksonXmlElementWrapper(useWrapping = false) protected List binary; @JacksonXmlProperty(localName = "AutoType") protected AutoType autoType; - @JacksonXmlProperty(localName = "History") /** Workaround jackson **/ + @JacksonXmlProperty(localName = "History") /* Workaround jackson */ protected JacksonHistory history; @JsonIgnore diff --git a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonGroup.java b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonGroup.java index c7a9dc43..436d66d5 100644 --- a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonGroup.java +++ b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonGroup.java @@ -21,7 +21,9 @@ import java.util.List; import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonAutoDetect; import org.jetbrains.annotations.NotNull; +import org.linguafranca.pwdb.base.AbstractGroup; import org.linguafranca.pwdb.kdbx.jackson.converter.StringToBooleanConverter; import org.linguafranca.pwdb.kdbx.jackson.converter.UUIDToBase64Converter; import org.linguafranca.pwdb.kdbx.jackson.converter.Base64ToUUIDConverter; @@ -51,9 +53,8 @@ "entry", "group", }) -@JsonIgnoreProperties(ignoreUnknown = true) -public class JacksonGroup - extends org.linguafranca.pwdb.base.AbstractGroup { +@JsonIgnoreProperties(ignoreUnknown=true) +public class JacksonGroup extends AbstractGroup { @JacksonXmlProperty(localName = "UUID") @JsonDeserialize(converter = Base64ToUUIDConverter.class) @@ -100,12 +101,12 @@ public class JacksonGroup @JsonSerialize(converter = UUIDToBase64Converter.class) protected UUID lastTopVisibleEntry; - @JacksonXmlProperty(localName = "Entry") /** Workaround jackson **/ + @JacksonXmlProperty(localName = "Entry") /* Workaround jackson */ @JacksonXmlElementWrapper(useWrapping = false) protected List entries; - @JacksonXmlProperty(localName = "Group") /** Workaround jackson **/ + @JacksonXmlProperty(localName = "Group") /* Workaround jackson */ @JacksonXmlElementWrapper(useWrapping = false) protected List groups; diff --git a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonHistory.java b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonHistory.java index 05ba3537..c9ea238c 100644 --- a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonHistory.java +++ b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/JacksonHistory.java @@ -23,12 +23,12 @@ public class JacksonHistory { - @JacksonXmlProperty(localName = "Entry") /** Workaround jackson **/ + @JacksonXmlProperty(localName = "Entry") /* Workaround jackson */ @JacksonXmlElementWrapper(useWrapping = false) private List entry; public JacksonHistory() { - entry = new ArrayList(); + entry = new ArrayList<>(); } /** diff --git a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/converter/ValueDeserializer.java b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/converter/ValueDeserializer.java index e448589e..8f7fda9b 100644 --- a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/converter/ValueDeserializer.java +++ b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/converter/ValueDeserializer.java @@ -29,20 +29,20 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -public class ValueDeserialized extends StdDeserializer { +public class ValueDeserializer extends StdDeserializer { private StreamEncryptor encryptor; - public ValueDeserialized() { - super(ValueDeserialized.class); + public ValueDeserializer() { + super(ValueDeserializer.class); } - public ValueDeserialized(Class v) { + public ValueDeserializer(Class v) { super(v); } - public ValueDeserialized(StreamEncryptor encryptor) { - super(ValueDeserialized.class); + public ValueDeserializer(StreamEncryptor encryptor) { + super(ValueDeserializer.class); this.encryptor = encryptor; } diff --git a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/model/EntryClasses.java b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/model/EntryClasses.java index 553203de..05b9c441 100644 --- a/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/model/EntryClasses.java +++ b/jackson/src/main/java/org/linguafranca/pwdb/kdbx/jackson/model/EntryClasses.java @@ -212,7 +212,7 @@ public void setRef(String ref) { public static class History { - @JacksonXmlProperty(localName = "Entry") /** Workaround jackson **/ + @JacksonXmlProperty(localName = "Entry") /* Workaround jackson */ @JacksonXmlElementWrapper(useWrapping = false) private List list; diff --git a/jaxb/src/main/java/org/linguafranca/pwdb/kdbx/jaxb/JaxbSerializableDatabase.java b/jaxb/src/main/java/org/linguafranca/pwdb/kdbx/jaxb/JaxbSerializableDatabase.java index b9a0f034..188af88b 100644 --- a/jaxb/src/main/java/org/linguafranca/pwdb/kdbx/jaxb/JaxbSerializableDatabase.java +++ b/jaxb/src/main/java/org/linguafranca/pwdb/kdbx/jaxb/JaxbSerializableDatabase.java @@ -186,7 +186,7 @@ public void afterMarshal(Object source) { } /** - * Create a list of names of peroperties that should be encrypted by default + * Create a list of names of properties that should be encrypted by default */ @NotNull private List getToEncrypt() {