@Priority(Priorities.JWS_CLIENT_READ_PRIORITY)
public class JwsClientResponseFilter extends AbstractJwsReaderProvider implements ClientResponseFilter {
@Override
public void filter(ClientRequestContext req, ClientResponseContext res) throws IOException {
JwsSignatureVerifier theSigVerifier = getInitializedSigVerifier();
JwsCompactConsumer p = new JwsCompactConsumer(IOUtils.readStringFromStream(res.getEntityStream()),
getSigProperties());
p.verifySignatureWith(theSigVerifier);
byte[] bytes = p.getDecodedJwsPayloadBytes();
res.setEntityStream(new ByteArrayInputStream(bytes));
res.getHeaders().putSingle("Content-Length", Integer.toString(bytes.length));
String ct = JwtUtils.checkContentType(p.getJwtHeaders().getContentType(), getDefaultMediaType());
if (ct != null) {
res.getHeaders().putSingle("Content-Type", ct);
}
}