mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding OAUTH module to UI
This commit is contained in:
parent
b86be8375c
commit
032b5d129a
@ -23,7 +23,7 @@ var uri = request.getRequestURI();
|
|||||||
var uriMatcher = new URIMatcher(String(uri));
|
var uriMatcher = new URIMatcher(String(uri));
|
||||||
|
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
|
|
||||||
function appendQueryParam (url, queryParam , value) {
|
function appendQueryParam (url, queryParam , value) {
|
||||||
if (url.indexOf("?") > 0) {
|
if (url.indexOf("?") > 0) {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ var deviceModule = require("/app/modules/device.js").deviceModule;
|
|||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var userModule = require("/app/modules/user.js").userModule;
|
var userModule = require("/app/modules/user.js").userModule;
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
|
|
||||||
var user = session.get(constants.USER_SESSION_KEY);
|
var user = session.get(constants.USER_SESSION_KEY);
|
||||||
var result;
|
var result;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ var log = new Log("api/device-api.jag");
|
|||||||
var constants = require("/app/modules/constants.js");
|
var constants = require("/app/modules/constants.js");
|
||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
|
|
||||||
var user = session.get(constants.USER_SESSION_KEY);
|
var user = session.get(constants.USER_SESSION_KEY);
|
||||||
var result;
|
var result;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ var uriMatcher = new URIMatcher(String(uri));
|
|||||||
|
|
||||||
var constants = require("/app/modules/constants.js");
|
var constants = require("/app/modules/constants.js");
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
|
|
||||||
if (uriMatcher.match("/{context}/api/invoker/execute/")) {
|
if (uriMatcher.match("/{context}/api/invoker/execute/")) {
|
||||||
var restAPIRequestDetails = request.getContent();
|
var restAPIRequestDetails = request.getContent();
|
||||||
|
|||||||
@ -22,7 +22,7 @@ var uriMatcher = new URIMatcher(String(uri));
|
|||||||
|
|
||||||
var log = new Log("api/operation-api.jag");
|
var log = new Log("api/operation-api.jag");
|
||||||
|
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
|
|
||||||
if (uriMatcher.match("/{context}/api/operation/paginate")) {
|
if (uriMatcher.match("/{context}/api/operation/paginate")) {
|
||||||
|
|||||||
@ -27,8 +27,8 @@ var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
|||||||
var userModule = require("/app/modules/user.js").userModule;
|
var userModule = require("/app/modules/user.js").userModule;
|
||||||
var deviceModule = require("/app/modules/device.js").deviceModule;
|
var deviceModule = require("/app/modules/device.js").deviceModule;
|
||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var apiWrapperUtil = require("/app/modules/token-handlers.js")["handlers"];
|
var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"];
|
||||||
var util = require("/app/modules/util.js").util;
|
var util = require("/app/modules/oauth/util.js").util;
|
||||||
|
|
||||||
var responseProcessor = require('utils').response;
|
var responseProcessor = require('utils').response;
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ deviceModule = function () {
|
|||||||
var utility = require('/app/modules/utility.js').utility;
|
var utility = require('/app/modules/utility.js').utility;
|
||||||
var constants = require('/app/modules/constants.js');
|
var constants = require('/app/modules/constants.js');
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
|
|
||||||
var ArrayList = Packages.java.util.ArrayList;
|
var ArrayList = Packages.java.util.ArrayList;
|
||||||
var Properties = Packages.java.util.Properties;
|
var Properties = Packages.java.util.Properties;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ var groupModule = {};
|
|||||||
var constants = require('/app/modules/constants.js');
|
var constants = require('/app/modules/constants.js');
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
|
|
||||||
var groupServiceEndpoint = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/groups";
|
var groupServiceEndpoint = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/groups";
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ var onFail;
|
|||||||
var constants = require("/app/modules/constants.js");
|
var constants = require("/app/modules/constants.js");
|
||||||
onSuccess = function (context) {
|
onSuccess = function (context) {
|
||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var apiWrapperUtil = require("/app/modules/token-handlers.js")["handlers"];
|
var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"];
|
||||||
if (context.input.samlToken) {
|
if (context.input.samlToken) {
|
||||||
apiWrapperUtil.setupAccessTokenPairBySamlGrantType(context.input.username, context.input.samlToken);
|
apiWrapperUtil.setupAccessTokenPairBySamlGrantType(context.input.username, context.input.samlToken);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -23,9 +23,9 @@
|
|||||||
* -----------------------------------------------------
|
* -----------------------------------------------------
|
||||||
*/
|
*/
|
||||||
var handlers = function () {
|
var handlers = function () {
|
||||||
var log = new Log("/app/modules/token-handlers.js");
|
var log = new Log("/app/modules/oauth/token-handlers.js");
|
||||||
|
|
||||||
var tokenUtil = require("/app/modules/util.js")["util"];
|
var tokenUtil = require("/app/modules/oauth/util.js")["util"];
|
||||||
var constants = require("/app/modules/constants.js");
|
var constants = require("/app/modules/constants.js");
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
|
|
||||||
@ -34,26 +34,26 @@ var handlers = function () {
|
|||||||
|
|
||||||
privateMethods.setUpEncodedTenantBasedClientAppCredentials = 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/oauth/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 - setUpEncodedTenantBasedClientAppCredentials(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/oauth/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 - setUpEncodedTenantBasedClientAppCredentials(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/oauth/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 - setUpEncodedTenantBasedClientAppCredentials(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/oauth/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 - setUpEncodedTenantBasedClientAppCredentials(x)");
|
"to obtain such credentials - setUpEncodedTenantBasedClientAppCredentials(x)");
|
||||||
} else {
|
} else {
|
||||||
@ -70,14 +70,14 @@ var handlers = function () {
|
|||||||
|
|
||||||
publicMethods.setupAccessTokenPairByPasswordGrantType = function (username, password) {
|
publicMethods.setupAccessTokenPairByPasswordGrantType = function (username, password) {
|
||||||
if (!username || !password) {
|
if (!username || !password) {
|
||||||
throw new Error("{/app/modules/token-handlers.js} Could not set up access token pair by " +
|
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair by " +
|
||||||
"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.setUpEncodedTenantBasedClientAppCredentials(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/oauth/token-handlers.js} Could not set up access token pair by " +
|
||||||
"password grant type. Encoded client credentials are " +
|
"password grant type. Encoded client credentials are " +
|
||||||
"missing - setupAccessTokenPairByPasswordGrantType(x, y)");
|
"missing - setupAccessTokenPairByPasswordGrantType(x, y)");
|
||||||
} else {
|
} else {
|
||||||
@ -92,7 +92,7 @@ var handlers = function () {
|
|||||||
getAccessTokenByPasswordGrantType(username,
|
getAccessTokenByPasswordGrantType(username,
|
||||||
encodeURIComponent(password), encodedClientCredentials, stringOfScopes);
|
encodeURIComponent(password), encodedClientCredentials, stringOfScopes);
|
||||||
if (!accessTokenPair) {
|
if (!accessTokenPair) {
|
||||||
throw new Error("{/app/modules/token-handlers.js} Could not set up access " +
|
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access " +
|
||||||
"token pair by password grant type. Error in token " +
|
"token pair by password grant type. Error in token " +
|
||||||
"retrieval - setupAccessTokenPairByPasswordGrantType(x, y)");
|
"retrieval - setupAccessTokenPairByPasswordGrantType(x, y)");
|
||||||
} else {
|
} else {
|
||||||
@ -105,14 +105,14 @@ var handlers = function () {
|
|||||||
|
|
||||||
publicMethods.setupAccessTokenPairBySamlGrantType = function (username, samlToken) {
|
publicMethods.setupAccessTokenPairBySamlGrantType = function (username, samlToken) {
|
||||||
if (!username || !samlToken) {
|
if (!username || !samlToken) {
|
||||||
throw new Error("{/app/modules/token-handlers.js} Could not set up access token pair by " +
|
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair by " +
|
||||||
"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.setUpEncodedTenantBasedClientAppCredentials(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/oauth/token-handlers.js} Could not set up access token pair " +
|
||||||
"by saml grant type. Encoded client credentials are " +
|
"by saml grant type. Encoded client credentials are " +
|
||||||
"missing - setupAccessTokenPairByPasswordGrantType(x, y)");
|
"missing - setupAccessTokenPairByPasswordGrantType(x, y)");
|
||||||
} else {
|
} else {
|
||||||
@ -121,7 +121,7 @@ var handlers = function () {
|
|||||||
accessTokenPair = tokenUtil.
|
accessTokenPair = tokenUtil.
|
||||||
getAccessTokenBySAMLGrantType(samlToken, encodedClientCredentials, "PRODUCTION");
|
getAccessTokenBySAMLGrantType(samlToken, encodedClientCredentials, "PRODUCTION");
|
||||||
if (!accessTokenPair) {
|
if (!accessTokenPair) {
|
||||||
throw new Error("{/app/modules/token-handlers.js} Could not set up access token " +
|
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token " +
|
||||||
"pair by password grant type. Error in token " +
|
"pair by password grant type. Error in token " +
|
||||||
"retrieval - setupAccessTokenPairByPasswordGrantType(x, y)");
|
"retrieval - setupAccessTokenPairByPasswordGrantType(x, y)");
|
||||||
} else {
|
} else {
|
||||||
@ -137,14 +137,14 @@ var handlers = function () {
|
|||||||
// accessTokenPair includes current access token as well as current refresh token
|
// accessTokenPair includes current access token as well as current refresh token
|
||||||
var encodedClientCredentials = session.get(constants["ENCODED_CLIENT_KEYS_IDENTIFIER"]);
|
var encodedClientCredentials = session.get(constants["ENCODED_CLIENT_KEYS_IDENTIFIER"]);
|
||||||
if (!accessTokenPair || !encodedClientCredentials) {
|
if (!accessTokenPair || !encodedClientCredentials) {
|
||||||
throw new Error("{/app/modules/token-handlers.js} Error in refreshing tokens. Either the access " +
|
throw new Error("{/app/modules/oauth/token-handlers.js} Error in refreshing tokens. Either the access " +
|
||||||
"token pair, encoded client credentials or both input are not found under " +
|
"token pair, encoded client credentials or both input are not found under " +
|
||||||
"session context - refreshAccessToken()");
|
"session context - refreshAccessToken()");
|
||||||
} else {
|
} else {
|
||||||
var newTokenPair = tokenUtil.
|
var newTokenPair = tokenUtil.
|
||||||
getNewAccessTokenByRefreshToken(accessTokenPair["refreshToken"], encodedClientCredentials);
|
getNewAccessTokenByRefreshToken(accessTokenPair["refreshToken"], encodedClientCredentials);
|
||||||
if (!newTokenPair) {
|
if (!newTokenPair) {
|
||||||
log.error("{/app/modules/token-handlers.js} Error in refreshing access token. Unable to update " +
|
log.error("{/app/modules/oauth/token-handlers.js} Error in refreshing access token. Unable to update " +
|
||||||
"session context with new access token pair - refreshAccessToken()");
|
"session context with new access token pair - refreshAccessToken()");
|
||||||
} else {
|
} else {
|
||||||
session.put(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"], stringify(newTokenPair));
|
session.put(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"], stringify(newTokenPair));
|
||||||
@ -24,7 +24,7 @@
|
|||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
var invokers = function () {
|
var invokers = function () {
|
||||||
var log = new Log("/app/modules/token-protected-service-invokers.js");
|
var log = new Log("/app/modules/oauth/token-protected-service-invokers.js");
|
||||||
|
|
||||||
var publicXMLHTTPInvokers = {};
|
var publicXMLHTTPInvokers = {};
|
||||||
var publicHTTPClientInvokers = {};
|
var publicHTTPClientInvokers = {};
|
||||||
@ -38,7 +38,7 @@ var invokers = function () {
|
|||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var constants = require("/app/modules/constants.js");
|
var constants = require("/app/modules/constants.js");
|
||||||
var userModule = require("/app/modules/user.js")["userModule"];
|
var userModule = require("/app/modules/user.js")["userModule"];
|
||||||
var tokenUtil = require("/app/modules/token-handlers.js")["handlers"];
|
var tokenUtil = require("/app/modules/oauth/token-handlers.js")["handlers"];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method reads the token pair from the session and return the access token.
|
* This method reads the token pair from the session and return the access token.
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var util = function () {
|
var util = function () {
|
||||||
var log = new Log("/app/modules/util.js");
|
var log = new Log("/app/modules/oauth/util.js");
|
||||||
|
|
||||||
var privateMethods = {};
|
var privateMethods = {};
|
||||||
var publicMethods = {};
|
var publicMethods = {};
|
||||||
@ -64,11 +64,11 @@ var util = function () {
|
|||||||
dynamicClientAppCredentials["clientId"] = responsePayload["client_id"];
|
dynamicClientAppCredentials["clientId"] = responsePayload["client_id"];
|
||||||
dynamicClientAppCredentials["clientSecret"] = responsePayload["client_secret"];
|
dynamicClientAppCredentials["clientSecret"] = responsePayload["client_secret"];
|
||||||
} else if (xhr["status"] == 400) {
|
} else if (xhr["status"] == 400) {
|
||||||
log.error("{/app/modules/util.js - getDynamicClientAppCredentials()} " +
|
log.error("{/app/modules/oauth/util.js - getDynamicClientAppCredentials()} " +
|
||||||
"Bad request. Invalid data provided as dynamic client application properties.");
|
"Bad request. Invalid data provided as dynamic client application properties.");
|
||||||
dynamicClientAppCredentials = null;
|
dynamicClientAppCredentials = null;
|
||||||
} else {
|
} else {
|
||||||
log.error("{/app/modules/util.js - getDynamicClientAppCredentials()} " +
|
log.error("{/app/modules/oauth/util.js - getDynamicClientAppCredentials()} " +
|
||||||
"Error in retrieving dynamic client credentials.");
|
"Error in retrieving dynamic client credentials.");
|
||||||
dynamicClientAppCredentials = null;
|
dynamicClientAppCredentials = null;
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ var util = function () {
|
|||||||
|
|
||||||
publicMethods.getAccessTokenByPasswordGrantType = function (username, password, encodedClientAppCredentials, scopes) {
|
publicMethods.getAccessTokenByPasswordGrantType = function (username, password, encodedClientAppCredentials, scopes) {
|
||||||
if (!username || !password || !encodedClientAppCredentials || !scopes) {
|
if (!username || !password || !encodedClientAppCredentials || !scopes) {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving access token by password " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving access token by password " +
|
||||||
"grant type. No username, password, encoded client app credentials or scopes are " +
|
"grant type. No username, password, encoded client app credentials or scopes are " +
|
||||||
"found - getAccessTokenByPasswordGrantType(a, b, c, d)");
|
"found - getAccessTokenByPasswordGrantType(a, b, c, d)");
|
||||||
return null;
|
return null;
|
||||||
@ -101,7 +101,7 @@ var util = function () {
|
|||||||
tokenPair["refreshToken"] = responsePayload["refresh_token"];
|
tokenPair["refreshToken"] = responsePayload["refresh_token"];
|
||||||
return tokenPair;
|
return tokenPair;
|
||||||
} else {
|
} else {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving access token by password " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving access token by password " +
|
||||||
"grant type - getAccessTokenByPasswordGrantType(a, b, c, d)");
|
"grant type - getAccessTokenByPasswordGrantType(a, b, c, d)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ var util = function () {
|
|||||||
|
|
||||||
publicMethods.getAccessTokenBySAMLGrantType = function (assertion, encodedClientAppCredentials, scopes) {
|
publicMethods.getAccessTokenBySAMLGrantType = function (assertion, encodedClientAppCredentials, scopes) {
|
||||||
if (!assertion || !encodedClientAppCredentials || !scopes) {
|
if (!assertion || !encodedClientAppCredentials || !scopes) {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving access token by saml " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving access token by saml " +
|
||||||
"grant type. No assertion, encoded client app credentials or scopes are " +
|
"grant type. No assertion, encoded client app credentials or scopes are " +
|
||||||
"found - getAccessTokenBySAMLGrantType(x, y, z)");
|
"found - getAccessTokenBySAMLGrantType(x, y, z)");
|
||||||
return null;
|
return null;
|
||||||
@ -127,7 +127,7 @@ var util = function () {
|
|||||||
|
|
||||||
var extractedAssertion;
|
var extractedAssertion;
|
||||||
if (assertionStartIndex == -1 || assertionEndIndex == -1) {
|
if (assertionStartIndex == -1 || assertionEndIndex == -1) {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving access token by saml grant type. " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving access token by saml grant type. " +
|
||||||
"Issue in assertion format - getAccessTokenBySAMLGrantType(x, y, z)");
|
"Issue in assertion format - getAccessTokenBySAMLGrantType(x, y, z)");
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
@ -153,7 +153,7 @@ var util = function () {
|
|||||||
tokenPair["refreshToken"] = responsePayload["refresh_token"];
|
tokenPair["refreshToken"] = responsePayload["refresh_token"];
|
||||||
return tokenPair;
|
return tokenPair;
|
||||||
} else {
|
} else {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving access token by password " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving access token by password " +
|
||||||
"grant type - getAccessTokenBySAMLGrantType(x, y, z)");
|
"grant type - getAccessTokenBySAMLGrantType(x, y, z)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ var util = function () {
|
|||||||
|
|
||||||
publicMethods.getNewAccessTokenByRefreshToken = function (refreshToken, encodedClientAppCredentials, scopes) {
|
publicMethods.getNewAccessTokenByRefreshToken = function (refreshToken, encodedClientAppCredentials, scopes) {
|
||||||
if (!refreshToken || !encodedClientAppCredentials) {
|
if (!refreshToken || !encodedClientAppCredentials) {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving new access token by current " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving new access token by current " +
|
||||||
"refresh token. No refresh token or encoded client app credentials are " +
|
"refresh token. No refresh token or encoded client app credentials are " +
|
||||||
"found - getNewAccessTokenByRefreshToken(x, y, z)");
|
"found - getNewAccessTokenByRefreshToken(x, y, z)");
|
||||||
return null;
|
return null;
|
||||||
@ -187,7 +187,7 @@ var util = function () {
|
|||||||
tokenPair["refreshToken"] = responsePayload["refresh_token"];
|
tokenPair["refreshToken"] = responsePayload["refresh_token"];
|
||||||
return tokenPair;
|
return tokenPair;
|
||||||
} else {
|
} else {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving new access token by " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving new access token by " +
|
||||||
"current refresh token - getNewAccessTokenByRefreshToken(x, y, z)");
|
"current refresh token - getNewAccessTokenByRefreshToken(x, y, z)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ var util = function () {
|
|||||||
|
|
||||||
publicMethods.getAccessTokenByJWTGrantType = function (clientAppCredentials) {
|
publicMethods.getAccessTokenByJWTGrantType = function (clientAppCredentials) {
|
||||||
if (!clientAppCredentials) {
|
if (!clientAppCredentials) {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving new access token by current refresh token. " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving new access token by current refresh token. " +
|
||||||
"No client app credentials are found as input - getAccessTokenByJWTGrantType(x)");
|
"No client app credentials are found as input - getAccessTokenByJWTGrantType(x)");
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
@ -212,13 +212,13 @@ var util = function () {
|
|||||||
|
|
||||||
publicMethods.getTenantBasedClientAppCredentials = function (username, jwtToken) {
|
publicMethods.getTenantBasedClientAppCredentials = function (username, jwtToken) {
|
||||||
if (!username || !jwtToken) {
|
if (!username || !jwtToken) {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving tenant based client app " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving tenant based client app " +
|
||||||
"credentials. No username or jwt token is found as input - getTenantBasedClientAppCredentials(x, y)");
|
"credentials. No username or jwt token is found as input - getTenantBasedClientAppCredentials(x, y)");
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
var tenantDomain = carbon.server.tenantDomain({username: username});
|
var tenantDomain = carbon.server.tenantDomain({username: username});
|
||||||
if (!tenantDomain) {
|
if (!tenantDomain) {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving tenant based client application " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving tenant based client application " +
|
||||||
"credentials. Unable to obtain a valid tenant domain for provided " +
|
"credentials. Unable to obtain a valid tenant domain for provided " +
|
||||||
"username - getTenantBasedClientAppCredentials(x, y)");
|
"username - getTenantBasedClientAppCredentials(x, y)");
|
||||||
return null;
|
return null;
|
||||||
@ -249,7 +249,7 @@ var util = function () {
|
|||||||
setCachedTenantBasedClientAppCredentials(tenantDomain, tenantBasedClientAppCredentials);
|
setCachedTenantBasedClientAppCredentials(tenantDomain, tenantBasedClientAppCredentials);
|
||||||
return tenantBasedClientAppCredentials;
|
return tenantBasedClientAppCredentials;
|
||||||
} else {
|
} else {
|
||||||
log.error("{/app/modules/util.js} Error in retrieving tenant based client " +
|
log.error("{/app/modules/oauth/util.js} Error in retrieving tenant based client " +
|
||||||
"application credentials from API Manager - getTenantBasedClientAppCredentials(x, y)");
|
"application credentials from API Manager - getTenantBasedClientAppCredentials(x, y)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ var operationModule = function () {
|
|||||||
var utility = require('/app/modules/utility.js').utility;
|
var utility = require('/app/modules/utility.js').utility;
|
||||||
var constants = require('/app/modules/constants.js');
|
var constants = require('/app/modules/constants.js');
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];;
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];;
|
||||||
|
|
||||||
var publicMethods = {};
|
var publicMethods = {};
|
||||||
var privateMethods = {};
|
var privateMethods = {};
|
||||||
|
|||||||
@ -26,7 +26,7 @@ policyModule = function () {
|
|||||||
var constants = require('/app/modules/constants.js');
|
var constants = require('/app/modules/constants.js');
|
||||||
var utility = require("/app/modules/utility.js")["utility"];
|
var utility = require("/app/modules/utility.js")["utility"];
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
|
|
||||||
var publicMethods = {};
|
var publicMethods = {};
|
||||||
var privateMethods = {};
|
var privateMethods = {};
|
||||||
|
|||||||
@ -25,7 +25,7 @@ var userModule = function () {
|
|||||||
var constants = require("/app/modules/constants.js");
|
var constants = require("/app/modules/constants.js");
|
||||||
var utility = require("/app/modules/utility.js")["utility"];
|
var utility = require("/app/modules/utility.js")["utility"];
|
||||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||||
var serviceInvokers = require("/app/modules/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
|
|
||||||
/* Initializing user manager */
|
/* Initializing user manager */
|
||||||
var carbon = require("carbon");
|
var carbon = require("carbon");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user