From 469c3d855b2b5d4cd74eb1abb51e184eb5974b21 Mon Sep 17 00:00:00 2001 From: "eunok.shin" Date: Fri, 22 Jul 2016 13:28:29 +0900 Subject: [PATCH] change 3rd party(Github) code Change-Id: Iaa28bccc46b8eef8e493cf8e99eebc939bf0db0f Signed-off-by: eunok.shin Reviewed-on: https://gerrit.iotivity.org/gerrit/9589 Tested-by: jenkins-iotivity Reviewed-by: Jee Hyeok Kim --- cloud/account/Github.jar | Bin 2517 -> 2484 bytes .../iotivity/cloud/accountserver/oauth/Github.jar | Bin 2517 -> 0 bytes .../iotivity/cloud/accountserver/oauth/Github.java | 123 +++++++++++++++++++++ 3 files changed, 123 insertions(+) delete mode 100644 cloud/account/src/main/java/org/iotivity/cloud/accountserver/oauth/Github.jar create mode 100644 cloud/account/src/main/java/org/iotivity/cloud/accountserver/oauth/Github.java diff --git a/cloud/account/Github.jar b/cloud/account/Github.jar index c7b8f8a29a06024628407de7b715c22a4aac2102..5d6cce7e0a06b8118bee1894b7448f3896a0242c 100644 GIT binary patch delta 2203 zcmV;M2xRxw6SNZzP)h>@6aWYa2mo4a_K^)<14nH3k#0wSUli9B|6bi?mSudchLqYC zOrnAm7eN$u)dZ0MilV#{5>q<6J1nEi&N?$oBz>f|TGLl-?Yp+=D>Z%C*4TEju}$s! z^XWg-pZfUTnORt20ipKuft@>d&N=s-?|I&T{QI4E0qn=$6s!|yGOcvfFdbvsaAu;( zjG0eGwPezN%x4{2x2AO~YHE3BGTLJ}llg>#fWYQ++O!tUXxVghAaPDlItnTTS{_o+ zKqr5P+#P|+WX905&bW~hi1g3P9daxqn~n=?=rXgmqh*~@EtA(ns1n$wYaPjb?GtVL zn_F926U{CAT2sve6}FzVbSH$30`>b7$>wCLV?u9#+1GNQqpkU%o@mz-TC3LDa^S#z zt$CuYqdk>Kb_l4JZku^4sgLKaObA;9wof`v&W=T+TF%&;cFo?KG^e6@TWVZ!$jBPb z5rOsf4Wj~qE;FTvu^!bbBG@Xhso%)zr}9$?-5S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z^lLxT~w{TiwU%89eAax!%&UQRf#oyV)qL-__tZcRi0t z7EJ3hVm)w;hvgp^Arf}}FgS(zJg811S2gX_i&!~`M zK4q)-q%DC^V?&;)n8b%2%^4S?8N9RP%N(1Ku1^QgvzJ`gKA51rox?lXOZw%7IlV{# z^Q7eU)V2}2dmZKVEJL|783v8LFqI;eTX8w?Zn0gT>n2c#OLtzU*HBJ#nI)h+QtAhB z>*oF6#1pT@9)Qu7W4!V@Nzr+plUxhlRQ#(M4WU8wnM{$D!L#<=R~utM(!Utf|w z6vanS+us%>`^O!wk??i<3?Di@Bfz)nzWYS#D135%%2Ew~dw9^|hp>?4`4R%pIPt-> z=hss(S?mBqb{!7+a}Fje7h2kNve* zBvW^7MKFvylnq{vO= z3B%d4@1>f}*tD2|F^#}1510vbbnexZ58-lFr<94M)z{Ve)iYJf-B*l~3Bv0>+E*vL zd5$)##Bo9goErlP?nw|a{~jM4J{jNG_nogDsqyLaft`jsfQEVz1$=MsvCS)H#}cKJ6)t_ zDL=t1638$dP0uxS;N}hXooNz1yKHH)H28vuGEp}+io7XRv2gL___eU|DXz@bll@Bi z=`(gNM37&>NbECHK*Y_61I4P@s@UvwJsrtWvtdz)96B=dtvChLm@RqXRS}3F-FLff0qY z^XewleY*2zqI9zXYXMcntRD1)?IW|7*5*zRnh~xuY^Idheu+ZjxWbS!gVvRD)ZDvX z!>Utht~rAw=F;voP*kcSq^Xi9P|`;e4fv?e=;)aTM{p0u#g*jP-MSl0lI%CS^{7xd zf9~>E+?~0nTrJP=xz(?n`{1)B_|v%h$Ss}wf}@`W5}5_1bnePL=UX`OIR6Re&`$Dc zSB?ntyT+1RJsH@{mkY@huB=rqu-l$eCw;P4La^*2@D}wY*=GF zAAERSu6lEzo;vBW requestAccessToken(String authCode, + String authServerUrl) { + + HashMap authServerInfo = new HashMap(); + + try { + + OAuthClientRequest request = OAuthClientRequest + .tokenProvider(OAuthProviderType.GITHUB) + .setGrantType(GrantType.AUTHORIZATION_CODE) + .setClientId(client_id).setClientSecret(secret) + .setCode(authCode).buildBodyMessage(); + + OAuthClient oAuthClient = new OAuthClient( + new URLConnectionClient()); + GitHubTokenResponse oAuthResponse = oAuthClient.accessToken(request, + GitHubTokenResponse.class); + + authServerInfo.put(Constants.KEY_ACCESS_TOKEN_GH, + oAuthResponse.getAccessToken()); + + } catch (OAuthSystemException | OAuthProblemException e) { + authServerInfo.put(Constants.ERROR_MESSAGE, e.getMessage()); + } + + return authServerInfo; + } + + @Override + public HashMap requestGetUserInfo(String accessToken, + String apiServerUrl) { + + HashMap authServerInfo = new HashMap(); + + String userInfo = null; + + if (accessToken == null) { + Log.w("accessToken is null!"); + return null; + } + + try { + + OAuthClientRequest request = new OAuthBearerClientRequest( + resource_url).setAccessToken(accessToken) + .buildQueryMessage(); + + OAuthClient oAuthClient = new OAuthClient( + new URLConnectionClient()); + OAuthResourceResponse resourceResponse = oAuthClient.resource( + request, OAuth.HttpMethod.GET, OAuthResourceResponse.class); + + userInfo = resourceResponse.getBody(); + Log.d("userInfo: " + userInfo); + + } catch (OAuthSystemException | OAuthProblemException e) { + authServerInfo.put(Constants.ERROR_MESSAGE, e.getMessage()); + } + + String userIdKey = "login"; + JSONUtil> util = new JSONUtil>(); + HashMap parsedData = util.parseJSON(userInfo, + HashMap.class); + String userId = parsedData.get(userIdKey); + authServerInfo.put(Constants.KEY_USER_ID, userId); + + return authServerInfo; + } +} -- 2.7.4