/sample-java-v5

USI Java client based on USI sample code - to support Version 5

Primary LanguageJava

This source is based on the sample JAVA code previously available from https://www.usi.gov.au/system-developers/sample-code

It works as is with 3PT using the STS 1.2 SHA1 service.

Note that USI v3 has been deprecated, so support for it has been removed.

Alternatively, see below for PROD which uses:

WSDLs

The WSDLs used are NOT those hosted on the USI site. Instead local modified copies are used which:

  • remove the MEX call as this is not supported by the STS
  • configure the STS including claims
  • full specify use of sha256 (otherwise some aspects fall back to sha1)

Files:

Building

Either use:

  • IDE - use gh to fetch the jars (see comment in build)
  • ANT - see build4 (USI v4)

Tested platforms: Windows 10, MacOS, Linux

Notes on contributions:

  1. binaries are banned (use gh)

Using ANT

See the input vars in build.xml.

e.g.

  • ant -Dusiver=5 -Denv=PROD getjars wsdl jar runUSITest

or seperately run targets

  • ant getjars
  • ant -Dusiver=5 -Denv=PROD wsdl
  • ant -Dusiver=5 jar
  • ant -Dusiver=5 runUSITest

will generate files for USI v5 for production use (requires a valid production keystore file to run). The wsdl target will setup the appgen.properties file and copy the application..properties to application.properties where is 3PT or PROD.

Variables exist to set:

  • USI v5 or v4 service (v3 no longer supported)
  • 3PT or PROD
  • STS v1.2 or v1.3

In application.properties there are some values that can be set at runtime:

  • local or cloud (ActAs/Applies)
  • keystore=keystore/keystore-usi.xml
  • alias_local=ABRD:27809366375_USIMachine
  • alias_cloud=ABRD:11000002568_INGLETON153

Dependencies (built and tested with)

Ensure environment variables are set properly

  • JAVA_HOME
  • CXF_HOME (must be set to bin subfolder)

The build3/4 scripts will fetch the dependent libs into the lib subfolder:

  • abrakm.jar
  • auskey-dep-1.1.jar
  • webservices-api.jar
  • webservices-extra.jar
  • webservices-rt.jar

Structure

  • build.xml
    • see Building
  • keystore/
    • the M2M credentials used in testing 3PT
  • application.properties, etc
    • used by the sample apps. See content for more info.
  • srcv4/usi
    • the USI sample app for USI v4
  • srcv4/au
    • the pre-generated output of wsdl2java (see wsdl target in build.xml)
    • the files are the same for 3PT or PROD so there is no need to regenerate (unless the service definition changes)
  • srcv4/wsdls
    • UsiService_EEE_stsSS.wsdl (where EEE=3PT or PROD; SS=12 (sha1) or 13 (sha256))
    • contains numerous changes to support client side calls
  • srcv4/META-INF
    • the wsdl definition file consumed by the generated source
  • srcv5/*
    • the USI v5 files
  • lib
    • where downloaded jars are put

Sample of expected results from run

USI reports an error as the data already exists. However, the transaction did verify successfully.

***********************************************************
WARNING: ***** Using proxy [localhost:8080] *****
***********************************************************
[main] INFO au.gov.abr.akm.credential.store.ABRKeyStoreSerializer - XML keystore loading
[main] INFO au.gov.abr.akm.credential.store.ABRKeyStoreSerializer - 2 credentials loaded in 125 milliseconds.
[main] INFO au.gov.abr.akm.credential.store.ABRCredential - Initialising X509Delegate
[main] INFO au.gov.abr.akm.credential.store.ABRCredential - checked to see if credential is due to be renewed - is not due yet
[main] INFO au.gov.abr.akm.credential.store.ABRKeyStoreSerializer - XML keystore loading
[main] INFO au.gov.abr.akm.credential.store.ABRKeyStoreSerializer - 2 credentials loaded in 17 milliseconds.
----------Printing Create USI Request Result and USI
Failure
null
----------Printing Error Messages
Failed to create USI record, multiple existing records were found.
----------Cannot call Verify, due to errors from Create.

Notes

Proxy and Tracing

See EnableProxy_FOR_DEBUG_ONLY() to use a proxy such as BURP to capture http/s traffic.

soapTracing() is generally sufficient.