Skip to content

Commit 5e7281c

Browse files
author
Christian Huff
committed
Merge from 1.3.2 upstream
1 parent 8c021ae commit 5e7281c

20 files changed

Lines changed: 729 additions & 278 deletions

README.textile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ You can pull scribe from a maven repository, just add this to your __pom.xml__ f
6565
@<dependency>@
6666
@<groupId>org.scribe</groupId>@
6767
@<artifactId>scribe</artifactId>@
68-
@<version>1.3.0</version>@
68+
@<version>1.3.2</version>@
6969
@</dependency>@
7070

7171
h1. Getting started in less than 2 minutes

changelog.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,13 @@
8585
* FIX: Allow digits in url schemes
8686
* FEATURE: Specific exception for connection problems (OAuthConnectionException)
8787
* FIX: Dropbox Api and Evernote Api updated to their latests versions
88-
* FIX: Digg and Skyrock Apis
88+
* FEATURE: Digg and Skyrock Apis
89+
90+
[1.3.2]
91+
* FIX: Don't include oauth_token in 2legged calls.
92+
* FEATURE: RSA-SHA1 Signatures.
93+
* FEATURE: equals & hashcode on Token object.
94+
* FEATURE: ConstantContact Api
95+
96+
[1.3.3]
97+
* FEATURE: accessToken and requestToken timeouts default to 2 seconds and can be specified.

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>org.scribe</groupId>
55
<artifactId>scribe</artifactId>
66
<packaging>jar</packaging>
7-
<version>1.3.1-patched</version>
7+
<version>1.3.2</version>
88
<name>Scribe OAuth Library</name>
99
<description>The best OAuth library out there</description>
1010
<url>http://github.com/fernandezpablo85/scribe-java</url>
@@ -67,7 +67,7 @@
6767
<target>1.5</target>
6868
</configuration>
6969
</plugin>
70-
<!--plugin>
70+
<plugin>
7171
<groupId>org.apache.maven.plugins</groupId>
7272
<artifactId>maven-gpg-plugin</artifactId>
7373
<executions>
@@ -79,7 +79,7 @@
7979
</goals>
8080
</execution>
8181
</executions>
82-
</plugin-->
82+
</plugin>
8383
</plugins>
8484
</build>
8585
</project>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.scribe.builder.api;
2+
3+
import java.util.regex.*;
4+
import org.scribe.exceptions.*;
5+
import org.scribe.extractors.*;
6+
import org.scribe.model.*;
7+
import org.scribe.utils.*;
8+
9+
public class ConstantContactApi2 extends DefaultApi20
10+
{
11+
private static final String AUTHORIZE_URL = "https://oauth2.constantcontact.com/oauth2/oauth/siteowner/authorize?client_id=%s&response_type=code&redirect_uri=%s";
12+
13+
@Override
14+
public String getAccessTokenEndpoint()
15+
{
16+
return "https://oauth2.constantcontact.com/oauth2/oauth/token?grant_type=authorization_code";
17+
}
18+
19+
@Override
20+
public String getAuthorizationUrl(OAuthConfig config)
21+
{
22+
return String.format(AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()));
23+
}
24+
25+
@Override
26+
public Verb getAccessTokenVerb()
27+
{
28+
return Verb.POST;
29+
}
30+
31+
@Override
32+
public AccessTokenExtractor getAccessTokenExtractor()
33+
{
34+
return new AccessTokenExtractor()
35+
{
36+
37+
public Token extract(String response)
38+
{
39+
Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
40+
41+
String regex = "\"access_token\"\\s*:\\s*\"([^&\"]+)\"";
42+
Matcher matcher = Pattern.compile(regex).matcher(response);
43+
if (matcher.find())
44+
{
45+
String token = OAuthEncoder.decode(matcher.group(1));
46+
return new Token(token, "", response);
47+
}
48+
else
49+
{
50+
throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
51+
}
52+
}
53+
};
54+
}
55+
}

src/main/java/org/scribe/builder/api/LinkedInApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class LinkedInApi extends DefaultApi10a
66
{
7-
private static final String AUTHORIZE_URL = "https://api.linkedin.com/uas/oauth/authorize?oauth_token=%s";
7+
private static final String AUTHORIZE_URL = "https://api.linkedin.com/uas/oauth/authenticate?oauth_token=%s";
88

99
@Override
1010
public String getAccessTokenEndpoint()
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.scribe.builder.api;
2+
3+
import org.scribe.model.*;
4+
5+
/**
6+
* @author Arieh "Vainolo" Bibliowicz
7+
* @see http://apidocs.mendeley.com/home/authentication
8+
*/
9+
public class MendeleyApi extends DefaultApi10a
10+
{
11+
12+
private static final String AUTHORIZATION_URL = "http://api.mendeley.com/oauth/authorize?oauth_token=%s";
13+
14+
@Override
15+
public String getRequestTokenEndpoint()
16+
{
17+
return "http://api.mendeley.com/oauth/request_token/";
18+
}
19+
20+
@Override
21+
public String getAccessTokenEndpoint()
22+
{
23+
return "http://api.mendeley.com/oauth/access_token/";
24+
}
25+
26+
@Override
27+
public String getAuthorizationUrl(Token requestToken)
28+
{
29+
return String.format(AUTHORIZATION_URL, requestToken.getToken());
30+
}
31+
32+
@Override
33+
public Verb getAccessTokenVerb()
34+
{
35+
return Verb.GET;
36+
}
37+
38+
@Override
39+
public Verb getRequestTokenVerb()
40+
{
41+
return Verb.GET;
42+
}
43+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.scribe.builder.api;
2+
3+
import org.scribe.model.*;
4+
5+
public class TrelloApi extends DefaultApi10a
6+
{
7+
private static final String AUTHORIZE_URL = "https://trello.com/1/OAuthAuthorizeToken?oauth_token=%s";
8+
9+
@Override
10+
public String getAccessTokenEndpoint()
11+
{
12+
return "https://trello.com/1/OAuthGetAccessToken";
13+
}
14+
15+
@Override
16+
public String getRequestTokenEndpoint()
17+
{
18+
return "https://trello.com/1/OAuthGetRequestToken";
19+
}
20+
21+
@Override
22+
public String getAuthorizationUrl(Token requestToken)
23+
{
24+
return String.format(AUTHORIZE_URL, requestToken.getToken());
25+
}
26+
27+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.scribe.builder.api;
2+
3+
import org.scribe.model.Token;
4+
import org.scribe.services.*;
5+
6+
/**
7+
* @author Julio Gutierrez
8+
*
9+
* Sep 6, 2012
10+
*/
11+
public class UbuntuOneApi extends DefaultApi10a
12+
{
13+
14+
private static final String AUTHORIZATION_URL = "https://one.ubuntu.com/oauth/authorize/?oauth_token=%s";
15+
16+
@Override
17+
public String getAccessTokenEndpoint()
18+
{
19+
return "https://one.ubuntu.com/oauth/access/";
20+
}
21+
22+
@Override
23+
public String getAuthorizationUrl(Token requestToken)
24+
{
25+
return String.format(AUTHORIZATION_URL, requestToken.getToken());
26+
}
27+
28+
@Override
29+
public String getRequestTokenEndpoint()
30+
{
31+
return "https://one.ubuntu.com/oauth/request/";
32+
}
33+
34+
@Override
35+
public SignatureService getSignatureService()
36+
{
37+
return new PlaintextSignatureService();
38+
}
39+
40+
}

src/main/java/org/scribe/builder/api/VkontakteApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
public class VkontakteApi extends DefaultApi20
1212
{
13-
private static final String AUTHORIZE_URL = "https://api.vkontakte.ru/oauth/authorize?client_id=%s&redirect_uri=%s&response_type=code";
13+
private static final String AUTHORIZE_URL = "https://oauth.vk.com/authorize?client_id=%s&redirect_uri=%s&response_type=code";
1414
private static final String SCOPED_AUTHORIZE_URL = String.format("%s&scope=%%s", AUTHORIZE_URL);
1515

1616
@Override

src/main/java/org/scribe/extractors/JsonTokenExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class JsonTokenExtractor implements AccessTokenExtractor
1010
{
11-
private Pattern accessTokenPattern = Pattern.compile("\"access_token\"\\s*:\\s*\"(\\S*?)\"");
11+
private Pattern accessTokenPattern = Pattern.compile("\"access_token\":\\s*\"(\\S*?)\"");
1212

1313
public Token extract(String response)
1414
{
@@ -24,4 +24,4 @@ public Token extract(String response)
2424
}
2525
}
2626

27-
}
27+
}

0 commit comments

Comments
 (0)