A simple example of how to request a ticket from Qlik Sense Proxy Service API using java.
This document goes through the process of creating ticketing code in Java.
Attention! The example described below is an EXAMPLE. It is not production code. It is a proof of concept to show how to acquire a ticket from the QPS ReST API using Java. If you are intending to use this code for a production deployment, make sure to do the following:
Using Java Keytool, create a Java Key Store (JKS) file containing the client.pfx file exported from Qlik Sense. As a note, I use the word "secret" as the password for my certs. You may do something different. Alter the below as necessary.
"%PathtoJREKeytool%\keytool.exe" -importkeystore -srckeystore "client.pfx" -srcstoretype pkcs12 -destkeystore "client.jks" -deststoretype JKS -srcstorepass secret -deststorepass secret -noprompt
Using Java Keytool, create a Java Key Store (JKS) file containing the root.cer file exported from Qlik Sense.
"%PathtoJREKeytool%\keytool.exe" -import -alias QlikCA -keystore "root.jks" -file "root.cer" -storepass secret -noprompt
Compiling the java file into an actual java class is easy to do if the jdk is installed. Open a command prompt and navigate to the directory with the java code you want to compile. In the command line type in the path to the javac executable referencing the ticket.java file shown above and hit enter. If all goes well the code will compile.
Now we can test the code by calling java Ticket with arguments for userId and userDirectory (java class files are case sensitive).