Search in sources :

Example 1 with HttpResponse

use of org.apache.shindig.gadgets.http.HttpResponse in project liferay-ide by liferay.

the class OAuthRequest method fetchData.

/**
 * Get honest-to-goodness user data.
 *
 * @throws OAuthProtocolException if the service provider returns an OAuth
 * related error instead of user data.
 */
private HttpResponseBuilder fetchData() throws OAuthRequestException, OAuthProtocolException {
    HttpResponseBuilder builder = null;
    if (accessTokenData != null) {
        // This is a request for access token data, return it.
        builder = formatAccessTokenData();
    } else {
        HttpRequest signed = sanitizeAndSign(realRequest, null, false);
        HttpResponse response = fetchFromServer(signed);
        checkForProtocolProblem(response);
        builder = new HttpResponseBuilder(response);
    }
    return builder;
}
Also used : HttpRequest(org.apache.shindig.gadgets.http.HttpRequest) HttpResponseBuilder(org.apache.shindig.gadgets.http.HttpResponseBuilder) HttpResponse(org.apache.shindig.gadgets.http.HttpResponse)

Example 2 with HttpResponse

use of org.apache.shindig.gadgets.http.HttpResponse in project liferay-ide by liferay.

the class OAuthRequest method sendOAuthMessage.

/**
 * Sends OAuth request token and access token messages.
 */
private OAuthMessage sendOAuthMessage(HttpRequest request) throws OAuthRequestException, OAuthProtocolException {
    HttpResponse response = fetchFromServer(request);
    checkForProtocolProblem(response);
    OAuthMessage reply = new OAuthMessage(null, null, null);
    reply.addParameters(OAuth.decodeForm(response.getResponseAsString()));
    reply = parseAuthHeader(reply, response);
    if (OAuthUtil.getParameter(reply, OAuth.OAUTH_TOKEN) == null) {
        throw new OAuthRequestException(OAuthError.MISSING_OAUTH_PARAMETER, OAuth.OAUTH_TOKEN);
    }
    if (OAuthUtil.getParameter(reply, OAuth.OAUTH_TOKEN_SECRET) == null) {
        throw new OAuthRequestException(OAuthError.MISSING_OAUTH_PARAMETER, OAuth.OAUTH_TOKEN_SECRET);
    }
    return reply;
}
Also used : OAuthMessage(net.oauth.OAuthMessage) HttpResponse(org.apache.shindig.gadgets.http.HttpResponse)

Aggregations

HttpResponse (org.apache.shindig.gadgets.http.HttpResponse)2 OAuthMessage (net.oauth.OAuthMessage)1 HttpRequest (org.apache.shindig.gadgets.http.HttpRequest)1 HttpResponseBuilder (org.apache.shindig.gadgets.http.HttpResponseBuilder)1