Refactoring OAuth utilities at UI Layer

revert-70aa11f8
dilanua 9 years ago
parent 70074e2f3e
commit b86be8375c

@ -32,30 +32,30 @@ var handlers = function () {
var privateMethods = {}; var privateMethods = {};
var publicMethods = {}; var publicMethods = {};
privateMethods.setUpEncodedTenantBasedClientCredentials = function (username) { privateMethods.setUpEncodedTenantBasedClientAppCredentials = function (username) {
if (!username) { if (!username) {
throw new Error("{/app/modules/token-handlers.js} Could not set up encoded tenant based " + throw new Error("{/app/modules/token-handlers.js} Could not set up encoded tenant based " +
"client credentials to session context. No username is found as " + "client credentials to session context. No username is found as " +
"input - setUpEncodedTenantBasedClientCredentials(x)"); "input - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials(); var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials();
if (!dynamicClientAppCredentials) { if (!dynamicClientAppCredentials) {
throw new Error("{/app/modules/token-handlers.js} Could not set up encoded tenant based " + throw new Error("{/app/modules/token-handlers.js} Could not set up encoded tenant based " +
"client credentials to session context as the server is unable to obtain " + "client credentials to session context as the server is unable to obtain " +
"dynamic client credentials - setUpEncodedTenantBasedClientCredentials(x)"); "dynamic client credentials - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
var jwtToken = tokenUtil.getAccessTokenByJWTGrantType(dynamicClientAppCredentials); var jwtToken = tokenUtil.getAccessTokenByJWTGrantType(dynamicClientAppCredentials);
if (!jwtToken) { if (!jwtToken) {
throw new Error("{/app/modules/token-handlers.js} Could not set up encoded tenant based " + throw new Error("{/app/modules/token-handlers.js} Could not set up encoded tenant based " +
"client credentials to session context as the server is unable to obtain " + "client credentials to session context as the server is unable to obtain " +
"a jwt token - setUpEncodedTenantBasedClientCredentials(x)"); "a jwt token - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
var tenantBasedClientCredentials = tokenUtil. var tenantBasedClientCredentials = tokenUtil.
getTenantBasedClientAppCredentials(username, jwtToken); getTenantBasedClientAppCredentials(username, jwtToken);
if (!tenantBasedClientCredentials) { if (!tenantBasedClientCredentials) {
throw new Error("{/app/modules/token-handlers.js} Could not set up encoded tenant " + throw new Error("{/app/modules/token-handlers.js} Could not set up encoded tenant " +
"based client credentials to session context as the server is unable " + "based client credentials to session context as the server is unable " +
"to obtain such credentials - setUpEncodedTenantBasedClientCredentials(x)"); "to obtain such credentials - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
var encodedTenantBasedClientCredentials = var encodedTenantBasedClientCredentials =
tokenUtil.encode(tenantBasedClientCredentials["clientId"] + ":" + tokenUtil.encode(tenantBasedClientCredentials["clientId"] + ":" +
@ -74,7 +74,7 @@ var handlers = function () {
"password grant type. Either username, password or both are missing as " + "password grant type. Either username, password or both are missing as " +
"input - setupAccessTokenPairByPasswordGrantType(x, y)"); "input - setupAccessTokenPairByPasswordGrantType(x, y)");
} else { } else {
privateMethods.setUpEncodedTenantBasedClientCredentials(username); privateMethods.setUpEncodedTenantBasedClientAppCredentials(username);
var encodedClientCredentials = session.get(constants["ENCODED_CLIENT_KEYS_IDENTIFIER"]); var encodedClientCredentials = session.get(constants["ENCODED_CLIENT_KEYS_IDENTIFIER"]);
if (!encodedClientCredentials) { if (!encodedClientCredentials) {
throw new Error("{/app/modules/token-handlers.js} Could not set up access token pair by " + throw new Error("{/app/modules/token-handlers.js} Could not set up access token pair by " +
@ -109,7 +109,7 @@ var handlers = function () {
"saml grant type. Either username, samlToken or both are missing as " + "saml grant type. Either username, samlToken or both are missing as " +
"input - setupAccessTokenPairByPasswordGrantType(x, y)"); "input - setupAccessTokenPairByPasswordGrantType(x, y)");
} else { } else {
privateMethods.setUpEncodedTenantBasedClientCredentials(username); privateMethods.setUpEncodedTenantBasedClientAppCredentials(username);
var encodedClientCredentials = session.get(constants["ENCODED_CLIENT_KEYS_IDENTIFIER"]); var encodedClientCredentials = session.get(constants["ENCODED_CLIENT_KEYS_IDENTIFIER"]);
if (!encodedClientCredentials) { if (!encodedClientCredentials) {
throw new Error("{/app/modules/token-handlers.js} Could not set up access token pair " + throw new Error("{/app/modules/token-handlers.js} Could not set up access token pair " +

Loading…
Cancel
Save