org.linguafranca.pwdb.kdbx.jackson.model.EntryClasses Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of KeePassJava2-jackson Show documentation
Show all versions of KeePassJava2-jackson Show documentation
Contains a Jackson XML implementation for KDBX.
The newest version!
/*
* Copyright 2015 Giuseppe Valente
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.linguafranca.pwdb.kdbx.jackson.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.linguafranca.pwdb.kdbx.jackson.JacksonEntry;
import org.linguafranca.pwdb.kdbx.jackson.converter.BooleanToStringConverter;
import org.linguafranca.pwdb.kdbx.jackson.converter.StringToBooleanConverter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
public abstract class EntryClasses {
public static StringProperty getStringProperty(String name, List string) {
for (StringProperty property : string) {
if (property.key.equals(name)) {
return property;
}
}
return null;
}
public static String getStringContent(StringProperty property) {
return property == null || property.value == null ? null : property.value.text;
}
public static BinaryProperty getBinaryProp(String name, List binary) {
for (BinaryProperty property : binary) {
if (property.key.equals(name)) {
return property;
}
}
return null;
}
public static String getBinaryContent(BinaryProperty property) {
return property == null || property.value == null ? null : property.value.ref;
}
public static class AutoType {
@JacksonXmlProperty(localName = "Enabled")
@JsonDeserialize(converter = StringToBooleanConverter.class)
@JsonSerialize(converter = BooleanToStringConverter.class)
protected Boolean enabled;
@JacksonXmlProperty(localName = "DataTransferObfuscation")
protected int dataTransferObfuscation;
@JacksonXmlProperty(localName = "DefaultSequence")
protected String defaultSequence;
@JacksonXmlProperty(localName = "Association")
protected AutoType.Association association;
public static class Association {
@JacksonXmlProperty(localName = "Window")
protected String window;
@JacksonXmlProperty(localName = "KeystrokeSequence")
protected String keystrokeSequence;
protected List