HDFC Bank Open API Banking Platform – User Manual
Copyright@HDFCBank 14 Restricted
if (debug) e.printStackTrace();
} catch (InvalidKeyException e) {
if (debug) e.printStackTrace();
}
if (tokenForThisReq == null) return false;
if (tokenForThisReq.equals(tokenReceivedFromServer)) return true;
return false;
}
public class JwtTokenForReqId{
public static String getJwtTokenForReqId(String uniqueRequestId) throws UnsupportedEncodingException,
NoSuchAlgorithmException, InvalidKeyException {
String secretKey = "";
String response2 = null;
String keyToEncode = "";
StringBuffer sb, sb2, sb3;
try {
//STEP 1 //Remove ‘_’ from ApplicationVariables.DEVICE_UNIQUE_ID for below code only.
String keyString = ApplicationVariables.DEVICE_UNIQUE_ID + "." +
com.indigo.hdfcloans.utils.Utility.getCurrentDateIn_yyyymmdd() + "." + uniqueRequestId;
Log.e("KEYSTRING", keyString);
MessageDigest mDigest = MessageDigest.getInstance("SHA256");
byte[] result = mDigest.digest(keyString.getBytes());
sb = new StringBuffer();
for (int i = 0; i < result.length; i++) {
sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
}
String string = "{\"alg\":\"HS256\",\"typ\":\"HQR\"}";
mDigest = MessageDigest.getInstance("SHA256");
byte[] result2 = mDigest.digest(string.getBytes());
sb2 = new StringBuffer();
for (int i = 0; i < result2.length; i++) {
sb2.append(Integer.toString((result2[i] & 0xff) + 0x100, 16).substring(1));
}
//STEP 2.2
String string1 = "{\"tokenId\":43124832,\"userId\":\"" + ApplicationVariables.DEVICE_UNIQUE_ID +
"\",\"username\":\"Guest\",\"validity\":\"2016-05-07 17:07\"}";
mDigest = MessageDigest.getInstance("SHA256");
byte[] result3 = mDigest.digest(string1.getBytes());
sb3 = new StringBuffer();
for (int i = 0; i < result3.length; i++) {