Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
privateMethods["initiateWSRequest"] = function (action, endpoint, successCallback,
errorCallback, soapVersion, payload) {
var ws = require("ws");
//noinspection JSUnresolvedFunction
var wsRequest = new ws.WSRequest();
var options = [];
if (devicemgtProps["isOAuthEnabled"]) {
var accessToken = privateMethods.getAccessToken();
if (accessToken) {
var authenticationHeaderName = String(constants["AUTHORIZATION_HEADER"]);
var authenticationHeaderValue = String(constants["BEARER_PREFIX"] + accessToken);
var headers = [];
var oAuthAuthenticationData = {};
oAuthAuthenticationData.name = authenticationHeaderName;
oAuthAuthenticationData.value = authenticationHeaderValue;
headers.push(oAuthAuthenticationData);
options.HTTPHeaders = headers;
} else {
response.sendRedirect(devicemgtProps["appContext"] + "login");
}
}
function initiateWSRequest(action, endpoint, payload, successCallback, errorCallback, soapVersion) {
var ws = require('ws');
var wsRequest = new ws.WSRequest();
var options = new Array();
if (IS_OAUTH_ENABLED) {
var accessToken = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER).accessToken;
if (!(!accessToken)) {
var authenticationHeaderName = String(constants.AUTHORIZATION_HEADER);
var authenticationHeaderValue = String(constants.BEARER_PREFIX + accessToken);
var headers = [];
var oAuthAuthenticationData = {};
oAuthAuthenticationData.name = authenticationHeaderName;
oAuthAuthenticationData.value = authenticationHeaderValue;
headers.push(oAuthAuthenticationData);
options.HTTPHeaders = headers;
}
}
options.useSOAP = soapVersion;
options.useWSA = constants.WEB_SERVICE_ADDRESSING_VERSION;
function initiateWSRequest(action, endpoint, payload, successCallback, errorCallback, soapVersion) {
var ws = require('ws');
var wsRequest = new ws.WSRequest();
var options = new Array();
if (IS_OAUTH_ENABLED) {
var accessToken = getAccessToken();
if (!(!accessToken)) {
var authenticationHeaderName = String(constants.AUTHORIZATION_HEADER);
var authenticationHeaderValue = String(constants.BEARER_PREFIX + accessToken);
var headers = [];
var oAuthAuthenticationData = {};
oAuthAuthenticationData.name = authenticationHeaderName;
oAuthAuthenticationData.value = authenticationHeaderValue;
headers.push(oAuthAuthenticationData);
options.HTTPHeaders = headers;
}
}
options.useSOAP = soapVersion;
options.useWSA = constants.WEB_SERVICE_ADDRESSING_VERSION;
function initiateWSRequest(action, endpoint, payload, successCallback, errorCallback, soapVersion) {
var ws = require('ws');
var wsRequest = new ws.WSRequest();
var options = new Array();
if (IS_OAUTH_ENABLED) {
var accessToken = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER).accessToken;
if (!(!accessToken)) {
var authenticationHeaderName = String(constants.AUTHORIZATION_HEADER);
var authenticationHeaderValue = String(constants.BEARER_PREFIX + accessToken);
var headers = [];
var oAuthAuthenticationData = {};
oAuthAuthenticationData.name = authenticationHeaderName;
oAuthAuthenticationData.value = authenticationHeaderValue;
headers.push(oAuthAuthenticationData);
options.HTTPHeaders = headers;
}
}
options.useSOAP = soapVersion;
options.useWSA = constants.WEB_SERVICE_ADDRESSING_VERSION;
(function() {
var log = new Log();
var ws = require('ws');
var request = new ws.WSRequest();
var options = new Array();
this.urlWs = "https://localhost:9443/services/UserAdmin/";
this.addNewUser = function(skey, userName, password) {
//log.info("module " + skey + userName + password)
options.useSOAP = 1.2;
options.useWSA = 1.0;
options.action = "urn:addUser";
options["HTTPHeaders"] = [{
name : "Cookie",
value : "JSESSIONID=" + skey
}];
var payload = '' + userName + '' + password + '';
var result;