Skip to content

Commit

Permalink
fix spotbugs warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamVe committed Nov 20, 2024
1 parent 585daf2 commit 5945e5d
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,12 @@ public int getAssertionCount() {
public List<PublicKeyCredentialUserEntity> getUsers() throws UserInformationNotAvailableError {
List<PublicKeyCredentialUserEntity> users = new ArrayList<>();
for (BasicWebAuthnClient.WithExtensionResults<Ctap2Session.AssertionData> assertion : assertions) {
try {
users.add(PublicKeyCredentialUserEntity.fromMap(
Objects.requireNonNull(assertion.data.getUser()),
SerializationType.CBOR
));
} catch (NullPointerException e) {
Map<String, ?> user = assertion.data.getUser();
if (user == null) {
throw new UserInformationNotAvailableError();
}

users.add(PublicKeyCredentialUserEntity.fromMap(user, SerializationType.CBOR));
}
return users;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ public static void testClientCredentialManagement(FidoTestState state) throws Th

Map<PublicKeyCredentialDescriptor, PublicKeyCredentialUserEntity> credentials = credentialManager.getCredentials(TestData.RP_ID);
assertThat(credentials.size(), equalTo(1));
PublicKeyCredentialDescriptor key = credentials.keySet().iterator().next();
PublicKeyCredentialDescriptor key = credentials.entrySet().iterator().next().getKey();
assertThat(Objects.requireNonNull(credentials.get(key))
.getId(), equalTo(TestData.USER_ID));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

public class Ctap2BioEnrollmentTests {

private static final Logger logger = LoggerFactory.getLogger(PivCertificateTests.class);
private static final Logger logger = LoggerFactory.getLogger(Ctap2BioEnrollmentTests.class);

public static void testFingerprintEnrollment(Ctap2Session session, FidoTestState state)
throws Throwable {
Expand Down Expand Up @@ -145,9 +145,9 @@ public static boolean isEnrolled(byte[] templateId, Map<byte[], String> enrollme
}

public static String getName(byte[] templateId, Map<byte[], String> enrollments) {
for (byte[] enrolledTemplateId : enrollments.keySet()) {
if (Arrays.equals(templateId, enrolledTemplateId)) {
return enrollments.get(enrolledTemplateId);
for (Map.Entry<byte[], String> enrollment : enrollments.entrySet()) {
if (Arrays.equals(templateId, enrollment.getKey())) {
return enrollments.get(enrollment.getKey());
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

public class CredBlobExtensionTests {

private final String CRED_BLOB = "credBlob";
private final String GET_CRED_BLOB = "getCredBlob";
private final byte[] CRED_BLOB_DATA = {
private static final String CRED_BLOB = "credBlob";
private static final String GET_CRED_BLOB = "getCredBlob";
private static final byte[] CRED_BLOB_DATA = {
(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
(byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x02,
(byte) 0x03, (byte) 0x03, (byte) 0x03, (byte) 0x03,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

public class CredPropsExtensionTests {

private final String CRED_PROPS = "credProps";
private static final String CRED_PROPS = "credProps";

public static void test(FidoTestState state) throws Throwable {
CredPropsExtensionTests extTest = new CredPropsExtensionTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

public class CredProtectExtensionTests {

private final String CRED_PROTECT = "credProtect";
private final String POLICY = "credentialProtectionPolicy";
private final String POLICY_OPTIONAL = "userVerificationOptional";
private final String POLICY_WITH_LIST = "userVerificationOptionalWithCredentialIDList";
private final String POLICY_REQUIRED = "userVerificationRequired";
private static final String CRED_PROTECT = "credProtect";
private static final String POLICY = "credentialProtectionPolicy";
private static final String POLICY_OPTIONAL = "userVerificationOptional";
private static final String POLICY_WITH_LIST = "userVerificationOptionalWithCredentialIDList";
private static final String POLICY_REQUIRED = "userVerificationRequired";

public static void test(FidoTestState state) throws Throwable {
CredProtectExtensionTests extTest = new CredProtectExtensionTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@

public class HmacSecretExtensionTests {

private final String KEY_HMAC_SECRET = "hmac-secret";
private final String KEY_HMAC_CREATE_SECRET = "hmacCreateSecret";
private final String KEY_HMAC_GET_SECRET = "hmacGetSecret";
private final String KEY_SALT1 = "salt1";
private final String KEY_SALT2 = "salt2";
private final String KEY_OUTPUT1 = "output1";
private final String KEY_OUTPUT2 = "output2";

private final String VALUE_SALT1 = Base64.toUrlSafeString(new byte[]{
private static final String KEY_HMAC_SECRET = "hmac-secret";
private static final String KEY_HMAC_CREATE_SECRET = "hmacCreateSecret";
private static final String KEY_HMAC_GET_SECRET = "hmacGetSecret";
private static final String KEY_SALT1 = "salt1";
private static final String KEY_SALT2 = "salt2";
private static final String KEY_OUTPUT1 = "output1";
private static final String KEY_OUTPUT2 = "output2";

private static final String VALUE_SALT1 = Base64.toUrlSafeString(new byte[]{
0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@

public class LargeBlobExtensionTests {

static final String LARGE_BLOB = "largeBlob";
static final String LARGE_BLOB_KEY = "largeBlobKey";
static final String KEY_SUPPORT = "support";
static final String KEY_SUPPORTED = "supported";
static final String KEY_READ = "read";
static final String KEY_WRITE = "write";
static final String KEY_BLOB = "blob";
static final String KEY_WRITTEN = "written";
static final String ATTR_PREFERRED = "preferred";
static final String ATTR_REQUIRED = "required";
private static final String LARGE_BLOB = "largeBlob";
private static final String LARGE_BLOB_KEY = "largeBlobKey";
private static final String KEY_SUPPORT = "support";
private static final String KEY_SUPPORTED = "supported";
private static final String KEY_READ = "read";
private static final String KEY_WRITE = "write";
private static final String KEY_BLOB = "blob";
private static final String KEY_WRITTEN = "written";
private static final String ATTR_PREFERRED = "preferred";
private static final String ATTR_REQUIRED = "required";

public static void test(FidoTestState state) throws Throwable {
LargeBlobExtensionTests largeBlobExtensionTests = new LargeBlobExtensionTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import javax.annotation.Nullable;

public class MinPinLengthExtensionTests {
private final String MIN_PIN_LENGTH = "minPinLength";
private static final String MIN_PIN_LENGTH = "minPinLength";

public static void test(FidoTestState state) throws Throwable {
MinPinLengthExtensionTests extTest = new MinPinLengthExtensionTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@

public class PrfExtensionTests {

private final String KEY_HMAC_SECRET = "hmac-secret";
private final String PRF_EXT = "prf";
private final String KEY_ENABLED = "enabled";
private final String KEY_EVAL = "eval";
private final String KEY_EVAL_BY_CREDENTIAL = "evalByCredential";
private final String KEY_FIRST = "first";
private final String KEY_SECOND = "second";
private static final String KEY_HMAC_SECRET = "hmac-secret";
private static final String PRF_EXT = "prf";
private static final String KEY_ENABLED = "enabled";
private static final String KEY_EVAL = "eval";
private static final String KEY_EVAL_BY_CREDENTIAL = "evalByCredential";
private static final String KEY_FIRST = "first";
private static final String KEY_SECOND = "second";

public static void test(FidoTestState state) throws Throwable {
PrfExtensionTests extTests = new PrfExtensionTests();
Expand Down

0 comments on commit 5945e5d

Please sign in to comment.