Exemplo de geração, verificação e re-sincronização de Blob HOTP OATH utilizando o HSM. Com semente gerada dentro do HSM.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class IssueHOTPBlobGenerate {
static String ip = "127.0.0.1";
static String user = "master";
static String password = "12345678";
public static void main(String[] args) throws TacException {
Dinamo api = new Dinamo();
api.openSession(ip, user, password);
String masterKeyName = "master_key";
System.out.println("--> Cria chave mestra");
api.createKey(masterKeyName, TacNDJavaLib.ALG_AES_256, true);
System.out.println("--> Gera BLOB HOTP");
byte[] hotpGenBlob = api.generateOATHHotpBlob(masterKeyName);
System.out.println("--> Recupera semente do BLOB HOTP");
byte[] hotpGenBlobSeed = api.getOATHSeed(masterKeyName, hotpGenBlob);
System.out.println("--> Gera próximo OTP");
String nextOtp = api.getNextOATHOTP(masterKeyName,
TacNDJavaLib.ISSUE_OATH_MIN_OTP_LEN,
hotpGenBlob);
System.out.println("--> Verifica OTP");
hotpGenBlob = api.checkOATHBlobOTP(masterKeyName, nextOtp, hotpGenBlob);
System.out.println("--> Re-sincroniza o BLOB HOTP");
hotpGenBlob = api.resyncOATHBlobOTP(masterKeyName, "457762", "251104", hotpGenBlob);
System.out.println("--> Deleta chave mestra");
api.deleteKey(masterKeyName);
api.closeSession();
}
}