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

        if (!str.contains("OAEP")) {
            return Optional.empty();
        }

        if (str.contains("OAEPWith")) {
            String digestStr;
            String mgfStr = null;

            final String generalizedStr = str.toLowerCase().trim();
            int algoStartIndex = generalizedStr.indexOf("OAEPWith".toLowerCase()) + 8;
            int paddingSuffix = generalizedStr.indexOf("Padding".toLowerCase());
            if (generalizedStr.contains("and")) {
                int encIndex = generalizedStr.indexOf("and") + 3;
                mgfStr = str.substring(encIndex, paddingSuffix);
                digestStr = str.substring(algoStartIndex, generalizedStr.indexOf("and"));
            } else {
                digestStr = str.substring(algoStartIndex, paddingSuffix);
            }

            // digest
            final JcaMessageDigestMapper jcaMessageDigestMapper = new JcaMessageDigestMapper();
            Optional<MessageDigest> messageDigestOptional =
                    jcaMessageDigestMapper.parse(digestStr, detectionLocation);

            // mgf
            Optional<MaskGenerationFunction> mgfOptional = Optional.empty();
            if (mgfStr != null) {
                final JcaMGFMapper jcaMGFMapper = new JcaMGFMapper();
                mgfOptional = jcaMGFMapper.parse(mgfStr, detectionLocation);
            }

            if (messageDigestOptional.isPresent()) {
                return mgfOptional
                        .map(
                                maskGenerationFunction ->
                                        new OAEP(
                                                messageDigestOptional.get(),
                                                maskGenerationFunction,
                                                detectionLocation))
                        .or(
                                () ->
                                        Optional.of(
                                                new OAEP(
                                                        messageDigestOptional.get(),
                                                        detectionLocation)));
            }
        }

        return Optional.of(new OAEP(detectionLocation));
    }
@Test
    void base() {
        DetectionLocation testDetectionLocation =
                new DetectionLocation("testfile", 1, 1, List.of("test"), () -> "SSL");

        JcaOAEPPaddingMapper jcaOAEPPaddingMapper = new JcaOAEPPaddingMapper();
        Optional<OAEP> oaepPAdding =
                jcaOAEPPaddingMapper.parse("OAEPWithMD5AndMGF1Padding", testDetectionLocation);

        assertThat(oaepPAdding).isPresent();
        assertThat(oaepPAdding.get()).isInstanceOf(OAEP.class);
        OAEP oaep = oaepPAdding.get();

        Optional<MessageDigest> messageDigestOptional = oaep.getDigest();
        assertThat(messageDigestOptional).isPresent();
        assertThat(messageDigestOptional.get()).isInstanceOf(MD5.class);

        Optional<MaskGenerationFunction> maskGenerationFunctionOptional = oaep.getMGF();
        assertThat(maskGenerationFunctionOptional).isPresent();
        assertThat(maskGenerationFunctionOptional.get()).isInstanceOf(MGF1.class);
    }