Remove EvernoteAuthToken
This commit is contained in:
1 parent
5c030ca360
commit
0a45342004
1 file changed
+3
-54
@@ -6,7 +6,6 @@ import java.util.regex.Pattern;
|
||||
import org.scribe.exceptions.OAuthException;
|
||||
import org.scribe.extractors.AccessTokenExtractor;
|
||||
import org.scribe.model.Token;
|
||||
import org.scribe.model.Verb;
|
||||
import org.scribe.utils.OAuthEncoder;
|
||||
import org.scribe.utils.Preconditions;
|
||||
|
||||
@@ -14,12 +13,6 @@ public class EvernoteApi extends DefaultApi10a
|
||||
{
|
||||
private static final String EVERNOTE_URL = "https://www.evernote.com";
|
||||
|
||||
@Override
|
||||
public Verb getRequestTokenVerb()
|
||||
{
|
||||
return Verb.GET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestTokenEndpoint()
|
||||
{
|
||||
@@ -65,51 +58,12 @@ public class EvernoteApi extends DefaultApi10a
|
||||
return String.format(SANDBOX_URL + "/OAuth.action?oauth_token=%s", requestToken.getToken());
|
||||
}
|
||||
}
|
||||
|
||||
public static class EvernoteAuthToken extends Token {
|
||||
private static final long serialVersionUID = 5913745981744917828L;
|
||||
|
||||
private String noteStoreUrl;
|
||||
private String webApiUrlPrefix;
|
||||
private int userId;
|
||||
|
||||
public EvernoteAuthToken(String token, String secret,
|
||||
String noteStoreUrl, String webApiUrlPrefix, int userId, String rawResponse) {
|
||||
super(token, secret, rawResponse);
|
||||
this.noteStoreUrl = noteStoreUrl;
|
||||
this.webApiUrlPrefix = webApiUrlPrefix;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Evernote web service NoteStore URL from the OAuth access token response.
|
||||
*/
|
||||
public String getNoteStoreUrl() {
|
||||
return noteStoreUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Evernote web API URL prefix from the OAuth access token response.
|
||||
*/
|
||||
public String getWebApiUrlPrefix() {
|
||||
return webApiUrlPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the numeric Evernote user ID from the OAuth access token response.
|
||||
*/
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EvernoteAccessTokenExtractor implements org.scribe.extractors.AccessTokenExtractor {
|
||||
public static class EvernoteAccessTokenExtractor implements AccessTokenExtractor {
|
||||
|
||||
private static final Pattern TOKEN_REGEX = Pattern.compile("oauth_token=([^&]+)");
|
||||
// Evernote access tokens include an empty token secret (the empty string).
|
||||
private static final Pattern SECRET_REGEX = Pattern.compile("oauth_token_secret=([^&]*)");
|
||||
private static final Pattern NOTESTORE_REGEX = Pattern.compile("edam_noteStoreUrl=([^&]+)");
|
||||
private static final Pattern WEBAPI_REGEX = Pattern.compile("edam_webApiUrlPrefix=([^&]+)");
|
||||
private static final Pattern USERID_REGEX = Pattern.compile("edam_userId=([^&]+)");
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -118,12 +72,7 @@ public class EvernoteApi extends DefaultApi10a
|
||||
{
|
||||
Preconditions.checkEmptyString(response, "Response body is incorrect. " +
|
||||
"Can't extract a token from an empty string");
|
||||
return new EvernoteAuthToken(extract(response, TOKEN_REGEX),
|
||||
extract(response, SECRET_REGEX),
|
||||
extract(response, NOTESTORE_REGEX),
|
||||
extract(response, WEBAPI_REGEX),
|
||||
Integer.parseInt(extract(response, USERID_REGEX)),
|
||||
response);
|
||||
return new Token(extract(response, TOKEN_REGEX), extract(response, SECRET_REGEX), response);
|
||||
}
|
||||
|
||||
private String extract(String response, Pattern p)
|
||||
|
||||
Reference in new issue
Block a user