aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/network/OAuth.java
diff options
context:
space:
mode:
authorrsudev <rasch@munin-soft.de>2013-05-28 23:17:56 -0700
committerrsudev <rasch@munin-soft.de>2013-05-28 23:17:56 -0700
commitf6779ac30d6ac1357d67654ea17afa1f1d6fa770 (patch)
treee1e84fca95948ef7ba13be7e12809388b24d3267 /main/src/cgeo/geocaching/network/OAuth.java
parentd6f1bc648361076c3b2038a6ab9b175e1de39b3d (diff)
parenta7de49db675048db5ae0c05ccd730a8579e6876e (diff)
downloadcgeo-f6779ac30d6ac1357d67654ea17afa1f1d6fa770.zip
cgeo-f6779ac30d6ac1357d67654ea17afa1f1d6fa770.tar.gz
cgeo-f6779ac30d6ac1357d67654ea17afa1f1d6fa770.tar.bz2
Merge pull request #2787 from rsudev/ocde_okapi_2
Implements OKAPI access for opencaching.de
Diffstat (limited to 'main/src/cgeo/geocaching/network/OAuth.java')
-rw-r--r--main/src/cgeo/geocaching/network/OAuth.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/network/OAuth.java b/main/src/cgeo/geocaching/network/OAuth.java
index 0b7a261..6740096 100644
--- a/main/src/cgeo/geocaching/network/OAuth.java
+++ b/main/src/cgeo/geocaching/network/OAuth.java
@@ -1,9 +1,9 @@
package cgeo.geocaching.network;
-import cgeo.geocaching.Settings;
import cgeo.geocaching.utils.CryptUtils;
import ch.boye.httpclientandroidlib.NameValuePair;
+
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
@@ -11,9 +11,17 @@ import java.util.Date;
import java.util.List;
public class OAuth {
- public static void signOAuth(final String host, final String path, final String method, final boolean https, final Parameters params, final String token, final String tokenSecret) {
+ public static void signOAuth(final String host,
+ final String path,
+ final String method,
+ final boolean https,
+ final Parameters params,
+ final String token,
+ final String tokenSecret,
+ final String consumerKey,
+ final String consumerSecret) {
params.put(
- "oauth_consumer_key", Settings.getKeyConsumerPublic(),
+ "oauth_consumer_key", consumerKey,
"oauth_nonce", CryptUtils.md5(Long.toString(System.currentTimeMillis())),
"oauth_signature_method", "HMAC-SHA1",
"oauth_timestamp", Long.toString(new Date().getTime() / 1000),
@@ -26,7 +34,7 @@ public class OAuth {
paramsEncoded.add(nameValue.getName() + "=" + Network.rfc3986URLEncode(nameValue.getValue()));
}
- final String keysPacked = Settings.getKeyConsumerSecret() + "&" + StringUtils.defaultString(tokenSecret); // both even if empty some of them!
+ final String keysPacked = consumerSecret + "&" + StringUtils.defaultString(tokenSecret); // both even if empty some of them!
final String requestPacked = method + "&" + Network.rfc3986URLEncode((https ? "https" : "http") + "://" + host + path) + "&" + Network.rfc3986URLEncode(StringUtils.join(paramsEncoded.toArray(), '&'));
params.put("oauth_signature", CryptUtils.base64Encode(CryptUtils.hashHmac(requestPacked, keysPacked)));
}