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

Example of generating, checking and re-synchronizing a HOTP blob OATH using HSM. With seed generated within HSM.

See Note on examples.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class IssueHOTPBlob {
private static String strAddr = "127.0.0.1";
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("--> HSM Login");
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[] hotpImpBlob = api.generateOATHHotpBlob(masterKeyName);
//This call simulates the client application
String nextOtp = api.getNextOATHOTP(masterKeyName,
TacNDJavaLib.ISSUE_OATH_MIN_OTP_LEN,
hotpImpBlob);
System.out.println("--> check OTP value for know seed and sequence");
hotpImpBlob = api.checkOATHBlobOTP( masterKeyName,
nextOtp,
hotpImpBlob);
System.out.println("--> Two consecutive OTPs are passed for HSM to adjust the event window in the case of need to sync (event token)");
//These 2 OTPs must be generated by the client application
hotpImpBlob = api.resyncOATHBlobOTP( masterKeyName,
"758993",
"864532",
hotpImpBlob);
System.out.println("--> Delete the master key");
api.deleteKey(masterKeyName);
api.closeSession();
System.out.println("The process ended successfully");
}
}