@Nonnull
    @Override
    public Optional<Signature> parse(
            @Nullable String str, @Nonnull DetectionLocation detectionLocation) {
        if (str == null) {
            return Optional.empty();
        }

        final String generalizedStr = str.toLowerCase().trim();
        if (!generalizedStr.contains("with")) {
            return map(str, detectionLocation);
        }

        int hashEndPos = generalizedStr.indexOf("with");
        String digestStr = str.substring(0, hashEndPos);
        JcaMessageDigestMapper jcaMessageDigestMapper = new JcaMessageDigestMapper();
        final Optional<MessageDigest> messageDigestOptional =
                jcaMessageDigestMapper.parse(digestStr, detectionLocation);

        int encryptStartPos = hashEndPos + 4;
        String signatureStr = str.substring(encryptStartPos);
        final String format;
        if (generalizedStr.contains("in") && generalizedStr.contains("format")) {
            int inStartPos = generalizedStr.indexOf("in");
            int inEndPos = inStartPos + 2;
            signatureStr = str.substring(encryptStartPos, inStartPos);
            format = str.substring(inEndPos);
        } else {
            format = null;
        }

        return map(signatureStr, detectionLocation)
                .map(
                        signature -> {
                            messageDigestOptional.ifPresent(signature::put);
                            if (format != null) {
                                signature.put(new OutputFormat(format, detectionLocation));
                            }
                            return signature;
                        });
    }
@Test
    void SHA384withDSA() {
        DetectionLocation testDetectionLocation =
                new DetectionLocation("testfile", 1, 1, List.of("test"), () -> "SSL");

        JcaSignatureMapper jcaSignatureMapper = new JcaSignatureMapper();
        Optional<Signature> signatureOptional =
                jcaSignatureMapper.parse("SHA384withDSA", testDetectionLocation);

        assertThat(signatureOptional).isPresent();
        assertThat(signatureOptional.get()).isInstanceOf(DSA.class);
        assertThat(signatureOptional.get().getFormat()).isEmpty();

        assertThat(signatureOptional.get().getDigest()).isPresent();
        MessageDigest messageDigest = signatureOptional.get().getDigest().get();
        assertThat(messageDigest).isInstanceOf(SHA2.class);
        assertThat(messageDigest.getName()).isEqualTo("SHA384");
        assertThat(messageDigest.getDigestSize()).isPresent();
        assertThat(messageDigest.getDigestSize().get().getValue()).isEqualTo(384);
    }