IssueHOTPBlob2.java

Exemplo de geração, verificação e re-sincronização de blob HOTP OATH utilizando o HSM. Com semente gerada fora do HSM.

Veja Nota sobre os exemplos.
package doxy.examples;
public class IssueHOTPBlob2 {
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);
// The seed is a binary that can be generated by hsm or by soft/hard token.
byte[] hotpSeed = { (byte)0xD5, (byte)0x17, (byte)0xED, (byte)0x40, (byte)0x1D,
(byte)0xF3, (byte)0x03, (byte)0x38, (byte)0x37, (byte)0xE0,
(byte)0x8B, (byte)0x62, (byte)0x55, (byte)0xBE, (byte)0xDB,
(byte)0xF9, (byte)0x52, (byte)0x0E, (byte)0xF8, (byte)0x8E };
System.out.println("--> Generate BLOB for the seed");
byte[] hotpImpBlob = api.importOATHHotpBlob( masterKeyName,
hotpSeed); // You must store binary value of blob
//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 syncronized (event token)");
hotpImpBlob = api.resyncOATHBlobOTP( masterKeyName,
"758993",
"864532",
hotpImpBlob);
api.closeSession();
System.out.println("The process ended sucessfully");
}
}