1

I have the following endpoint

@RequestMapping("missedcall")
fun missedCall(@RequestParam("v") encryptedValue : String, model: 
ModelMap): String {
    //decrypt encryptedValue here
}

When I execute this endpoint with "http://myurl.com/missedcall?v=this+is+my+encrypted+string", encryptedValue initialized as "this is my encrypted string". I actually want the pluses as they are part of the encryption and I can't decrypt the string without them.

The work around would be URL encode the string back to restore pluses and other special characters, BUT is there a cleaner way? Maybe disabling URL decoding for this particular endpoint?

Note: I can't pass this param in body, it has to be part of the query string. Also this is written in Kotlin, but I am 100% sure Java has similar issues, so don't feel discouraged by Kotlin :).

2 Answers 2

5

Any web framework will decrypt the query path for you, as that's expected behavior. If that's not what you want, you will have to define a method argument of type HttpServletRequest and parse the query yourself using HttpServletRequest.getQueryString().

Sign up to request clarification or add additional context in comments.

Comments

0

Thanks to @SeanPatrickFloyd, implemented it as

@RequestMapping("missedcall")
fun missedCall(request: HttpServletRequest, model: ModelMap): String {
    val encodedValue = request.queryString.split("=")[1]
    //decrypt encryptedValue here
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.