Java API
HSM Dinamo
Loading...
Looking for...
No entries found
SignVerifyPIX.java

Example of signature and verification using the PIX standard defined in the SPI (Instant Payment System).

See Note on examples.
package doxy.examples;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.dinamonetworks.Dinamo;
public class SignVerifyPIX {
public static void main(String[] args) throws IOException {
String strAddr = "127.0.0.1";
String strUsrId = "master";
String strPwd = " 12345678";
int nPort = 4433;
int nFlags = 0;
Path currentRelativePath = Paths.get("c:\\tmp\\pix\\pix.xml");
byte[] xml = Files.readAllBytes(currentRelativePath);
Dinamo api = new Dinamo();
try {
api.openSession(strAddr, strUsrId, strPwd, nPort, nFlags);
System.out.println("Connected.");
String strPrivKeyId ="key"; //Name of key in HSM
String strCertId ="key_cert"; //Name of certificate in HSM
byte[] signedXml = api.signPIX(strPrivKeyId,
strCertId,
xml);
System.out.println(new String(signedXml));
String strChainId = "key_chain"; //Name of the certificate chain in the HSM
boolean ret = api.verifyPIX(strChainId, null, signedXml);
System.out.println("Signature ok: " + ret);
api.closeSession();
} catch (br.com.trueaccess.TacException e) {
e.printStackTrace();
}
System.out.println("Finished.");
}
}