{"record":{"id":"36599e9705db4963","repo":"jwtk/jjwt","slug":"rsa-jwk-oth-other-prime-info-element-map-canno","errorCode":null,"errorMessage":"RSA JWK 'oth' (Other Prime Info) element map cannot be empty.","messagePattern":"RSA JWK 'oth' \\(Other Prime Info\\) element map cannot be empty\\.","errorType":"exception","errorClass":"MalformedKeyException","httpStatus":null,"severity":"error","filePath":"impl/src/main/java/io/jsonwebtoken/impl/security/RSAOtherPrimeInfoConverter.java","lineNumber":62,"sourceCode":"        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);\n        BigInteger prime = reader.get(PRIME_FACTOR);\n        BigInteger primeExponent = reader.get(FACTOR_CRT_EXPONENT);\n        BigInteger crtCoefficient = reader.get(FACTOR_CRT_COEFFICIENT);\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/impl/src/main/java/io/jsonwebtoken/impl/security/RSAOtherPrimeInfoConverter.java#L44-L80","documentation":"Thrown as MalformedKeyException when an element of the RSA JWK 'oth' (Other Prime Info) array is a Map but has no entries. RFC 7518 requires each 'oth' entry to carry r (prime factor), t (factor CRT exponent), and d (CRT coefficient); an empty object supplies none of them.","triggerScenarios":"Parsing a JWK where 'oth' contains an empty JSON object, e.g. oth: [{}], through JWK parsing/JwkBuilder APIs.","commonSituations":"Template JWKs with placeholder empty objects; code that strips JWK fields (e.g. removing r/t/d individually) leaving empty maps; incomplete multi-prime key exports.","solutions":["Populate the 'oth' element with the required r, t, and d parameters.","Remove empty objects from the 'oth' array, or remove the 'oth' member if not needed.","Re-export the multi-prime RSA key from its original source with all CRT parameters."],"exampleFix":"// before\n\"oth\": [{}]\n// after\n\"oth\": [ {\"r\":\"...\",\"t\":\"...\",\"d\":\"...\"} ]","handlingStrategy":"validation","validationCode":"boolean othNonEmpty = oth != null && oth.stream().allMatch(e -> e instanceof Map && !((Map<?,?>) e).isEmpty());","typeGuard":"boolean hasRequiredOthParams(Object o) { return o instanceof Map && ((Map<?,?>) o).keySet().containsAll(java.util.Arrays.asList(\"r\",\"t\",\"d\")); }","tryCatchPattern":"try { /* parse JWK */ } catch (MalformedKeyException e) { throw new IllegalStateException(\"'oth' entry missing r/t/d parameters\", e); }","preventionTips":["Check each 'oth' object contains r, t, and d before use.","Remove empty placeholder objects from JWK templates."],"tags":["jwk","rsa","malformed-key","empty-value"],"backgroundTag":"empty-required-field","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"}