diff --git a/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/PresentationService.java b/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/PresentationService.java index 57e7d41f..e5c1b169 100644 --- a/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/PresentationService.java +++ b/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/PresentationService.java @@ -274,12 +274,7 @@ private boolean validateCredential(VerifiableCredential credential) { final DidResolver resolver = didDocumentResolverService.getCompositeDidResolver(); final LinkedDataProofValidation linkedDataProofValidation = LinkedDataProofValidation.newInstance(resolver); final boolean isValid = linkedDataProofValidation.verify(credential); - - if (isValid) { - log.debug("Credential validation result: (valid: {}, credential-id: {})", isValid, credential.getId()); - } else { - log.info("Credential validation result: (valid: {}, credential-id: {})", isValid, credential.getId()); - } + log.info("Credential validation result: (valid: {}, credential-id: {})", isValid, credential.getId()); return isValid; } diff --git a/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java b/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java index e3a835b3..76237e05 100644 --- a/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java +++ b/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java @@ -363,11 +363,7 @@ private void validateCreateWallet(CreateWalletRequest request, String callerBpn) } - @RequiredArgsConstructor - private class WalletKeyInfo { - private final String keyId; - private final KeyPair keyPair; - private final SupportedAlgorithms algorithm; - private final VerificationMethod verificationMethod; + private record WalletKeyInfo(String keyId, KeyPair keyPair, SupportedAlgorithms algorithm, + VerificationMethod verificationMethod) { } } diff --git a/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/signing/LocalSigningServiceImpl.java b/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/signing/LocalSigningServiceImpl.java index d3f6ae05..5317ec82 100644 --- a/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/signing/LocalSigningServiceImpl.java +++ b/miw/src/main/java/org/eclipse/tractusx/managedidentitywallets/signing/LocalSigningServiceImpl.java @@ -278,7 +278,7 @@ private SignedJWT generateJwtPresentation(PresentationCreationConfig config, byt private VerifiablePresentation generateJsonLdPresentation(PresentationCreationConfig config, byte[] privateKeyBytes) throws UnsupportedSignatureTypeException, InvalidPrivateKeyFormatException, SignatureGenerateFailedException, TransformJsonLdException { VerifiablePresentationBuilder verifiablePresentationBuilder = - new VerifiablePresentationBuilder().id(URI.create(config.getVpIssuerDid() + "#" + UUID.randomUUID().toString())) + new VerifiablePresentationBuilder().id(URI.create(config.getVpIssuerDid() + "#" + UUID.randomUUID())) .type(List.of(VerifiablePresentationType.VERIFIABLE_PRESENTATION)) .verifiableCredentials(config.getVerifiableCredentials()); @@ -339,7 +339,7 @@ private SignedJWT buildED25519(PresentationCreationConfig config, byte[] private SerializedJwtPresentationFactory presentationFactory = new SerializedJwtPresentationFactoryImpl( new SignedJwtFactory(new OctetKeyPairFactory()), new JsonLdSerializerImpl(), config.getVpIssuerDid()); - X25519PrivateKey privateKey = null; + X25519PrivateKey privateKey; try { privateKey = new X25519PrivateKey(privateKeyBytes); } catch (InvalidPrivateKeyFormatException e) { diff --git a/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/AuthenticationUtils.java b/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/AuthenticationUtils.java index 6f2a31ce..6a11009a 100644 --- a/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/AuthenticationUtils.java +++ b/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/AuthenticationUtils.java @@ -157,10 +157,15 @@ private static String getJwtToken(String username) { .clientId(StringPool.CLIENT_ID) .clientSecret(StringPool.CLIENT_SECRET) .username(username) - .password(StringPool.USER_PASSWORD) + .password(getUserPassword()) .build(); String access_token = keycloakAdminClient.tokenManager().getAccessToken().getToken(); return StringPool.BEARER_SPACE + access_token; } + + @NotNull + private static String getUserPassword() { + return "s3cr3t"; + } } diff --git a/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/controllers/RevocationApiController.java b/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/controllers/RevocationApiController.java index 580ff2af..8c1ed619 100644 --- a/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/controllers/RevocationApiController.java +++ b/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/controllers/RevocationApiController.java @@ -131,7 +131,7 @@ public ResponseEntity> verifyRevocation( /** * The function `getCredentialsByIssuerId` retrieves a list of credentials by their issuer ID. * - * @param issuerId The `issuerId` parameter is a string that represents the identifier of the + * @param issuerBPN The `issuerBPN` parameter is a string that represents the BPn of the * issuer. * @return The method is returning a ResponseEntity object that wraps a VerifiableCredential * object. diff --git a/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/validation/VerifiableCredentialValidator.java b/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/validation/VerifiableCredentialValidator.java index 66372d57..00947e53 100644 --- a/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/validation/VerifiableCredentialValidator.java +++ b/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/validation/VerifiableCredentialValidator.java @@ -48,15 +48,9 @@ public boolean isValid(VerifiableCredential credential, ConstraintValidatorConte // Assuming 'id' within 'credentialSubject' is the field to be validated as a URI @NonNull List credentialSubject = credential.getCredentialSubject(); - if (credentialSubject != null) { - if (!validateCredentialSubject(credentialSubject, context)) { - return false; - } - } + return validateCredentialSubject(credentialSubject, context); // Additional validation checks can be added here, e.g., checking the proof object - - return true; } private boolean validateCredentialSubject( diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/security/CustomAuthenticationConverterTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/security/CustomAuthenticationConverterTest.java index 29de8663..a918b0fe 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/security/CustomAuthenticationConverterTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/security/CustomAuthenticationConverterTest.java @@ -36,13 +36,13 @@ class CustomAuthenticationConverterTest { - private static String VALID = + private static final String VALID = "eyJhbGciOiJSUzI1NiIsImFscGhhIjoiZzB1ZjNycjlycnN2cHlhcTVuamg4In0.eyJpc3MiOiJEaW5vQ2hpZXNhLmdpdGh1Yi5pbyIsInN1YiI6Im1heGluZSIsImF1ZCI6ImlkcmlzIiwiaWF0IjoxNzAyNjUwMTc2LCJleHAiOjE3MDI2NTA3NzYsInJlc291cmNlX2FjY2VzcyI6eyJyZXNvdXJjZUlkIjp7InJvbGVzIjpbImRlaV9tdWRhIl19fX0.wTv9GBX3AuRO8UIsAuu2YJU77ai-wchDyxRn-_yX9PeHt23vCmp_JAbkkdMdyLAWWOKncjgNeG-4lB9RCBsjmbdb1imujUrAocp3VZQqNg6OVaNV58kdsIpNNF9S8XlFI4hr1BANrw2rWJDkTRu1id-Fu-BVE1BF7ySCKHS_NaY3e7yXQM-jtU63z5FBpPvfMF-La3blPle93rgut7V3LlG-tNOp93TgFzGrQQXuJUsew34T0u4OlQa3TjQuMdZMTy0SVSLSpIzAqDsAkHv34W6SdY1p6FVQ14TfawRLkrI2QY-YM_dCFAEE7KqqnUrVVyw6XG1ydeFDuX8SJuQX7g"; - private static String MISSING_RESOURCE_ID = + private static final String MISSING_RESOURCE_ID = "{\n" + " \"resource_access\": {\n" + " }\n" + "}"; - private static String MISSING_ROLES = + private static final String MISSING_ROLES = "{\n" + " \"resource_access\": {\n" + " \"resourceId\": {\n" diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/utils/BitSetManagerTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/utils/BitSetManagerTest.java index 6e41da99..67f9c813 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/utils/BitSetManagerTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/utils/BitSetManagerTest.java @@ -24,9 +24,9 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.BitSet; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -104,6 +104,6 @@ void encodeToStringAndDecodeFromString_AreReversible() { byte[] decodedData = BitSetManager.decodeFromString(encoded); assertNotNull(decodedData); - assertTrue(Arrays.equals(originalData, decodedData)); + assertArrayEquals(originalData, decodedData); } } diff --git a/wallet-commons/src/main/java/org/eclipse/tractusx/managedidentitywallets/commons/constant/StringPool.java b/wallet-commons/src/main/java/org/eclipse/tractusx/managedidentitywallets/commons/constant/StringPool.java index d6695fdd..5ee3fd5e 100644 --- a/wallet-commons/src/main/java/org/eclipse/tractusx/managedidentitywallets/commons/constant/StringPool.java +++ b/wallet-commons/src/main/java/org/eclipse/tractusx/managedidentitywallets/commons/constant/StringPool.java @@ -62,9 +62,6 @@ public class StringPool { public static final String CLIENT_SECRET = "miw_private_client_secret"; public static final String REALM = "miw_test"; - - public static final String USER_PASSWORD = "s3cr3t"; - public static final String VALID_USER_NAME = "valid_user"; public static final String INVALID_USER_NAME = "invalid_user"; diff --git a/wallet-commons/src/main/java/org/eclipse/tractusx/managedidentitywallets/commons/constant/SupportedAlgorithms.java b/wallet-commons/src/main/java/org/eclipse/tractusx/managedidentitywallets/commons/constant/SupportedAlgorithms.java index 7787937b..b9750cfe 100644 --- a/wallet-commons/src/main/java/org/eclipse/tractusx/managedidentitywallets/commons/constant/SupportedAlgorithms.java +++ b/wallet-commons/src/main/java/org/eclipse/tractusx/managedidentitywallets/commons/constant/SupportedAlgorithms.java @@ -26,7 +26,7 @@ public enum SupportedAlgorithms { ED25519("ED25519"), ES256K("ES256K"); - private String value; + private final String value; SupportedAlgorithms(String value) { this.value = value;