From bfdc414f84ad94fae2dbc18d477478078045eb8f Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Tue, 14 Dec 2021 15:08:23 +0200 Subject: [PATCH] Remove unused OAuth code in main module. (#4368) Closes #4367. --- main/pom.xml | 10 -- .../commands/auth/AuthorizeCommand.java | 168 ------------------ .../commands/auth/DeAuthorizeCommand.java | 65 ------- .../AuthorizationHeaderSigningStrategy.java | 76 -------- .../com/google/refine/oauth/Credentials.java | 124 ------------- .../google/refine/oauth/GoogleProvider.java | 52 ------ .../google/refine/oauth/OAuthUtilities.java | 89 ---------- .../src/com/google/refine/oauth/Provider.java | 76 -------- .../webapp/modules/core/MOD-INF/controller.js | 3 - pom.xml | 1 - 10 files changed, 664 deletions(-) delete mode 100644 main/src/com/google/refine/commands/auth/AuthorizeCommand.java delete mode 100644 main/src/com/google/refine/commands/auth/DeAuthorizeCommand.java delete mode 100644 main/src/com/google/refine/oauth/AuthorizationHeaderSigningStrategy.java delete mode 100644 main/src/com/google/refine/oauth/Credentials.java delete mode 100644 main/src/com/google/refine/oauth/GoogleProvider.java delete mode 100644 main/src/com/google/refine/oauth/OAuthUtilities.java delete mode 100644 main/src/com/google/refine/oauth/Provider.java diff --git a/main/pom.xml b/main/pom.xml index 82397c79a..8e7825a98 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -258,16 +258,6 @@ vicino ${vicino.version} - - oauth.signpost - signpost-core - ${signpost.version} - - - oauth.signpost - signpost-commonshttp4 - ${signpost.version} - org.clojure clojure diff --git a/main/src/com/google/refine/commands/auth/AuthorizeCommand.java b/main/src/com/google/refine/commands/auth/AuthorizeCommand.java deleted file mode 100644 index 1e6f44896..000000000 --- a/main/src/com/google/refine/commands/auth/AuthorizeCommand.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.commands.auth; - -import java.io.IOException; -import java.io.PrintWriter; -import java.net.URI; -import java.net.URISyntaxException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.google.refine.commands.Command; -import com.google.refine.oauth.Credentials; -import com.google.refine.oauth.OAuthUtilities; -import com.google.refine.oauth.Provider; - -import oauth.signpost.OAuthConsumer; -import oauth.signpost.OAuthProvider; - -public class AuthorizeCommand extends Command { - - private static final String OAUTH_VERIFIER_PARAM = "oauth_verifier"; - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - // get the provider from the request - Provider provider = OAuthUtilities.getProvider(request); - - try { - - // see if the request comes with access credentials - Credentials access_credentials = Credentials.getCredentials(request, provider, Credentials.Type.ACCESS); - - // prepare the continuation URL that the OAuth provider will redirect the user to - // (we need to make sure this URL points back to this code or the dance will never complete) - String callbackURL = getBaseURL(request,provider); - - if (access_credentials == null) { - // access credentials are not available so we need to check - // to see at what stage of the OAuth dance we are - - // get the request token credentials - Credentials request_credentials = Credentials.getCredentials(request, provider, Credentials.Type.REQUEST); - - OAuthConsumer consumer = OAuthUtilities.getConsumer(request_credentials, provider); - OAuthProvider pp = provider.getProvider(); - - if (request_credentials == null) { - // no credentials were found, so let's start the dance - - // get the request token - - String url = pp.retrieveRequestToken(consumer, callbackURL); - - request_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider); - - // and set them to that we can retrieve them later in the second part of the dance - Credentials.setCredentials(request, response, request_credentials, Credentials.Type.REQUEST, 3600); - - // now redirect the user to the Authorize URL where she can authenticate against the - // service provider and authorize us. - // The provider will bounce the user back here for us to continue the dance. - - response.sendRedirect(url); - } else { - // we are at the second stage of the dance, so we need need to obtain the access credentials now - - // if we got here, it means that the user performed a valid authentication against the - // service provider and authorized us, so now we can request more permanent credentials - // to the service provider and save those as well for later use. - - // this is set only for OAuth 1.0a - String verificationCode = request.getParameter(OAUTH_VERIFIER_PARAM); - - pp.retrieveAccessToken(consumer, verificationCode); - - access_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider); - - // no matter the result, we need to remove the request token - Credentials.deleteCredentials(request, response, provider, Credentials.Type.REQUEST); - - Credentials.setCredentials(request, response, access_credentials, Credentials.Type.ACCESS, 30 * 24 * 3600); - - finish(response); - } - } else { - finish(response); - } - } catch (Exception e) { - Credentials.deleteCredentials(request, response, provider, Credentials.Type.REQUEST); - Credentials.deleteCredentials(request, response, provider, Credentials.Type.ACCESS); - respondException(response, e); - } - } - - private void finish(HttpServletResponse response) throws IOException { - response.setCharacterEncoding("UTF-8"); - response.setHeader("Content-Type", "text/html"); - - PrintWriter writer = response.getWriter(); - writer.write( - "" + - "" + - "" + - "" - ); - writer.flush(); - } - - private String getBaseURL(HttpServletRequest request, Provider provider) { - String host = request.getHeader("host"); - if (host == null) { - String referrer = request.getHeader("referer"); - if (referrer != null) { - URI url; - try { - url = new URI(referrer); - int port = url.getPort(); - host = url.getHost() + ((port > -1) ? ":" + url.getPort() : ""); - } catch (URISyntaxException e) { - throw new RuntimeException("referrer '" + referrer + "' can't be parsed as a URL"); - } - } else { - throw new RuntimeException("neither the 'host' nor 'referer' headers were present in the HTTP response, I can't determine what URL OpenRefine is listening to."); - } - } - return "http://" + host + "/command/core/authorize/" + provider.getHost(); - } -} diff --git a/main/src/com/google/refine/commands/auth/DeAuthorizeCommand.java b/main/src/com/google/refine/commands/auth/DeAuthorizeCommand.java deleted file mode 100644 index 5e02ceedd..000000000 --- a/main/src/com/google/refine/commands/auth/DeAuthorizeCommand.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.commands.auth; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.google.refine.commands.Command; -import com.google.refine.oauth.Credentials; -import com.google.refine.oauth.OAuthUtilities; -import com.google.refine.oauth.Provider; - -public class DeAuthorizeCommand extends Command { - - @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - try { - response.setCharacterEncoding("UTF-8"); - response.setHeader("Content-Type", "application/json"); - - Provider provider = OAuthUtilities.getProvider(request); - - Credentials.deleteCredentials(request, response, provider, Credentials.Type.ACCESS); - - respond(response, "200 OK", ""); - } catch (Exception e) { - respondException(response, e); - } - } -} diff --git a/main/src/com/google/refine/oauth/AuthorizationHeaderSigningStrategy.java b/main/src/com/google/refine/oauth/AuthorizationHeaderSigningStrategy.java deleted file mode 100644 index 6deb8b17e..000000000 --- a/main/src/com/google/refine/oauth/AuthorizationHeaderSigningStrategy.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2018, OpenRefine contributors - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ -package com.google.refine.oauth; - -import java.util.Iterator; - -import oauth.signpost.OAuth; -import oauth.signpost.http.HttpParameters; -import oauth.signpost.http.HttpRequest; -import oauth.signpost.signature.SigningStrategy; - -public class AuthorizationHeaderSigningStrategy implements SigningStrategy { - - private static final long serialVersionUID = 1L; - - private final String realm; - - public AuthorizationHeaderSigningStrategy(String realm) { - this.realm = realm; - } - - public String writeSignature(String signature, HttpRequest request, HttpParameters requestParameters) { - - StringBuilder sb = new StringBuilder(); - - sb.append("OAuth "); - - if (realm != null) { - sb.append("realm=\"" + realm + "\", "); - } - - // add all (x_)oauth parameters - HttpParameters oauthParams = requestParameters.getOAuthParameters(); - oauthParams.put(OAuth.OAUTH_SIGNATURE, signature, true); - - Iterator iter = oauthParams.keySet().iterator(); - while (iter.hasNext()) { - String key = iter.next(); - sb.append(oauthParams.getAsHeaderElement(key)); - if (iter.hasNext()) { - sb.append(", "); - } - } - - String header = sb.toString(); - OAuth.debugOut("Auth Header", header); - request.setHeader(OAuth.HTTP_AUTHORIZATION_HEADER, header); - - return header; - } - -} diff --git a/main/src/com/google/refine/oauth/Credentials.java b/main/src/com/google/refine/oauth/Credentials.java deleted file mode 100644 index 7c4aa6381..000000000 --- a/main/src/com/google/refine/oauth/Credentials.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.oauth; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.google.refine.util.CookiesUtilities; - -import oauth.signpost.OAuth; -import oauth.signpost.http.HttpParameters; - -public class Credentials { - - private static final String TOKEN = "oauth_token"; - private static final String SECRET = "oauth_token_secret"; - - public enum Type { - REQUEST("request"), - ACCESS("access"); - - private final String postfix; - - Type(String postfix) { - this.postfix = postfix; - } - - public String getCookieName(Provider provider) { - if (provider == null) { - throw new RuntimeException("Provider can't be null"); - } - return provider.getHost() + "_" + postfix; - } - }; - - public static Credentials getCredentials(HttpServletRequest request, Provider provider, Type type) { - Cookie cookie = CookiesUtilities.getCookie(request, type.getCookieName(provider)); - return (cookie == null) ? null : makeCredentials(cookie.getValue(), provider); - } - - public static void setCredentials(HttpServletRequest request, HttpServletResponse response, Credentials credentials, Type type, int max_age) { - String name = type.getCookieName(credentials.getProvider()); - String value = credentials.toString(); - CookiesUtilities.setCookie(request, response, name, value, max_age); - } - - public static void deleteCredentials(HttpServletRequest request, HttpServletResponse response, Provider provider, Type type) { - CookiesUtilities.deleteCookie(request, response, type.getCookieName(provider)); - } - - public static Credentials makeCredentials(String str, Provider provider) { - HttpParameters p = OAuth.decodeForm(str); - return new Credentials(p.getFirst(TOKEN), p.getFirst(SECRET), provider); - } - - private Provider provider; - private String token; - private String secret; - - public Credentials(String token, String secret, Provider provider) { - this.token = token; - if (token == null) { - throw new RuntimeException("Could not find " + TOKEN + " in auth credentials"); - } - this.secret = secret; - if (secret == null) { - throw new RuntimeException("Could not find " + SECRET + " in auth credentials"); - } - this.provider = provider; - if (provider == null) { - throw new RuntimeException("Provider can't be null"); - } - } - - public String getToken() { - return token; - } - - public String getSecret() { - return secret; - } - - public Provider getProvider() { - return provider; - } - - @Override - public String toString() { - return TOKEN + "=" + OAuth.percentEncode(token) + "&" + SECRET + "=" + OAuth.percentEncode(secret); - } - -} diff --git a/main/src/com/google/refine/oauth/GoogleProvider.java b/main/src/com/google/refine/oauth/GoogleProvider.java deleted file mode 100644 index 6a4b0453e..000000000 --- a/main/src/com/google/refine/oauth/GoogleProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.oauth; - -public class GoogleProvider extends Provider { - - @Override - public String getRequestTokenServiceURL() { - return "https://www.google.com/accounts/OAuthGetRequestToken"; - } - - @Override - public String getAccessTokenServiceURL() { - return "https://www.google.com/accounts/OAuthGetAccessToken"; - } - - @Override - public String getUserAuthorizationURL() { - return "https://www.google.com/accounts/OAuthAuthorizeToken"; - } -} diff --git a/main/src/com/google/refine/oauth/OAuthUtilities.java b/main/src/com/google/refine/oauth/OAuthUtilities.java deleted file mode 100644 index 498a2103a..000000000 --- a/main/src/com/google/refine/oauth/OAuthUtilities.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.oauth; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import oauth.signpost.OAuthConsumer; - -public class OAuthUtilities { - - static final private Map providers = new HashMap(); - static final private Map infos = new HashMap(); - - static final public void registerOAuthProvider(Provider provider, String[] oauthInfo) { - providers.put(provider.getHost(), provider); - infos.put(provider.getHost(), oauthInfo); - } - - public static Provider getProvider(String name) { - return (name == null) ? null : providers.get(name); - } - - public static Provider getProvider(HttpServletRequest request) { - String path = request.getPathInfo().substring(1); - int slash = path.lastIndexOf('/'); - String provider_str = path.substring(slash + 1); - Provider provider = getProvider(provider_str); - if (provider == null) { - throw new RuntimeException("Can't find OAuth provider '" + provider_str + "'"); - } - return provider; - } - - public static OAuthConsumer getConsumer(Provider provider) { - if (provider == null) { - throw new RuntimeException("Provider can't be null"); - } - String[] consumer_info = infos.get(provider.getHost()); - if (consumer_info == null) { - throw new RuntimeException("Can't find secrets for provider '" + provider.getHost() + "'"); - } - OAuthConsumer oauthConsumer = provider.createConsumer(consumer_info[0],consumer_info[1]); - oauthConsumer.setSigningStrategy(new AuthorizationHeaderSigningStrategy(provider.getRealm())); - return oauthConsumer; - } - - public static OAuthConsumer getConsumer(Credentials credentials, Provider provider) { - OAuthConsumer consumer = getConsumer(provider); - if (credentials != null) { - consumer.setTokenWithSecret(credentials.getToken(), credentials.getSecret()); - } - return consumer; - } - -} diff --git a/main/src/com/google/refine/oauth/Provider.java b/main/src/com/google/refine/oauth/Provider.java deleted file mode 100644 index fb32e95c6..000000000 --- a/main/src/com/google/refine/oauth/Provider.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.oauth; - -import oauth.signpost.OAuthConsumer; -import oauth.signpost.OAuthProvider; -import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer; -import oauth.signpost.commonshttp.CommonsHttpOAuthProvider; - -public abstract class Provider { - - protected String host; - protected OAuthProvider oauthProvider; - - public Provider() { - } - - public Provider(String host) { - this.host = host; - } - - public String getHost() { - return host; - } - - public String getRealm() { - return "http://" + host + "/"; - } - - abstract public String getRequestTokenServiceURL(); - abstract public String getAccessTokenServiceURL(); - abstract public String getUserAuthorizationURL(); - - public OAuthConsumer createConsumer(String consumerKey, String consumerSecret) { - return new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); - } - - public synchronized OAuthProvider getProvider() { - if (oauthProvider == null) { - oauthProvider = new CommonsHttpOAuthProvider( - getRequestTokenServiceURL(), getAccessTokenServiceURL(), getUserAuthorizationURL()); - } - return oauthProvider; - } -} diff --git a/main/webapp/modules/core/MOD-INF/controller.js b/main/webapp/modules/core/MOD-INF/controller.js index 6a428f9e8..ff4226338 100644 --- a/main/webapp/modules/core/MOD-INF/controller.js +++ b/main/webapp/modules/core/MOD-INF/controller.js @@ -149,9 +149,6 @@ function registerCommands() { RS.registerCommand(module, "set-preference", new Packages.com.google.refine.commands.SetPreferenceCommand()); RS.registerCommand(module, "open-workspace-dir", new Packages.com.google.refine.commands.OpenWorkspaceDirCommand()); - RS.registerCommand(module, "authorize", new Packages.com.google.refine.commands.auth.AuthorizeCommand()); - RS.registerCommand(module, "deauthorize", new Packages.com.google.refine.commands.auth.DeAuthorizeCommand()); - } function registerOperations() { diff --git a/pom.xml b/pom.xml index 097e6eab1..8f5cba0bb 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,6 @@ 1.14.2 0.10.0 1.2 - 2.1.1 1.10.3 4.5.13 5.1.2