Example of export and import in TR-31 format.
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;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class ExportImportTR31 {
public static void main(String[] args) throws TacException {
Dinamo api = new Dinamo();
api.openSession("127.0.0.1", "master", "12345678", false);
String kbpk = "kbpk";
String key = "key";
api.createKey(key, TacNDJavaLib.ALG_AES_128, true);
api.createKey(kbpk, TacNDJavaLib.ALG_AES_256, true);
byte[] keyBlock = api.exportTR31(kbpk, key, TacNDJavaLib.EFT_ME_TR31_EXP_USAGE_AUTO,
TacNDJavaLib.EFT_ME_TR31_EXP_MODE_AUTO,
TacNDJavaLib.EFT_ME_TR31_EXP_AUTO);
System.out.println("Chave exportada com sucesso.");
String impKey = "impKey";
api.importTR31(kbpk, impKey, TacNDJavaLib.EXPORTABLE_KEY, keyBlock);
System.out.println("Chave importada com sucesso.");
api.deleteKey(key);
api.deleteKey(kbpk);
api.deleteKey(impKey);
api.closeSession();
}
}