Skip to content

Commit ac9f519

Browse files
committed
Fix deprecation warnings
1 parent f88ab32 commit ac9f519

File tree

14 files changed

+86
-52
lines changed

14 files changed

+86
-52
lines changed

webauthn-server-attestation/src/main/java/com/yubico/fido/metadata/FidoMetadataDownloaderException.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package com.yubico.fido.metadata;
22

3+
import lombok.Getter;
34
import lombok.NonNull;
4-
import lombok.Value;
55

6-
@Value
76
public class FidoMetadataDownloaderException extends Exception {
87

98
public enum Reason {
@@ -16,19 +15,20 @@ public enum Reason {
1615
}
1716
}
1817

19-
@NonNull
18+
@NonNull @Getter
2019
/** The reason why this exception was thrown. */
2120
private final Reason reason;
2221

2322
/** A {@link Throwable} that caused this exception. May be null. */
24-
private final Throwable cause;
23+
@Getter private final Throwable cause;
2524

26-
FidoMetadataDownloaderException(Reason reason, Throwable cause) {
25+
FidoMetadataDownloaderException(@NonNull Reason reason, Throwable cause) {
26+
super(cause);
2727
this.reason = reason;
2828
this.cause = cause;
2929
}
3030

31-
FidoMetadataDownloaderException(Reason reason) {
31+
FidoMetadataDownloaderException(@NonNull Reason reason) {
3232
this(reason, null);
3333
}
3434

webauthn-server-attestation/src/test/scala/com/yubico/fido/metadata/FidoMetadataDownloaderSpec.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class FidoMetadataDownloaderSpec
334334
)
335335

336336
blob should not be null
337-
blob.getHeader.getX5c.get.asScala.last.getIssuerDN.getName should equal(
337+
blob.getHeader.getX5c.get.asScala.last.getIssuerX500Principal.getName should equal(
338338
trustRootDistinguishedName
339339
)
340340
writtenCache should equal(
@@ -404,7 +404,7 @@ class FidoMetadataDownloaderSpec
404404
.build()
405405
)
406406
blob should not be null
407-
blob.getHeader.getX5c.get.asScala.last.getIssuerDN.getName should equal(
407+
blob.getHeader.getX5c.get.asScala.last.getIssuerX500Principal.getName should equal(
408408
newTrustRootDistinguishedName
409409
)
410410
writtenCache should equal(
@@ -467,7 +467,7 @@ class FidoMetadataDownloaderSpec
467467
.build()
468468
)
469469
blob should not be null
470-
blob.getHeader.getX5c.get.asScala.last.getIssuerDN.getName should equal(
470+
blob.getHeader.getX5c.get.asScala.last.getIssuerX500Principal.getName should equal(
471471
trustRootDistinguishedName
472472
)
473473
cacheFile.lastModified should equal(initialModTime)
@@ -527,7 +527,7 @@ class FidoMetadataDownloaderSpec
527527
.build()
528528
)
529529
blob should not be null
530-
blob.getHeader.getX5c.get.asScala.last.getIssuerDN.getName should equal(
530+
blob.getHeader.getX5c.get.asScala.last.getIssuerX500Principal.getName should equal(
531531
trustRootDistinguishedName
532532
)
533533
cacheFile.exists() should be(true)
@@ -600,7 +600,7 @@ class FidoMetadataDownloaderSpec
600600
.build()
601601
)
602602
blob should not be null
603-
blob.getHeader.getX5c.get.asScala.last.getIssuerDN.getName should equal(
603+
blob.getHeader.getX5c.get.asScala.last.getIssuerX500Principal.getName should equal(
604604
newTrustRootDistinguishedName
605605
)
606606
cacheFile.exists() should be(true)
@@ -656,7 +656,7 @@ class FidoMetadataDownloaderSpec
656656
.build()
657657
)
658658
blob should not be null
659-
blob.getHeader.getX5c.get.asScala.last.getIssuerDN.getName should equal(
659+
blob.getHeader.getX5c.get.asScala.last.getIssuerX500Principal.getName should equal(
660660
trustRootDistinguishedName
661661
)
662662
writtenCache should equal(None)

webauthn-server-core/src/main/java/com/yubico/webauthn/PackedAttestationStatementVerifier.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private boolean verifySelfAttestationSignature(
106106
throw new RuntimeException(e);
107107
}
108108

109-
final Long keyAlgId =
109+
final long keyAlgId =
110110
CBORObject.DecodeFromBytes(
111111
attestationObject
112112
.getAuthenticatorData()
@@ -115,15 +115,16 @@ private boolean verifySelfAttestationSignature(
115115
.getCredentialPublicKey()
116116
.getBytes())
117117
.get(CBORObject.FromObject(3))
118-
.AsInt64();
118+
.AsNumber()
119+
.ToInt64IfExact();
119120
final COSEAlgorithmIdentifier keyAlg =
120121
COSEAlgorithmIdentifier.fromId(keyAlgId)
121122
.orElseThrow(
122123
() ->
123124
new IllegalArgumentException(
124125
"Unsupported COSE algorithm identifier: " + keyAlgId));
125126

126-
final Long sigAlgId = attestationObject.getAttestationStatement().get("alg").asLong();
127+
final long sigAlgId = attestationObject.getAttestationStatement().get("alg").asLong();
127128
final COSEAlgorithmIdentifier sigAlg =
128129
COSEAlgorithmIdentifier.fromId(sigAlgId)
129130
.orElseThrow(

webauthn-server-core/src/main/java/com/yubico/webauthn/TpmAttestationStatementVerifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static final class Attributes {
8282
| (1 << 3) // 3 Reserved
8383
| (0x3 << 8) // 9:8 Reserved
8484
| (0xF << 12) // 15:12 Reserved
85-
| ((0xFFFFFFFF << 19) & ((1 << 32) - 1)) // 31:19 Reserved
85+
| ((0xFFFFFFFF << 19) & ((1 << 31) | ((1 << 31) - 1))) // 31:19 Reserved
8686
;
8787
}
8888

webauthn-server-core/src/main/java/com/yubico/webauthn/data/Extensions.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,10 @@ static Optional<List<UvmEntry>> parseAuthenticatorExtensionOutput(CBORObject cbo
428428
uvmEntry ->
429429
new UvmEntry(
430430
UserVerificationMethod.fromValue(uvmEntry.get(0).AsInt32Value()),
431-
KeyProtectionType.fromValue(uvmEntry.get(1).AsInt16()),
432-
MatcherProtectionType.fromValue(uvmEntry.get(2).AsInt16())))
431+
KeyProtectionType.fromValue(
432+
uvmEntry.get(1).AsNumber().ToInt16IfExact()),
433+
MatcherProtectionType.fromValue(
434+
uvmEntry.get(2).AsNumber().ToInt16IfExact())))
433435
.collect(Collectors.toList()));
434436
} else {
435437
return Optional.empty();
@@ -470,7 +472,7 @@ private static boolean validateAuthenticatorExtensionOutput(CBORObject extension
470472
}
471473

472474
for (CBORObject i : entry.getValues()) {
473-
if (!i.isIntegral()) {
475+
if (!(i.isNumber() && i.AsNumber().IsInteger())) {
474476
log.debug("Invalid type for uvmEntry element: expected integer, was: {}", i.getType());
475477
return false;
476478
}

webauthn-server-core/src/test/scala/com/yubico/webauthn/RelyingPartyAssertionSpec.scala

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,15 @@ class RelyingPartyAssertionSpec
418418
)
419419

420420
result.isSuccess should be(true)
421-
result.getUserHandle should equal(registrationTestData.userId.getId)
422-
result.getCredentialId should equal(registrationTestData.response.getId)
423-
result.getCredentialId should equal(testData.response.getId)
421+
result.getCredential.getUserHandle should equal(
422+
registrationTestData.userId.getId
423+
)
424+
result.getCredential.getCredentialId should equal(
425+
registrationTestData.response.getId
426+
)
427+
result.getCredential.getCredentialId should equal(
428+
testData.response.getId
429+
)
424430
credRepo.lookupCount should equal(1)
425431
}
426432

@@ -1906,8 +1912,12 @@ class RelyingPartyAssertionSpec
19061912
Try(steps.run) shouldBe a[Success[_]]
19071913

19081914
step.result.get.isSuccess should be(true)
1909-
step.result.get.getCredentialId should equal(Defaults.credentialId)
1910-
step.result.get.getUserHandle should equal(Defaults.userHandle)
1915+
step.result.get.getCredential.getCredentialId should equal(
1916+
Defaults.credentialId
1917+
)
1918+
step.result.get.getCredential.getUserHandle should equal(
1919+
Defaults.userHandle
1920+
)
19111921
step.result.get.getCredential.getCredentialId should equal(
19121922
step.result.get.getCredentialId
19131923
)
@@ -2001,8 +2011,8 @@ class RelyingPartyAssertionSpec
20012011
)
20022012

20032013
result.isSuccess should be(true)
2004-
result.getUserHandle should equal(testData.userId.getId)
2005-
result.getCredentialId should equal(credId)
2014+
result.getCredential.getUserHandle should equal(testData.userId.getId)
2015+
result.getCredential.getCredentialId should equal(credId)
20062016
}
20072017

20082018
it("an Ed25519 key.") {
@@ -2133,8 +2143,10 @@ class RelyingPartyAssertionSpec
21332143
)
21342144

21352145
result.isSuccess should be(true)
2136-
result.getUserHandle should equal(registrationRequest.getUser.getId)
2137-
result.getCredentialId should equal(credId)
2146+
result.getCredential.getUserHandle should equal(
2147+
registrationRequest.getUser.getId
2148+
)
2149+
result.getCredential.getCredentialId should equal(credId)
21382150
}
21392151

21402152
it("a generated Ed25519 key.") {
@@ -2172,9 +2184,15 @@ class RelyingPartyAssertionSpec
21722184
)
21732185

21742186
result.isSuccess should be(true)
2175-
result.getUserHandle should equal(registrationTestData.userId.getId)
2176-
result.getCredentialId should equal(registrationTestData.response.getId)
2177-
result.getCredentialId should equal(testData.response.getId)
2187+
result.getCredential.getUserHandle should equal(
2188+
registrationTestData.userId.getId
2189+
)
2190+
result.getCredential.getCredentialId should equal(
2191+
registrationTestData.response.getId
2192+
)
2193+
result.getCredential.getCredentialId should equal(
2194+
testData.response.getId
2195+
)
21782196
}
21792197

21802198
describe("an RS1 key") {
@@ -2215,11 +2233,15 @@ class RelyingPartyAssertionSpec
22152233
)
22162234

22172235
result.isSuccess should be(true)
2218-
result.getUserHandle should equal(registrationTestData.userId.getId)
2219-
result.getCredentialId should equal(
2236+
result.getCredential.getUserHandle should equal(
2237+
registrationTestData.userId.getId
2238+
)
2239+
result.getCredential.getCredentialId should equal(
22202240
registrationTestData.response.getId
22212241
)
2222-
result.getCredentialId should equal(testData.response.getId)
2242+
result.getCredential.getCredentialId should equal(
2243+
testData.response.getId
2244+
)
22232245
}
22242246

22252247
it("with basic attestation.") {
@@ -2275,8 +2297,10 @@ class RelyingPartyAssertionSpec
22752297
)
22762298

22772299
result.isSuccess should be(true)
2278-
result.getUserHandle should equal(testData.userId.getId)
2279-
result.getCredentialId should equal(testData.response.getId)
2300+
result.getCredential.getUserHandle should equal(testData.userId.getId)
2301+
result.getCredential.getCredentialId should equal(
2302+
testData.response.getId
2303+
)
22802304
}
22812305
}
22822306
}

webauthn-server-core/src/test/scala/com/yubico/webauthn/RelyingPartyCeremoniesSpec.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ class RelyingPartyCeremoniesSpec
110110
)
111111

112112
assertionResult.isSuccess should be(true)
113-
assertionResult.getCredentialId should equal(testData.assertion.get.id)
114-
assertionResult.getUserHandle should equal(testData.user.getId)
113+
assertionResult.getCredential.getCredentialId should equal(
114+
testData.assertion.get.id
115+
)
116+
assertionResult.getCredential.getUserHandle should equal(
117+
testData.user.getId
118+
)
115119
assertionResult.getUsername should equal(testData.user.getName)
116120
assertionResult.getSignatureCount should be >= testData.attestation.authenticatorData.getSignatureCounter
117121
assertionResult.isSignatureCounterValid should be(true)

webauthn-server-core/src/test/scala/com/yubico/webauthn/RelyingPartyRegistrationSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ class RelyingPartyRegistrationSpec
17141714
).getAuthenticatorData.getAttestedCredentialData.get.getCredentialPublicKey.getBytes
17151715
)
17161716
.get(CBORObject.FromObject(3))
1717-
.AsInt64 should equal(-7)
1717+
.AsInt64Value should equal(-7)
17181718
new AttestationObject(
17191719
testDataBase.attestationObject
17201720
).getAttestationStatement.get("alg").longValue should equal(
@@ -1791,7 +1791,7 @@ class RelyingPartyRegistrationSpec
17911791
attObj.getAuthenticatorData.getAttestedCredentialData.get.getCredentialPublicKey.getBytes
17921792
)
17931793
.get(CBORObject.FromObject(3))
1794-
.AsInt64 should equal(-257)
1794+
.AsInt64Value should equal(-257)
17951795
attObj.getAttestationStatement
17961796
.get("alg")
17971797
.longValue should equal(-65535)

webauthn-server-core/src/test/scala/com/yubico/webauthn/data/JsonIoSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class JsonIoSpec
372372
val encoded = json.writeValueAsString(tree)
373373
println(authenticatorAttachment)
374374
val decoded = json.readValue(encoded, tpe)
375-
decoded.getAuthenticatorAttachment.asScala should be(None)
375+
decoded.getAuthenticatorAttachment.toScala should be(None)
376376
}
377377

378378
forAll(
@@ -388,7 +388,7 @@ class JsonIoSpec
388388
println(authenticatorAttachment)
389389
val decoded = json.readValue(encoded, tpe)
390390

391-
decoded.getAuthenticatorAttachment.asScala should equal(
391+
decoded.getAuthenticatorAttachment.toScala should equal(
392392
Some(authenticatorAttachment)
393393
)
394394
}
@@ -402,7 +402,7 @@ class JsonIoSpec
402402
val encoded = json.writeValueAsString(tree)
403403
val decoded = json.readValue(encoded, tpe)
404404

405-
decoded.getAuthenticatorAttachment.asScala should be(None)
405+
decoded.getAuthenticatorAttachment.toScala should be(None)
406406
}
407407
}
408408

webauthn-server-core/src/test/scala/com/yubico/webauthn/extension/uvm/Generators.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package com.yubico.webauthn.extension.uvm
22

33
import org.scalacheck.Gen
44

5+
import scala.collection.immutable.ArraySeq
6+
57
object Generators {
68

79
def userVerificationMethod: Gen[UserVerificationMethod] =
8-
Gen.oneOf(UserVerificationMethod.values)
10+
Gen.oneOf(ArraySeq.unsafeWrapArray(UserVerificationMethod.values))
911

1012
def keyProtectionType: Gen[KeyProtectionType] =
11-
Gen.oneOf(KeyProtectionType.values)
13+
Gen.oneOf(ArraySeq.unsafeWrapArray(KeyProtectionType.values))
1214

1315
def matcherProtectionType: Gen[MatcherProtectionType] =
14-
Gen.oneOf(MatcherProtectionType.values)
16+
Gen.oneOf(ArraySeq.unsafeWrapArray(MatcherProtectionType.values))
1517

1618
}

0 commit comments

Comments
 (0)