Skip to content

Commit

Permalink
Various tidies
Browse files Browse the repository at this point in the history
  • Loading branch information
jorabin committed Aug 24, 2023
1 parent 7cb4488 commit 4a007f3
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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")));
}
}
5 changes: 5 additions & 0 deletions jackson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
<version>6.5.0</version>
</dependency>
<dependency>
<groupId>org.linguafranca.pwdb</groupId>
<artifactId>test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ public class JacksonEntry extends AbstractEntry<JacksonDatabase, JacksonGroup, J
@JacksonXmlProperty(localName = "Times")
protected Times times;

@JacksonXmlProperty(localName = "String") /** Workaround jackson **/
@JacksonXmlProperty(localName = "String") /* Workaround jackson */
@JacksonXmlElementWrapper(useWrapping = false)
protected List<StringProperty> string;

@JacksonXmlProperty(localName = "Binary") /** Workaround jackson **/
@JacksonXmlProperty(localName = "Binary") /* Workaround jackson */
@JacksonXmlElementWrapper(useWrapping = false)
protected List<BinaryProperty> binary;

@JacksonXmlProperty(localName = "AutoType")
protected AutoType autoType;

@JacksonXmlProperty(localName = "History") /** Workaround jackson **/
@JacksonXmlProperty(localName = "History") /* Workaround jackson */
protected JacksonHistory history;

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,9 +53,8 @@
"entry",
"group",
})
@JsonIgnoreProperties(ignoreUnknown = true)
public class JacksonGroup
extends org.linguafranca.pwdb.base.AbstractGroup<JacksonDatabase, JacksonGroup, JacksonEntry, JacksonIcon> {
@JsonIgnoreProperties(ignoreUnknown=true)
public class JacksonGroup extends AbstractGroup<JacksonDatabase, JacksonGroup, JacksonEntry, JacksonIcon> {

@JacksonXmlProperty(localName = "UUID")
@JsonDeserialize(converter = Base64ToUUIDConverter.class)
Expand Down Expand Up @@ -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<JacksonEntry> entries;


@JacksonXmlProperty(localName = "Group") /** Workaround jackson **/
@JacksonXmlProperty(localName = "Group") /* Workaround jackson */
@JacksonXmlElementWrapper(useWrapping = false)
protected List<JacksonGroup> groups;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

public class JacksonHistory {

@JacksonXmlProperty(localName = "Entry") /** Workaround jackson **/
@JacksonXmlProperty(localName = "Entry") /* Workaround jackson */
@JacksonXmlElementWrapper(useWrapping = false)
private List<JacksonEntry> entry;

public JacksonHistory() {
entry = new ArrayList<JacksonEntry>();
entry = new ArrayList<>();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;

public class ValueDeserialized extends StdDeserializer<EntryClasses.StringProperty.Value> {
public class ValueDeserializer extends StdDeserializer<EntryClasses.StringProperty.Value> {

private StreamEncryptor encryptor;

public ValueDeserialized() {
super(ValueDeserialized.class);
public ValueDeserializer() {
super(ValueDeserializer.class);
}

public ValueDeserialized(Class<EntryClasses.StringProperty.Value> v) {
public ValueDeserializer(Class<EntryClasses.StringProperty.Value> v) {
super(v);
}

public ValueDeserialized(StreamEncryptor encryptor) {
super(ValueDeserialized.class);
public ValueDeserializer(StreamEncryptor encryptor) {
super(ValueDeserializer.class);
this.encryptor = encryptor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<JacksonEntry> list;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getToEncrypt() {
Expand Down

0 comments on commit 4a007f3

Please sign in to comment.