* @return an exception to throw for the given content
*/
private BellaDatiRuntimeException buildException(int code, byte[] content, boolean hasToken) {
try {
HttpParameters oauthParams = OAuth.decodeForm(new ByteArrayInputStream(content));
if (oauthParams.containsKey("oauth_problem")) {
String problem = oauthParams.getFirst("oauth_problem");
if ("missing_consumer".equals(problem) || "invalid_consumer".equals(problem)) {
return new AuthorizationException(Reason.CONSUMER_KEY_UNKNOWN);
} else if ("invalid_signature".equals(problem) || "signature_invalid".equals(problem)) {
return new AuthorizationException(hasToken ? Reason.TOKEN_INVALID : Reason.CONSUMER_SECRET_INVALID);