Reputation: 73
I have created a java service with parameter @Requestparam String Id when i was passing the Exact value it's working fine when i try to pass the encrypted value it is not working properly. I have given my work around below.
@GetMapping("fetch")
@Produces(value = "application/json")
@ApiOperation("Get user detail from Okta")
public ResponseEntity<UserInfoRespone> getUserDetailsFromOkta(@RequestParam String agentId) {
System.out.println("Actual:" +"c4njCC2/reRud+O/I41w3w==");
System.out.println("Incoming agent Id:" + agentId);
}
When i call the service using postman passed the encrypted value c4njCC2/reRud+O/I41w3w== but when i was trying to print the incoming agent id i found few characters were missing in the actual text looks like c4njCC2/reRud O/I41w3w== it has missed + symbol and added space to itself. so when i tried to decrypt the String it's coming as null.
Expected : c4njCC2/reRud+O/I41w3w==
Actual : c4njCC2/reRud O/I41w3w==
Could some one help me to resolve this?
Upvotes: 0
Views: 2168
Reputation: 10964
You need to URL encode your query parameter like this:
c4njCC2%2FreRud%2BO%2FI41w3w%3D%3D
There are several websites where you can encode/decode values like this (for example https://www.urlencoder.org/). Using plain java you can use the java.net.URLEncoder
:
URLEncoder.encode("c4njCC2/reRud+O/I41w3w==", StandardCharsets.UTF_8);
However a request parameter is probably not the best choice for encrypted data as you might get into trouble with other characters (even in encoded form) as well.
I'd suggest to submit this data in the request body instead.
Upvotes: 1