From 13e2381293d614628fe77958eceb3be9a4535fe8 Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 19 Aug 2016 10:50:12 +0530 Subject: [PATCH] Updating OAuth Utils - UI --- .../app/modules/oauth/token-handler-utils.js | 22 +++++++++---------- .../app/modules/oauth/token-handlers.js | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js index ba7827173b..f31e72622c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js @@ -84,7 +84,7 @@ var utils = function () { if (!username || !jwtToken) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + "based client app credentials. No username or jwt token is found " + - "as input - getTenantBasedClientAppCredentials(x, y)"); + "as input - getTenantBasedClientAppCredentials(x, y)"); return null; } else { //noinspection JSUnresolvedFunction, JSUnresolvedVariable @@ -92,7 +92,7 @@ var utils = function () { if (!tenantDomain) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + "based client application credentials. Unable to obtain a valid tenant domain for provided " + - "username - getTenantBasedClientAppCredentials(x, y)"); + "username - getTenantBasedClientAppCredentials(x, y)"); return null; } else { var cachedTenantBasedClientAppCredentials = privateMethods. @@ -104,7 +104,7 @@ var utils = function () { var applicationName = "webapp_" + tenantDomain; var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"] ["apiManagerClientAppRegistrationServiceURL"] + - "?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName; + "?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName; var xhr = new XMLHttpRequest(); xhr.open("POST", requestURL, false); @@ -123,7 +123,7 @@ var utils = function () { } else { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + "based client application credentials from API " + - "Manager - getTenantBasedClientAppCredentials(x, y)"); + "Manager - getTenantBasedClientAppCredentials(x, y)"); return null; } } @@ -152,11 +152,11 @@ var utils = function () { } }; - publicMethods["getTokenPairByPasswordGrantType"] = function (username, password, encodedClientAppCredentials, scopes) { + publicMethods["getTokenPairAndScopesByPasswordGrantType"] = function (username, password, encodedClientAppCredentials, scopes) { if (!username || !password || !encodedClientAppCredentials || !scopes) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by password " + "grant type. No username, password, encoded client app credentials or scopes are " + - "found - getTokenPairByPasswordGrantType(a, b, c, d)"); + "found - getTokenPairAndScopesByPasswordGrantType(a, b, c, d)"); return null; } else { // calling oauth provider token service endpoint @@ -179,17 +179,17 @@ var utils = function () { return tokenData; } else { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token " + - "by password grant type - getTokenPairByPasswordGrantType(a, b, c, d)"); + "by password grant type - getTokenPairAndScopesByPasswordGrantType(a, b, c, d)"); return null; } } }; - publicMethods["getTokenPairBySAMLGrantType"] = function (assertion, encodedClientAppCredentials, scopes) { + publicMethods["getTokenPairAndScopesBySAMLGrantType"] = function (assertion, encodedClientAppCredentials, scopes) { if (!assertion || !encodedClientAppCredentials || !scopes) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by saml " + "grant type. No assertion, encoded client app credentials or scopes are " + - "found - getTokenPairBySAMLGrantType(x, y, z)"); + "found - getTokenPairAndScopesBySAMLGrantType(x, y, z)"); return null; } else { var assertionXML = publicMethods.decode(assertion); @@ -205,7 +205,7 @@ var utils = function () { var extractedAssertion; if (assertionStartIndex == -1 || assertionEndIndex == -1) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access " + - "token by saml grant type. Issue in assertion format - getTokenPairBySAMLGrantType(x, y, z)"); + "token by saml grant type. Issue in assertion format - getTokenPairAndScopesBySAMLGrantType(x, y, z)"); return null; } else { extractedAssertion = assertionXML. @@ -232,7 +232,7 @@ var utils = function () { return tokenData; } else { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token " + - "by password grant type - getTokenPairBySAMLGrantType(x, y, z)"); + "by password grant type - getTokenPairAndScopesBySAMLGrantType(x, y, z)"); return null; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js index fc1016eb85..8a41429ce6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js @@ -53,7 +53,7 @@ var handlers = function () { stringOfScopes += entry + " "; }); tokenData = tokenUtil. - getTokenPairByPasswordGrantType(username, + getTokenPairAndScopesByPasswordGrantType(username, encodeURIComponent(password), encodedClientAppCredentials, stringOfScopes); if (!tokenData) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up " + @@ -90,7 +90,7 @@ var handlers = function () { var tokenData; // accessTokenPair will include current access token as well as current refresh token tokenData = tokenUtil. - getTokenPairBySAMLGrantType(samlToken, encodedClientAppCredentials, "PRODUCTION"); + getTokenPairAndScopesBySAMLGrantType(samlToken, encodedClientAppCredentials, "PRODUCTION"); if (!tokenData) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up token " + "pair by password grant type. Error in token " +