java - Sending url as query parameter in rest webservice -
i have written rest service encrypt , decrypt url.
encryption code:
@get @produces("application/json") @path("/encrypt/") public response encryptwithquery(@queryparam("plainstring") string plainstring) throws jsonexception { response response = new response(); aesutil util = new aesutil(key_size, iteration_count); response = util.encrypt(salt, iv, passphrase, plainstring); return response; }
decryption code:
@get @produces("application/json") @path("/decryptwp/") public response decryptwithquery(@queryparam("encryptstring") string encryptstring) throws jsonexception { response response = new response(); aesutil util = new aesutil(key_size, iteration_count); response = util.decrypt(salt, iv, passphrase, encryptstring); return response; }
when call encrypt rest service encrypted string
url encryption
http://localhost:9080/kttafm/keybank/encrypt?plainstring=http://localhost:9080/kttafm/master.jsp?abc=zyx
but when call decryption rest service below exception
javax.crypto.badpaddingexception: given final block not padded
but if move @queryparam tp @path param, decryption works fine,
the decrypt method works fine , decrypts encrypted string is
@get @produces("application/json") @path("/decrypt/{encryptstring}") public response decrypt(@pathparam("encryptstring") string encryptstring) throws jsonexception { response response = new response(); aesutil util = new aesutil(key_size, iteration_count); response = util.decrypt(salt, iv, passphrase, encryptstring); return response; }
what missing?
please make sure encode parameter on client side, e.g. using urlencoder.
for example, url encryption must be
http://localhost:9080/kttafm/keybank/encrypt?plainstring=http%3a%2f%2flocalhost%3a9080%2fkttafm%2fmaster.jsp%3fabc%3dzyx
Comments
Post a Comment