Allow marshalling of private keys
Check if file exists when unmarshalling private keys
@@ -64,6 +64,10 @@ public class PrivateKeyAdapter extends XmlAdapter<PrivateKeyMutable, PrivateKey>
private PrivateKey handleJsonFile(final PrivateKeyMutable input) throws IOException {
+ if (!Files.exists(input.getPath())) {
+ return new PrivateKey(null, null, null, null, null, null, null, input.getPath());
+ }
+
final String json = new String(Files.readAllBytes(input.getPath()));
final JsonObject topLevelObject = Json.createReader(new StringReader(json)).readObject();
@@ -96,6 +100,6 @@ public class PrivateKeyAdapter extends XmlAdapter<PrivateKeyMutable, PrivateKey>
@Override
public PrivateKeyMutable marshal(final PrivateKey input) {
- throw new UnsupportedOperationException();
+ return new PrivateKeyMutable(input.getPath(), null, input.getValue(), input.getPassword(), input);
}
}
