Example usage for org.springframework.security.oauth.consumer OAuthConsumerSupport readProtectedResource

List of usage examples for org.springframework.security.oauth.consumer OAuthConsumerSupport readProtectedResource

Introduction

In this page you can find the example usage for org.springframework.security.oauth.consumer OAuthConsumerSupport readProtectedResource.

Prototype

InputStream readProtectedResource(URL url, OAuthConsumerToken accessToken, String httpMethod)
        throws OAuthRequestFailedException;

Source Link

Document

Read a protected resource from the given URL using the specified access token and HTTP method.

Usage

From source file:org.kuali.mobility.events.service.CalendarEventServiceImpl.java

private String getProtectedResource(String url, OAuthConsumerSupport consumerSupport,
        OAuthConsumerToken accessToken) throws OAuthRequestFailedException, IOException {
    InputStream is = consumerSupport.readProtectedResource(new URL(url), accessToken, "GET");
    if (is != null) {
        String output = "";
        try {//from w w w  . j  av a  2 s.  c o m
            BufferedReader myInput = new BufferedReader(new InputStreamReader(is));
            String currentLine = null;
            while ((currentLine = myInput.readLine()) != null) {
                output = output + currentLine;
            }
        } finally {
            is.close();
        }
        return output;
    }
    return "";
}