IssueTOTPBlob.java
Exemplo de geração, verificação e re-sincronização de blob TOTP OATH utilizando o HSM. Com semente gerada dentro do HSM.
- Veja Nota sobre os exemplos.
package doxy.examples;
public class IssueTOTPBlob {
private static String strAddr = "10.0.62.16";
private static String strUsrId = "master";
private static String strPwd = "12345678";
private static String masterKeyName = "master_key";
public static void main(String[] args) throws TacException {
Dinamo api = new Dinamo();
System.out.println("--> Login HSM");
api.openSession(strAddr, strUsrId, strPwd);
System.out.println("--> Create a master key");
api.createKey(masterKeyName, TacNDJavaLib.ALG_AES_256, TacNDJavaLib.NONEXPORTABLE_KEY);
System.out.println("--> Generate BLOB for the seed");
byte[] totpGenBlob = api.generateOATHTotpBlob(masterKeyName);
//This call simulates the client application
String nextOtp = api.getNextOATHOTP(masterKeyName,
TacNDJavaLib.ISSUE_OATH_MIN_OTP_LEN,
totpGenBlob);
System.out.println("--> check OTP value for know seed and sequence");
totpGenBlob = api.checkOATHBlobOTP(masterKeyName, nextOtp, totpGenBlob);
api.closeSession();
System.out.println("The process ended sucessfully");
}
}