{"record":{"id":"f7374c674393a622","repo":"jwtk/jjwt","slug":"rsa-jwk-oth-other-prime-info-must-contain-map","errorCode":null,"errorMessage":"RSA JWK 'oth' (Other Prime Info) must contain map elements of name/value pairs. Element type found: ${o.getClass().getName()}","messagePattern":"RSA JWK 'oth' \\(Other Prime Info\\) must contain map elements of name/value pairs\\. Element type found: (.+?)","errorType":"exception","errorClass":"MalformedKeyException","httpStatus":null,"severity":"error","filePath":"impl/src/main/java/io/jsonwebtoken/impl/security/RSAOtherPrimeInfoConverter.java","lineNumber":58,"sourceCode":"\n    @Override\n    public Object applyTo(RSAOtherPrimeInfo info) {\n        Map<String, Object> m = new LinkedHashMap<>(3);\n        m.put(PRIME_FACTOR.getId(), PRIME_FACTOR.applyTo(info.getPrime()));\n        m.put(FACTOR_CRT_EXPONENT.getId(), FACTOR_CRT_EXPONENT.applyTo(info.getExponent()));\n        m.put(FACTOR_CRT_COEFFICIENT.getId(), FACTOR_CRT_COEFFICIENT.applyTo(info.getCrtCoefficient()));\n        return m;\n    }\n\n    @Override\n    public RSAOtherPrimeInfo applyFrom(Object o) {\n        if (o == null) {\n            throw new MalformedKeyException(\"RSA JWK 'oth' (Other Prime Info) element cannot be null.\");\n        }\n        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);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/impl/src/main/java/io/jsonwebtoken/impl/security/RSAOtherPrimeInfoConverter.java#L40-L76","documentation":"Thrown as MalformedKeyException when converting the RSA JWK 'oth' (Other Prime Info) array during JWK parsing and an individual element is not a Map. Each 'oth' entry must be a JSON object with 'r', 't', and 'd' name/value pairs per RFC 7518. The library throws because a non-object element (string, number, etc.) cannot be interpreted as prime info.","triggerScenarios":"Parsing a JWK string/JSON whose RSA 'oth' array contains a non-object element, e.g. oth: [\"abc\"] or oth: [123], via Jwts.parser key/JWK loading or JwkBuilder input.","commonSituations":"Hand-written or third-party JWKs with malformed multi-prime RSA data; JSON serialization tools flattening nested objects into strings; truncated or corrupted key material copied between systems.","solutions":["Fix the JWK 'oth' array so every element is a JSON object with r/t/d name/value pairs.","Remove the 'oth' member entirely if the key is not a multi-prime RSA key (it is optional for standard two-prime keys).","Regenerate the key with Jwts.SIG.RSxxx.keyPair() or a standard keytool/openssl flow and re-export a valid JWK."],"exampleFix":"// before\n\"oth\": [\"4C9f...\", \"1a2b\"]\n// after\n\"oth\": [ {\"r\":\"4C9f...\",\"t\":\"dHJ1...\",\"d\":\"cHJp...\"} ]","handlingStrategy":"validation","validationCode":"boolean othValid = oth != null && oth.stream().allMatch(e -> e instanceof Map && !((Map<?,?>) e).isEmpty());","typeGuard":"boolean isOthElement(Object o) { return o instanceof Map && !((Map<?,?>) o).isEmpty(); }","tryCatchPattern":"try { /* parse JWK */ } catch (MalformedKeyException e) { log.error(\"Invalid 'oth' element: {}\", e.getMessage()); throw new IllegalArgumentException(\"JWK 'oth' must be array of objects with r/t/d\", e); }","preventionTips":["Validate JWK JSON against the RFC 7518 schema before parsing.","Never hand-edit 'oth' entries; export keys with standard tooling."],"tags":["jwk","rsa","malformed-key","json"],"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"}