org.springframework.social.oauth1
Class ProtectedResourceClientFactory
java.lang.Object
org.springframework.social.oauth1.ProtectedResourceClientFactory
public class ProtectedResourceClientFactory
- extends java.lang.Object
Factory for RestTemplate instances that execute requests for resources protected by the OAuth 1 protocol.
Encapsulates the configuration of the interceptor that adds the necessary Authorization header to each request before it is executed.
Also hides the differences between Spring 3.0.x and 3.1 implementation.
Parameter Encoding
The underlying OAuth signing algorithm assumes that query parameters are encoded as application/x-www-form-urlencoded.
The RestTemplate methods that take String URL templates encode query parameters per RFC 3986 and not form-encoded.
This leads to problems where certain characters are improperly encoded. Spaces, for example are encoded as %20 instead of +;
and an actual + sign is left unencoded (and will be interpreted as a space when decoded as if it were form-encoded).
However, RestTemplate's methods that take URIs will leave the URI's parameters untouched. Therefore, when consuming a REST operation
with query parameters that require encoding (for example, if passing a + sign in a parameter value) you should use RestTemplate's
URI-based methods constructed with form-encoded parameters. See URIBuilder for a convenient way to build up such URIs.
Method Summary |
static RestTemplate |
create(java.lang.String consumerKey,
java.lang.String consumerSecret,
java.lang.String accessToken,
java.lang.String accessTokenSecret)
Constructs a RestTemplate that adds the OAuth1 Authorization header to each request before it is executed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ProtectedResourceClientFactory
public ProtectedResourceClientFactory()
create
public static RestTemplate create(java.lang.String consumerKey,
java.lang.String consumerSecret,
java.lang.String accessToken,
java.lang.String accessTokenSecret)
- Constructs a RestTemplate that adds the OAuth1 Authorization header to each request before it is executed.