API Java
HSM Dinamo
Cargando...
Buscando...
No se han encontrado entradas
PostPutGetDeletePIX.java

Ejemplo de utilización de las operaciones HTTP POST, PUT, GET y DELETE para el envío en el estándar PIX definido en el SPI (Sistema de Pago Instantáneo).

Véase la nota sobre ejemplos.
paquete 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;
import com.dinamonetworks.PIXHTTPReqDetails;
import com.dinamonetworks.PIXResponse;
public clase PostPutGetDeletePIX {
public static void main(String[] args) throws IOException {
String strAddr = "127.0.0.1";
String strUsrId = "maestro";
String strPwd = "12345678";
int nPuerto = 4433;
int nFlags = 0;
Ruta currentRelativePath = Paths.get("c:\tmp\pix\pix.xml");
byte[] xml = Files.readAllBytes(currentRelativePath);
Dinamo api = new Dinamo();
intentar {
api.openSession(strAddr, strUsrId, strPwd, nPort, nFlags);
System.out.println("Conectado");
String strPrivKeyId ="clave"; //Nombre de la clave en el HSM
String strCertChainId ="key_cert"; //Nombre del certificado en el HSM
String strPIXCertChainId ="peer_chain"; //Nombre de la cadena de certificados PIX en el HSM
String strURL = "https://127.0.0.1:8000"; //URL para acceder al PIX
String straRequestHeaderList[] = { "Content-Type: application/xml; charset=utf-8"}; //Headers HTTP
PIXResponse response = api.postPIX(strPrivKeyId,
strCertChainId,
strPIXCertChainId,
strURL,
straRequestHeaderList,
xml,
0,
0);
System.out.println("POST");
System.out.println("Cabeza");
System.out.println(new String(response.getHead()));
System.out.println("Cuerpo");
System.out.println(new String(response.getBody()));
/*
* Llamada opcional para recuperar los detalles de la operación.
* */
PIXHTTPReqDetails detalles = api.getPIXHTTPReqDetails();
System.out.println("Tiempo total (ms): " + details.getTotalTime());
System.out.println("Respuesta HTTP: " + details.getHttpResponseCode());
response = api.putPIX(strPrivKeyId,
strCertChainId,
strPIXCertChainId,
strURL,
straRequestHeaderList,
xml,
0,
0);
System.out.println("PUT");
System.out.println("Cabeza");
System.out.println(new String(response.getHead()));
System.out.println("Cuerpo");
System.out.println(new String(response.getBody()));
/*
* Llamada opcional para recuperar los detalles de la operación.
* */
details = api.getPIXHTTPReqDetails();
System.out.println("Tiempo total (ms): " + details.getTotalTime());
System.out.println("Respuesta HTTP: " + details.getHttpResponseCode());
response = api.getPIX(strPrivKeyId,
strCertChainId,
strPIXCertChainId,
strURL,
straRequestHeaderList,
0,
0);
System.out.println("GET");
System.out.println("Cabeza");
System.out.println(new String(response.getHead()));
System.out.println("Cuerpo");
System.out.println(new String(response.getBody()));
response = api.deletePIX( strPrivKeyId,
strCertChainId,
strPIXCertChainId,
strURL,
straRequestHeaderList,
0,
0);
System.out.println("BORRAR");
System.out.println("Cabeza");
System.out.println(new String(response.getHead()));
System.out.println("Cuerpo");
System.out.println(new String(response.getBody()));
api.closeSession();
} catch (br.com.trueaccess.TacException e) {
e.printStackTrace();
}
System.out.println("Finalizado.");
}
}