{"record":{"id":"0cf56ab73c8c7a75","repo":"jwtk/jjwt","slug":"e-getmessage","errorCode":null,"errorMessage":"${e.getMessage()}","messagePattern":"\\$\\{e\\.getMessage\\(\\)\\}","errorType":"exception","errorClass":"MalformedKeyException","httpStatus":null,"severity":"error","filePath":"impl/src/main/java/io/jsonwebtoken/impl/security/RSAOtherPrimeInfoConverter.java","lineNumber":73,"sourceCode":"        if (!(o instanceof Map)) {\n            String msg = \"RSA JWK 'oth' (Other Prime Info) must contain map elements of name/value pairs. \" +\n                    \"Element type found: \" + o.getClass().getName();\n            throw new MalformedKeyException(msg);\n        }\n        Map<?, ?> m = (Map<?, ?>) o;\n        if (Collections.isEmpty(m)) {\n            throw new MalformedKeyException(\"RSA JWK 'oth' (Other Prime Info) element map cannot be empty.\");\n        }\n\n        // Need a Context instance to satisfy the API contract of the reader.get* methods below.\n        JwkContext<?> ctx = new DefaultJwkContext<>(PARAMS);\n        try {\n            for (Map.Entry<?, ?> entry : m.entrySet()) {\n                String name = String.valueOf(entry.getKey());\n                ctx.put(name, entry.getValue());\n            }\n        } catch (Exception e) {\n            throw new MalformedKeyException(e.getMessage(), e);\n        }\n\n        ParameterReadable reader = new RequiredParameterReader(ctx);\n        BigInteger prime = reader.get(PRIME_FACTOR);\n        BigInteger primeExponent = reader.get(FACTOR_CRT_EXPONENT);\n        BigInteger crtCoefficient = reader.get(FACTOR_CRT_COEFFICIENT);\n\n        return new RSAOtherPrimeInfo(prime, primeExponent, crtCoefficient);\n    }\n}\n","sourceCodeStart":55,"sourceCodeEnd":84,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/impl/src/main/java/io/jsonwebtoken/impl/security/RSAOtherPrimeInfoConverter.java#L55-L84","documentation":"Wraps any exception raised while copying the 'oth' element map entries into a JwkContext, or (via the later required reads in applyFrom) while extracting the required r/t/d BigInteger parameters, rethrowing it as a MalformedKeyException. The message is the underlying exception's message.","triggerScenarios":"Parsing an 'oth' element whose values are not usable as the required PRIME_FACTOR, FACTOR_CRT_EXPONENT, and FACTOR_CRT_COEFFICIENT parameters (e.g. missing r/t/d keys, or non-Base64URL/non-numeric values) during JWK parsing.","commonSituations":"JWKs with renamed or missing r/t/d fields; values encoded in standard Base64 instead of Base64URL; decoding failures on corrupted parameter strings.","solutions":["Inspect the cause exception message; ensure each 'oth' element has r, t, and d as Base64URL-encoded unsigned integers.","Validate the JWK with an external JWK validator before feeding it to jjwt.","Regenerate or re-export the multi-prime RSA key with complete CRT parameters."],"exampleFix":"// before\n{\"r\":\"...\"} // missing t and d\n// after\n{\"r\":\"...\",\"t\":\"...\",\"d\":\"...\"} // all Base64URL-encoded","handlingStrategy":"try-catch","validationCode":"boolean othComplete = othElements.stream().allMatch(m -> m instanceof Map && ((Map<?,?>) m).keySet().containsAll(Arrays.asList(\"r\",\"t\",\"d\")));","typeGuard":null,"tryCatchPattern":"try { /* build JWK from oth */ } catch (MalformedKeyException e) { inspectCause(e); throw new IllegalArgumentException(\"Bad 'oth' parameters: \" + e.getMessage(), e); }","preventionTips":["Ensure r/t/d values are Base64URL-encoded unsigned integers.","Round-trip test JWKs through parse+serialize before storing them."],"tags":["jwk","rsa","malformed-key","parameter-missing"],"backgroundTag":"schema-validation-failed","analyzedSha":"fb71496164c71442d08adec4571d9616ed5e1b8d","analyzedAt":"2026-09-09T00:33:09.982Z","contentChangedAt":"2026-09-09T00:33:09.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}