2
0

Transition to Jackson so we can retain unrecognized properties in the source JSON.

This commit is contained in:
Maarten Billemont
2018-05-14 11:27:49 -04:00
parent f0d523fb35
commit 38a357cb28
12 changed files with 246 additions and 196 deletions

View File

@@ -11,6 +11,7 @@ dependencies {
compile group: 'com.lyndir.lhunath.opal', name: 'opal-crypto', version: '1.6-p11'
compile group: 'com.lambdaworks', name: 'scrypt', version: '1.4.0'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.5'
compile group: 'org.jetbrains', name: 'annotations', version: '13.0'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
}

View File

@@ -0,0 +1,25 @@
//==============================================================================
// This file is part of Master Password.
// Copyright (c) 2011-2017, Maarten Billemont.
//
// Master Password is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Master Password is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You can find a copy of the GNU General Public License in the
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
//==============================================================================
package com.lyndir.masterpassword;
/**
* @author lhunath, 2017-09-21
*/
public class MPKeyUnavailableException extends Exception {
}

View File

@@ -18,6 +18,8 @@
package com.lyndir.masterpassword;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedInteger;
import com.lyndir.lhunath.opal.system.CodeUtils;
@@ -232,11 +234,13 @@ public class MPMasterKey {
return algorithm;
}
@JsonCreator
public static Version fromInt(final int algorithmVersion) {
return values()[algorithmVersion];
}
@JsonValue
public int toInt() {
return ordinal();

View File

@@ -18,6 +18,8 @@
package com.lyndir.masterpassword;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.lyndir.lhunath.opal.system.logging.Logger;
@@ -179,6 +181,7 @@ public enum MPResultType {
return typeFeatures.contains( feature );
}
@JsonValue
public int getType() {
int mask = typeIndex | typeClass.getMask();
for (final MPSiteFeature typeFeature : typeFeatures)
@@ -226,6 +229,7 @@ public enum MPResultType {
*
* @return The type registered with the given type.
*/
@JsonCreator
public static MPResultType forType(final int type) {
for (final MPResultType resultType : values())