svn commit: r1738407 - in /ofbiz/trunk/specialpurpose/passport: README src/org/ofbiz/passport/event/GitHubEvents.java src/org/ofbiz/passport/event/LinkedInEvents.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1738407 - in /ofbiz/trunk/specialpurpose/passport: README src/org/ofbiz/passport/event/GitHubEvents.java src/org/ofbiz/passport/event/LinkedInEvents.java

shijh
Author: shijh
Date: Sun Apr 10 05:59:25 2016
New Revision: 1738407

URL: http://svn.apache.org/viewvc?rev=1738407&view=rev
Log:
OFBIZ-6755 Update the passport component to use httpclient/core-4.4.1 instead of commons-httpclient-3.1

1. Changed Applications to OAuth applications in README Github section.
2. Corrected the uri build to make the Github and LinkedIn OAuth login work.

Modified:
    ofbiz/trunk/specialpurpose/passport/README
    ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/GitHubEvents.java
    ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/LinkedInEvents.java

Modified: ofbiz/trunk/specialpurpose/passport/README
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/passport/README?rev=1738407&r1=1738406&r2=1738407&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/passport/README (original)
+++ ofbiz/trunk/specialpurpose/passport/README Sun Apr 10 05:59:25 2016
@@ -16,7 +16,7 @@ Here are the steps for a quick start in
 
 2. Login GitHub.
 
-3. Visit Settings->Applications->Developer applications, click "Register new application" button.
+3. Visit Settings->OAuth applications->Developer applications, click "Register new application" button.
 
 4. In "Register a new OAuth application", fill in your OFBiz website information. Here the
 Authorization callback URL: https://YourWebSiteOrInternetIp:8443/ecomseo/githubResponse

Modified: ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/GitHubEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/GitHubEvents.java?rev=1738407&r1=1738406&r2=1738407&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/GitHubEvents.java (original)
+++ ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/GitHubEvents.java Sun Apr 10 05:59:25 2016
@@ -171,12 +171,13 @@ public class GitHubEvents {
         
         try {
             URI uri = new URIBuilder()
-                    .setHost(TokenEndpoint)
+                    .setScheme(TokenEndpoint.substring(0, TokenEndpoint.indexOf(":")))
+                    .setHost(TokenEndpoint.substring(TokenEndpoint.indexOf(":") + 3))
                     .setPath(TokenServiceUri)
                     .setParameter("client_id", clientId)
                     .setParameter("client_secret", secret)
                     .setParameter("code", authorizationCode)
-                    .setParameter("redirect_uri", URLEncoder.encode(returnURI, "UTF-8"))
+                    .setParameter("redirect_uri", returnURI)
                     .build();
             HttpPost postMethod = new HttpPost(uri);
             CloseableHttpClient jsonClient = HttpClients.custom().build();
@@ -188,7 +189,7 @@ public class GitHubEvents {
             // Debug.logInfo("GitHub get access token response code: " + postResponse.getStatusLine().getStatusCode(), module);
             // Debug.logInfo("GitHub get access token response content: " + responseString, module);
             if (postResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                // Debug.logInfo("Json Response from GitHub: " + responseString, module);
+                Debug.logInfo("Json Response from GitHub: " + responseString, module);
                 JSON jsonObject = JSON.from(responseString);
                 JSONToMap jsonMap = new JSONToMap();
                 Map<String, Object> userMap = jsonMap.convert(jsonObject);

Modified: ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/LinkedInEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/LinkedInEvents.java?rev=1738407&r1=1738406&r2=1738407&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/LinkedInEvents.java (original)
+++ ofbiz/trunk/specialpurpose/passport/src/org/ofbiz/passport/event/LinkedInEvents.java Sun Apr 10 05:59:25 2016
@@ -171,13 +171,14 @@ public class LinkedInEvents {
         
         try {
             URI uri = new URIBuilder()
-                    .setHost(TokenEndpoint)
+                    .setScheme(TokenEndpoint.substring(0, TokenEndpoint.indexOf(":")))
+                    .setHost(TokenEndpoint.substring(TokenEndpoint.indexOf(":") + 3))
                     .setPath(TokenServiceUri)
                     .setParameter("client_id", clientId)
                     .setParameter("client_secret", secret)
                     .setParameter("grant_type", "authorization_code")
                     .setParameter("code", authorizationCode)
-                    .setParameter("redirect_uri", URLEncoder.encode(returnURI, "UTF-8"))
+                    .setParameter("redirect_uri", returnURI)
                     .build();
             HttpPost postMethod = new HttpPost(uri);
             CloseableHttpClient jsonClient = HttpClients.custom().build();