Working with HMAC authentication in Jmeter - javascript

I am doing performance testing of Web Services which involves HMAC authentication. Details are:
A java script has been developed which will create a signature, MD5
code and nonce number before a request is sent from the API
This information generated above will be passed on to variables
defined in the script which will authenticate before making a
request.
Once authentication is successful the request will be sent and
valid response will be obtained from DB.
script needs to be put in a beanshell preprocessor of Jmeter:
This script will be generating values for the header manager which in turn will do authentication process.
The problem is the language in which the script has been written ( JS ) is not compatible with Jmeter i.e jmeter cannot use the script created because it does not understands the language of the script. I came to know that the script has to be modified probably using jquery so that the jmeter beanshell can interpret it and generate values for
Date
MD-5
Signature
How can I change it to jQuery or is there any possibility to get similar JQuery code, as I do not have much java script coding background.

Try to use JSR223 Sampler with script language set to javascript (Language: JavaScript).
Reference:
https://stackoverflow.com/a/14853893/5159450

Related

Client JS for Infinispan does not find cache entered by Infinispan Java client

I've a application java to resposible to putting information in the caches and an application NodeJS responsible to manager the evict. The Infinispan Javascript client does not find the entries that was put by the Infinispan Java client. I tried to use the data types and string key's but it didn't work.
I'm use Infinispan 8.2 with Hot Rod protocol.
For data types to work, the Java client also needs to provide data type information using the encoder (see here), but that was only added in Infinispan 9.1.
An example showing how Infinispan endpoints can interop can be found here. The example does not show the Node.js client, but once you've seen the types provided by the Java client, you should be able to use those data types with the Node.js client.

How to call java methods in a .jar file from javascript?

I know there are many similar questions on the internet but none of them could solve my doubt. So pardon me. About my project. I have a java file or program that takes a string , encrypts it and then returns the encrypted string to me.
I want to include or keep this java file (.jar file) on the webpage or the client-side. Now I know that we can upload this java program on server side and then easily communicate with it instead of calling keeping it on client-side which most people consider a bad practice.
But my purpose of keeping this jar file on the client side is that JavaScript code for encryption can be easily seen if we inspect element, so compared to it .jar file is more secure and one cannot see underlying encryption code and also if in case the there is network loss then instead of typing the entire string again and getting it encrypted again from the server, I want to save that string in such situation, get it encrypted from the jar file on the client-side so that once network problem is solved I don't need to retype whole message again and then I can directly send the message or the string to the other end or to other user on the network.
So for this I need help regarding how can I store my .jar file on webpage or client-side and then how to call methods from the .jar file using JavaScript. I know applets are deprecated, chrome does not support java. I have also seen some examples on internet like https://docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html but Its not working properly for me.
So I am in search of some ideal method by which I can first of all include or upload .jar file on client-side and then a method by which I can call java methods from .jar file using JavaScript. Please help... My earnest request...!
JavaScript code for encryption can be easily seen if we inspect element
I'm assuming you mean embedded Javascript here. Because you can refer to an external JS files which are located on the web server, not the client machine.
The browser may cache your script file somewhere locally but if one were bothered enough to dig it up, he might as well decompile your jar file which is much more easier.
Java can easily be decompiled. A jar file on the client will not be more secure than client-side JavaScript.
An encryption method that is compromised by looking at its code is not secure.
You seem to have many misconceptions... here are some facts for you to consider:
A JAR file (as either an application, WebStart or applet) running on client-side is NOT secure. If it runs on my computer, I can do anything I want. I can download the JAR file and decompile it. It's no better than JavaScript in this regard, it just takes slightly more effort and knowledge.
To protect data between client and server, you can simply use HTTPS and POST the data from web page to your server.
If client is encrypting data to you, there should be nothing to hide about the encryption process. The client generates a session key to encrypt the data, then wrap that session key by your server's public key. Then client send both encrypted data and wrapped session key to your server. Read more about Public Key Infrastructure (PKI): https://en.wikipedia.org/wiki/Public_key_infrastructure
By default a Java applet/WebStart is not granted access to disk. You must sign it to write data to disk, and user/security policies can still deny granting those access rights. (Applet - Unable to write file)
As you are aware of it, applet/WebStart is dying because of browsers rejecting plugins. There's Web Cryptography API (it's not mature, and there's no hardware support), you can try that instead. https://www.w3.org/TR/WebCryptoAPI/

How to launch a Java Web start application with dynamic parameters

I'm trying to migrate a Java applet to a Java web start application. The applet was activated from a JavaScript with several parameters, some are not hard-coded (sessionId, tempFilePath):
deployJava.runApplet(attributes, parameters);
In order to migrate the applet I'm using a simple JNLP file with applet-desc tag. And from the JavaScript I call:
deployJava.launchWebStartApplication('$jnlp_path');
I just can't understand how to pass to the web start application the parameters that were created by the JavaScript.
OK, so it turns out that using deployJava.launchWebStartApplication(...) triggers security restrictions in Chrome and IE.
What I did is kind of work around: I sent an HTTP request to my server and the server's response was a JNLP content.
On the server side, I edited the JNLP on runtime and each time I inserted the required parameters.
When the browsers receive the JNLP content they trigger the download of the required jar.
And that's it!

Adobe Captivate: Using GET/POST for Server Side Calculation in SCORM Module

Is it possible for Captivate 6 to exchange data with a PHP script via POST/GET while maintaining our ability to package our module into SCORM? Our module needs to exchange data from the user and send to our server farm for some computational-heavy calculations, which are then used in the module to modify the information displayed to the user. This is independent of the SCORM functionality.
I have seen a few examples where people have set the reporting options of their module to "email" (as opposed to SCORM) and then modified the email reporting javascript functions provided by Captivate to send data via GET/POST using XMLHttpRequest. In our case this will not work because I still need to do my reporting via SCORM. However, I also need to access some server side resources on our web server to drive the Captivate presentation.
Any ideas?
You can get/set variables in Captivate using JavaScript.
Extract data from Captivate using JavaScript (my open-source CaptivateController utility is designed to make this easy).
Pass the data to your PHP page using xmlhttprequest (aka AJAX). *
Send any return values to Captivate using JavaScript (again, the CaptivateController makes this easy).
Then do whatever you wish with the data inside Captivate.
This is all independent of SCORM. Bear in mind that a true SCORM package does not rely on an external PHP script, but there is no technical reason why it wouldn't work.
* Watch out for cross-domain scripting issues when trying to pass the data from your course to your PHP file and back. If you run into problems, search StackOverflow -- there are plenty of StackOverflow posts covering cross-domain scripting issues.

Connecting C++ backend to Javascript

I was hoping to make a website that displays a google map with points based of information returned by a C++ function. I know you can use Java Server Pages to call java methods on the server with javascript. Would there be a way to connect C++ code on the server with javascript in order to produce the same result as java server pages?
Since JavaScript runs at a completely different environment which is separated from the webserver by a HTTP connection, your best bet is to fire a HTTP request to the server side on a specific URL which has the particular C++ code attached.
You can fire asynchronous HTTP requests in JavaScript using XMLHttpRequest, the core technique behind "Ajax". The w3schools provides a concise introduction to Ajax. To make it all less verbose and bloated, you may consider to grab the jQuery library which has under each an $.ajax function for this purpose.
That said, Java Server Pages is absolutely not to be compared with JavaScript. JSP is a Java based server side view technology which provides a template to write HTML/CSS/JS in and offers capabilities to control the page flow dynamically and interact with backend Java code using taglibs and expression language. It runs all on the server machine, produces a HTML page and sends it over HTTP to the client side. The C++/C#/NET counterpart of JSP is ASP.

Categories