-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get binary data posting working, through some hacky code, move some v…
…alidation around, finish up testing
- Loading branch information
Showing
14 changed files
with
534 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/org/springframework/social/tumblr/api/impl/TumblrOAuth1Credentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.springframework.social.tumblr.api.impl; | ||
|
||
/** | ||
* Bean for OAuth credentials. Copy of Spring Socials' OAuth1Credentials, which is not public. | ||
* | ||
* @author sam | ||
* @version $Id$ | ||
*/ | ||
public class TumblrOAuth1Credentials { | ||
private final String consumerKey; | ||
|
||
private final String consumerSecret; | ||
|
||
private final String accessToken; | ||
|
||
private final String accessTokenSecret; | ||
|
||
public TumblrOAuth1Credentials(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) { | ||
this.consumerKey = consumerKey; | ||
this.consumerSecret = consumerSecret; | ||
this.accessToken = accessToken; | ||
this.accessTokenSecret = accessTokenSecret; | ||
} | ||
|
||
public String getConsumerKey() { | ||
return consumerKey; | ||
} | ||
|
||
public String getConsumerSecret() { | ||
return consumerSecret; | ||
} | ||
|
||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
|
||
public String getAccessTokenSecret() { | ||
return accessTokenSecret; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/springframework/social/tumblr/api/impl/TumblrOAuth1RequestInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.springframework.social.tumblr.api.impl; | ||
|
||
import org.springframework.http.HttpRequest; | ||
import org.springframework.http.client.ClientHttpRequestExecution; | ||
import org.springframework.http.client.ClientHttpRequestInterceptor; | ||
import org.springframework.http.client.ClientHttpResponse; | ||
import org.springframework.social.support.HttpRequestDecorator; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Copy of Spring Social's OAuth1RequestInterceptor, which is not public. Uses a | ||
* custom version of Spring Social's also not-public SigningSupport class. | ||
* | ||
* @author sam | ||
* @version $Id$ | ||
*/ | ||
public class TumblrOAuth1RequestInterceptor implements ClientHttpRequestInterceptor { | ||
|
||
private final TumblrSigningSupport signingUtils; | ||
private final TumblrTemplate tumblrTemplate; | ||
|
||
public TumblrOAuth1RequestInterceptor(TumblrTemplate tumblrTemplate) { | ||
this.tumblrTemplate = tumblrTemplate; | ||
this.signingUtils = new TumblrSigningSupport(); | ||
} | ||
|
||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { | ||
HttpRequest protectedResourceRequest = new HttpRequestDecorator(request); | ||
protectedResourceRequest.getHeaders().add("Authorization", getAuthorizationHeaderValue(request, body)); | ||
return execution.execute(protectedResourceRequest, body); | ||
} | ||
|
||
// internal helpers | ||
|
||
private String getAuthorizationHeaderValue(HttpRequest request, byte[] body) { | ||
return signingUtils.buildAuthorizationHeaderValue(request, body, tumblrTemplate.getCredentials()); | ||
} | ||
} |
Oops, something went wrong.