Commit bacc3047 authored by Josh Ji's avatar Josh Ji

logger.info

parent f9fb0ed0
......@@ -33,25 +33,25 @@ public class RESTfulApi {
public String queryIdentity(@RequestBody IdentityRequest identityRequest) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
String sql = "SELECT * FROM identities WHERE HMACbase64 LIKE ?;";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql,new Object[]{identityRequest.HMAC +"%"}, new int[]{Types.VARCHAR});
logger.debug("identityRequest : {}, {}", identityRequest.HMAC, identityRequest.Cx);
logger.info("identityRequest : {}, {}", identityRequest.HMAC, identityRequest.Cx);
Cipher aesCipher = Cipher.getInstance("AES/CBC/NoPadding");
IvParameterSpec IV = new IvParameterSpec(new byte[]{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00});
logger.debug("encryptedCx in base64 form : "+identityRequest.Cx);
logger.info("encryptedCx in base64 form : "+identityRequest.Cx);
for(Map<String, Object> map : list){
byte[] sharedSecret = (byte[])map.get("SharedSecret");
byte[] Cx = (byte[])map.get("Cx");
String IDx = (String)map.get("IDx");
SecretKey secretKey = new SecretKeySpec(sharedSecret, "AES");
logger.debug("IDx in db : " + IDx);
logger.debug("sharedSecret in db : " + HexUtils.toHexString(sharedSecret));
logger.debug("Cx in db : " + HexUtils.toHexString(Cx));
logger.info("IDx in db : " + IDx);
logger.info("sharedSecret in db : " + HexUtils.toHexString(sharedSecret));
logger.info("Cx in db : " + HexUtils.toHexString(Cx));
aesCipher.init(Cipher.DECRYPT_MODE, secretKey, IV);
byte[] encryptedCx = Base64Utils.decodeFromString(identityRequest.Cx);
logger.debug("encryptedCx : " + HexUtils.toHexString(encryptedCx));
logger.info("encryptedCx : " + HexUtils.toHexString(encryptedCx));
byte[] decryptedCx = aesCipher.doFinal(encryptedCx, 0, 16);
logger.debug("decryptedCx : " + HexUtils.toHexString(decryptedCx));
logger.info("decryptedCx : " + HexUtils.toHexString(decryptedCx));
if(Arrays.equals(Cx, decryptedCx)){
return IDx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment