How to run Java Sample Code for MLE

shameem
Visa Employee

How to run Java Sample Code for MLE

In this “How-to” guide, we will show you how to test MLE (Message Level Encryption) enabled APIs using Java.

 

Important Links:

Enable MLE

 

The first step is to enable MLE for the API(s) you are interested in.

 

Login to your Visa Developer Dashboard and go to your project, you should see something like this:

 

2020-11-11_09-45-12.png

 

Enable the APIs for which MLE needs to be active in VDP by toggling the API for which MLE needs to be enforced.

 

In this tutorial, we are going to enable MLE for Funds Transfer API And Query API:

 

2020-11-11_09-46-41.png

 

Get the credentials

On the left side navigation menu of your project, click on “Credentials”.

 

2020-11-11_11-25-10.png

 

Next step we will create a Key-ID by clicking on the Generate Key-ID button.

 

2020-11-11_11-29-02.png

 

Copy the Key-ID for your reference.

The Key-ID looks this: 41d9f2a1-xxxx-4xxx-b40c-a0480c2xxxxx

 

2020-11-11_11-30-49.png

 

The next step is to add a CSR. Click on the link "Add CSR" .   

 

You are prompt to submit a Certificate Signing Request. 

 

2020-11-11_11-32-46.png

 

We have the option to Generate a CSR for me (default) or submit your own. In this example, we will use the Generate a CSR for me (default) and click Confirm button.

 

After submitting the request, you will be prompt to download the Certificate/Copy Private Key. 

 

 

2020-11-11_11-34-26.png

 

After you have downloaded the private key, check the box "I confirm that I've downloaded my certificate key" and click continue. You will see the Status change to "Active".

 

Expand the Key-ID and you will see the Server Encryption Certificate and Client Encryption Certificate. Download both certificates.

2020-11-11_11-36-33.png

To be able to make an API call with MLE, you need to have the following

  • Server Encryption Certificate
  • Key-ID
  • Certificate Private Key

 

How to run Java Sample Code for MLE

 

Step 1 - Download the Java Sample Code 

 

  • Download the Java Sample Code (maven project) which is available by login to the developer portal
  • You should be able to see Message Level Encryption Sample Code under the General Assets Section

MLE_GeneralAssets.png

 

  • Import the Java Project to your IDE, Eclipse or IntelliJ

 

Open the Java Class PushFundsAndQueryAPIWithMLE on your IDE and set the below parameters with your own credentials

 

KEYSTORE_PATH = "<YOUR KEYSTORE PATH>";

KEYSTORE_PASSWORD = "<YOUR KEYSTORE PASSWORD>";

 

USER_ID = "<YOUR USER ID>";

PASSWORD = "<YOUR PASSWORD>";

 

MLE_CLIENT_PRIVATE_KEY_PATH = "<YOUR MLE CLIENT PRIVATE KEY PATH>";

MLE_SERVER_PUBLIC_CERTIFICATE_PATH = "<YOUR MLE SERVER PUBLIC CERTIFICATE PATH>";

KEY_ID = "<YOUR KEY ID>";

 

Please refer to the article HelloWorld.java - How to run Java Sample Code using the Hello World API and Mutual SSL of how to create a Java KeyStore.

 

Step 2 - Compile Your Code 

 

  • Simple right click and run 'PushFundsAndQueryAPIWithMLE.main()'.  The IDE will start compiling your code and execute the code.

 

Want more? Join the Visa Developer Community to get alerts on the latest tutorials, guides, and new developer resources. Stay tuned for more in the series. 

5 REPLIES 5
evgeny_t
Occasional Visitor

Re: How to run Java Sample Code for MLE

Can't get
PushFundsAndQueryAPIWithMLE.txt 😞
shameem
Visa Employee

Re: How to run Java Sample Code for MLE

Hi @evgeny_t ,

 

Thank you for checking out the Java MLE How-To Guide.

 

Kindly download the download the Java Sample Code which is available by login to the developer portal

 

You should be able to see the Message Level Encryption Sample Code under the General Assets Section which contains the Java Sample Code (Maven Project) which you can import on your IDE.

 

MLE_GeneralAssets.png

 

Let me know how it goes and any feedback you may have.

 

Thank you

Shameem

Szabolcs
Occasional Visitor

Re: How to run Java Sample Code for MLE

Hi

I tried to download the "Message Level Encryption Sample Code" bundle on dashboard page, but when I clicked on it nothing happened (after the throbber finished). Same story with the "Hello World Sample Codes" bundle.

JWS JWE Sample Code - Java can be downloaded.
I am logged in the developer portal.
What could be the problem?

shameem
Visa Employee

Re: How to run Java Sample Code for MLE

Hi @Szabolcs ,

 

I was able to download the "Message Level Encryption Sample Code" from the dashboard page. Would you mind trying with a different browser or check if file was blocked from the browser you are using.

 

Thank you

Shameem

Szabolcs
Occasional Visitor

Re: How to run Java Sample Code for MLE

Hi Shameem,
thank you for your reply.
I checked in dev mode the requests and it turned out it was just a network restriction from my company side. I solved this problem and now I was able to download the required bundles.
Br
Szabolcs