jwejose4j

jose4j: how to set full serialization input?


Is there a way to set a JWE full serialization input with jose4j? For example, what goes in the TODO below?

public String decryptJWE(PrivateKey privateKey, String payload, boolean compact) throws JoseException {
    JsonWebEncryption jwe = new JsonWebEncryption();

    if (compact) {
        jwe.setCompactSerialization(payload);
    } else {
        // TODO:  what goes here?  expecting something like jwe.setFullSerialization(payload)
    }
    jwe.setKey(privateKey);

    return jwe.getPayload();
}

Solution

  • No, only the JWE compact serialization is supported. The general and flattened JWE JSON serializations aren't directly supported.