From fb419085b1fb30defb9e5d224e7339268c04146c Mon Sep 17 00:00:00 2001 From: Martin Paljak Date: Sun, 17 Nov 2024 15:41:29 +0200 Subject: [PATCH] Remove known deprecations --- .../main/java/pro/javacard/fido2/common/COSEPublicKey.java | 4 +--- .../java/pro/javacard/fido2/common/CTAP2ProtocolHelpers.java | 1 + .../main/java/pro/javacard/fido2/common/U2FAuthenticate.java | 1 - .../src/main/java/pro/javacard/fido2/common/U2FRegister.java | 3 +-- .../java/pro/javacard/fido2/transports/USBTransport.java | 5 +++-- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/pro/javacard/fido2/common/COSEPublicKey.java b/common/src/main/java/pro/javacard/fido2/common/COSEPublicKey.java index 89fe418..d960846 100644 --- a/common/src/main/java/pro/javacard/fido2/common/COSEPublicKey.java +++ b/common/src/main/java/pro/javacard/fido2/common/COSEPublicKey.java @@ -25,12 +25,10 @@ public class COSEPublicKey { factory.setCodec(CTAP2ProtocolHelpers.cborMapper); } - @SuppressWarnings("deprecation") static COSEPublicKey fromBytes(byte[] cbor) throws IOException { CBORParser parser = factory.createParser(cbor); ObjectNode parsed = parser.readValueAsTree(); - // FIXME: getCurrentLocation() is deprecated - byte[] encoded = Arrays.copyOf(cbor, (int) parser.getCurrentLocation().getByteOffset() - 1); + byte[] encoded = Arrays.copyOf(cbor, (int) parser.currentLocation().getByteOffset() - 1); final PublicKey pubkey; switch (parsed.get("3").asInt()) { diff --git a/common/src/main/java/pro/javacard/fido2/common/CTAP2ProtocolHelpers.java b/common/src/main/java/pro/javacard/fido2/common/CTAP2ProtocolHelpers.java index daf445c..c8dc878 100644 --- a/common/src/main/java/pro/javacard/fido2/common/CTAP2ProtocolHelpers.java +++ b/common/src/main/java/pro/javacard/fido2/common/CTAP2ProtocolHelpers.java @@ -41,6 +41,7 @@ public static void setProtocolDebug(OutputStream debug) { } static { + // FIXME: QUOTE_FIELD_NAMES in com.fasterxml.jackson.core.JsonGenerator.Feature has been deprecated mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, false); // We have numerics in visual } diff --git a/common/src/main/java/pro/javacard/fido2/common/U2FAuthenticate.java b/common/src/main/java/pro/javacard/fido2/common/U2FAuthenticate.java index ba629b0..25aa892 100644 --- a/common/src/main/java/pro/javacard/fido2/common/U2FAuthenticate.java +++ b/common/src/main/java/pro/javacard/fido2/common/U2FAuthenticate.java @@ -51,7 +51,6 @@ public static byte[] toAuthenticateCommand(GetAssertionCommand command) throws I return u2fcmd; } - @SuppressWarnings("deprecation") public static byte[] toCBOR(GetAssertionCommand command, byte[] response) throws IOException { byte[] appId = PINProtocols.sha256(command.origin.getBytes(StandardCharsets.UTF_8)); diff --git a/common/src/main/java/pro/javacard/fido2/common/U2FRegister.java b/common/src/main/java/pro/javacard/fido2/common/U2FRegister.java index a64515c..d061df8 100644 --- a/common/src/main/java/pro/javacard/fido2/common/U2FRegister.java +++ b/common/src/main/java/pro/javacard/fido2/common/U2FRegister.java @@ -30,7 +30,6 @@ void verifyU2FRegistration(MakeCredentialCommand command) throws IllegalArgument throw new IllegalArgumentException("U2F supports only P256"); } - @SuppressWarnings("deprecation") public static byte[] toCBOR(MakeCredentialCommand command, byte[] response) throws IOException { int offset = 0; @@ -95,7 +94,7 @@ public static byte[] toCBOR(MakeCredentialCommand command, byte[] response) thro generator.writeFieldName("sig"); generator.writeBinary(signature); generator.writeFieldName("x5c"); - generator.writeStartArray(1); + generator.writeStartArray(null, 1); generator.writeBinary(cert); generator.writeEndArray(); generator.writeEndObject(); // sig+x509 dict diff --git a/transports/src/main/java/pro/javacard/fido2/transports/USBTransport.java b/transports/src/main/java/pro/javacard/fido2/transports/USBTransport.java index bca39a7..588cb45 100644 --- a/transports/src/main/java/pro/javacard/fido2/transports/USBTransport.java +++ b/transports/src/main/java/pro/javacard/fido2/transports/USBTransport.java @@ -103,11 +103,12 @@ public static USBTransport getInstance(HidDevice dev, CallbackHandler cb) { return new USBTransport(dev, cb); } - @SuppressWarnings("deprecation") private USBTransport(HidDevice dev, CallbackHandler cb) { device = dev; callbackHandler = cb; - if (!device.isOpen()) device.open(); //FIXME: isOpen is deprecated + if (device.isClosed()) { + device.open(); + } try { channelID = openChannel(device); } catch (IOException e) {