Security Tutorial (Java/AnBx)

Security Programming, Protocol Verification and Code Generation
Paolo Modesti -

Part 1 - Java Client/Server Programming

In this tutorial, we assume that the Java Development Kit (JDK) is already installed on your machine.
If this is not the case, you need to download the JDK (we recommend Adoptium OpenJDK) and install it. This should not be necessary on the university's PCs.

First of all, check the location and the version of the JDK:

If the path or version are different you will need to is set the JAVA_HOME variable accordingly. All these examples and tasks should work, as long as you are using Java .
In the following examples, we assume that JDK is installed in C:\Program Files\\jdk-.0..

TASK 0 - Configure and test the Java development environment

vi ~/.bashrc or vi ~/.bash_profile

add these lines

export JAVA_HOME=/usr/java/jdk.0_.

export PATH=$JAVA_HOME/bin:$PATH

save the file, and load it again

source ~/.bashrc or source ~/.bash_profile

On Linux the variable should now be set for your profile not just for the current session

TASK 1 - Client/Server

//COMPILE (MAKE)
javac -cp AnBxJ.jar Tutorial_01.java
// {Tutorial,client,server}_01.class files are generated

On Windows:

//RUN SERVER (start opens a new terminal)
start java -cp .;AnBxJ.jar Tutorial_01 server

//RUN CLIENT
java -cp .;AnBxJ.jar Tutorial_01 client

On Linux or Mac:

Open another terminal and run the server
//RUN SERVER
java -cp .:AnBxJ.jar Tutorial_01 server

On the previous terminal run the client
//RUN CLIENT
java -cp .:AnBxJ.jar Tutorial_01 client

Note that on Linux and Mac you need to replace ; with : in the rest of the tutorial

TASK 2 - Client/Server

TASK 3 - Key generation (optional)