From c001d96877029ac64e6eb8a16be5f2ea9eae18a7 Mon Sep 17 00:00:00 2001 From: Lahiru Madushanka Date: Sat, 5 Aug 2017 14:53:44 +0530 Subject: [PATCH] Fix for 1261 (#884) --- .pom.xml.swp | Bin 0 -> 16384 bytes .../jaggeryapps/devicemgt/api/device-api.jag | 1 + .../oauth/token-protected-service-invokers.js | 8 +++++--- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .pom.xml.swp diff --git a/.pom.xml.swp b/.pom.xml.swp new file mode 100644 index 0000000000000000000000000000000000000000..f89e01a40fab8e125782d12895c2d487b7de7fcc GIT binary patch literal 16384 zcmeHNON=8&8E%#&FhEE|Bm@!?wGJpVV!GO%nPjs|uY;N0C01s}!+3T#D|Qsx?XstL z?Cz$k+a3d16cOg1 zx4WGYFZDwypcHsz6u4EJpDV>%{m#Nsa>tv_zA|A|6s3StKq;UUPzopolmbctrGQf4 zP$&@kZ`D4Ao*t3CJtx0kmHWOfKTGoZ`5gaW$v+^ke!$2L z+K+$b_)q8fe@Z^BXr9UOFXq~RmmF{!{~wZnzifYyS5-5%T z*IfJE9RGsk)Bb-y$Nxq0ss6X$G#dZUl27O5VvhflTVe zR`Pd9{;?b{FRL%5fKosypcGIFC`xfA7)XI+mj{;TT z2yg}U`453l0Pg|b4qV5Xz>k5;zy@#s{E*K<6gnM#xR+7#))B>9N7xhHuIIkI;m{-=!o7_BG2A{4BSa6-EK$M$&Wf3YyNg zL*@#dvA(6*u-UxdrGBW}9S5DAz?gL{r=xSBKrn&1XGP)WjdjOnBKteG6~?dAP0&c6 zH7wuPMN=4r@bm(`6R@}X&niwW&w7s>eXi>_o`j?>9%tcPjD=80#T!{=#{ z-c!`;E0xvy{k8R+J{Xm~Wwjl*UB-K}LfG_Y5+(B|Z{$tec&}#2#QH{)x|mniIVbN) z3+QPvp7`N4O*8$#y98kg-syGu$$}KCYxS5*E%bMjQHW-&)|QPpLLsp{vCW+w>wdpa z`}48gT(MX(9$a3k!?A1Wj>|*KwHds)bArbgmptS!Oze*P-i?vHx)ZzTy@iL04;AS) zZx-UUD{er9Tqcpo-vs%REaA0fmopk)=03AU?j;?|ZAZ9;k+z3$Bv1b^ZR@*>!ThvbI)PS+Ab1liC_ttgW1?u2*X-_;rRd%a1f2 z9tKV$5?f%`_=v+t3_KTui2cvHxTkUwun$E}0N2KV;BJB&g4O6S2+cJwLi$iRYn9BLT*CxykZCcm1v#;WnRkk)Gnn(;21G zY%@bDoeo(OKAfyE)OS6s7ESz}(#-p?>4?lECkrK7ED-$j@|uwUWFZP$`n`qw%9^PE zb=2fv07U(tKL7j<>it!q29$uSsPTUT{1o^MFb}*L_%-VLuL2Bs8}KaRJOO+i_!=PM zejZRCrGQdEDWDWk3Md7X0!jg;fKosyFjfJaWh4g&!$YIMLlGVBoc0oY%%rrxWc943 zXH&lA_~kH&@MvWWq2ZWJSfUE&A(drOd7hT$XoX?Z-QI!9h_IJ4&ZIz;%o@P>-#EisdX^}npghD(VktZ5`PC2t99DNLu2eRq%!|c&gDZbV#VIn8-!Ldg2 dF*DYD;95RTqSC-(VI0%NF+uOxNZ7og_CI7u%0&PG literal 0 HcmV?d00001 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag index e49a8afba2..84a9b98bdc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag @@ -45,6 +45,7 @@ if (!user) { } else { queryString = "?" + queryString; } + var deviceType = request.getParameter("deviceType"); // need a better solution here deviceTypeConfig = utility.getDeviceTypeConfig(deviceType); if (deviceTypeConfig && deviceTypeConfig.deviceType.downloadAgentUri) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js index efcb3c6cae..cfde7134b6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js @@ -39,7 +39,7 @@ var invokers = function () { var constants = require("/app/modules/constants.js"); var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var tokenUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; - + var tokenHandler = require("/app/modules/oauth/token-handler-utils.js")["utils"]; /** * This method reads the token pair from the session and return the access token. * If the token pair is not set in the session, this will return null. @@ -259,10 +259,12 @@ var invokers = function () { var wsRequest = new ws.WSRequest(); var options = []; if (devicemgtProps["isOAuthEnabled"]) { - var accessToken = privateMethods.getAccessToken(); + var adminUsername = devicemgtProps["adminUser"]; + var accessToken = tokenHandler.getJwtToken(adminUsername); + var decoded = tokenHandler.encode(accessToken); if (accessToken) { var authenticationHeaderName = String(constants["AUTHORIZATION_HEADER"]); - var authenticationHeaderValue = String(constants["BEARER_PREFIX"] + accessToken); + var authenticationHeaderValue = String(constants["BEARER_PREFIX"] + decoded); var headers = []; var oAuthAuthenticationData = {}; oAuthAuthenticationData.name = authenticationHeaderName;