FIXED - task 614: Use same instance of OAuthProvider in OAuth dance. Patch supplied by sdeo@google.com

http://code.google.com/p/google-refine/issues/detail?id=614

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2566 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2012-09-19 23:16:29 +00:00
parent 0cab117351
commit 27e3c0c8dc
3 changed files with 12 additions and 7 deletions

View File

@ -77,7 +77,7 @@ public class AuthorizeCommand extends Command {
Credentials request_credentials = Credentials.getCredentials(request, provider, Credentials.Type.REQUEST); Credentials request_credentials = Credentials.getCredentials(request, provider, Credentials.Type.REQUEST);
OAuthConsumer consumer = OAuthUtilities.getConsumer(request_credentials, provider); OAuthConsumer consumer = OAuthUtilities.getConsumer(request_credentials, provider);
OAuthProvider pp = OAuthUtilities.getOAuthProvider(provider); OAuthProvider pp = provider.getProvider();
if (request_credentials == null) { if (request_credentials == null) {
// no credentials were found, so let's start the dance // no credentials were found, so let's start the dance

View File

@ -39,8 +39,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import oauth.signpost.OAuthConsumer; import oauth.signpost.OAuthConsumer;
import oauth.signpost.OAuthProvider;
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider;
public class OAuthUtilities { public class OAuthUtilities {
@ -88,8 +86,4 @@ public class OAuthUtilities {
return consumer; return consumer;
} }
public static OAuthProvider getOAuthProvider(Provider p) {
return new CommonsHttpOAuthProvider(p.getRequestTokenServiceURL(), p.getAccessTokenServiceURL(), p.getUserAuthorizationURL());
}
} }

View File

@ -34,11 +34,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.oauth; package com.google.refine.oauth;
import oauth.signpost.OAuthConsumer; import oauth.signpost.OAuthConsumer;
import oauth.signpost.OAuthProvider;
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider;
public abstract class Provider { public abstract class Provider {
protected String host; protected String host;
protected OAuthProvider oauthProvider;
public Provider() { public Provider() {
} }
@ -62,4 +65,12 @@ public abstract class Provider {
public OAuthConsumer createConsumer(String consumerKey, String consumerSecret) { public OAuthConsumer createConsumer(String consumerKey, String consumerSecret) {
return new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); return new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
} }
public synchronized OAuthProvider getProvider() {
if (oauthProvider == null) {
oauthProvider = new CommonsHttpOAuthProvider(
getRequestTokenServiceURL(), getAccessTokenServiceURL(), getUserAuthorizationURL());
}
return oauthProvider;
}
} }