1

we've an application in which users would be sending an encrypted version of resourceId in the GET REST request.

Example: GET localhost:8080/demo-application/Employee/abcde123xyz

this abcde123xyz is an encrypted value which would be decrypted to a value 1001.

we want to make this translation before reaching controller, so that controller get the decrypted value. Can we do it using interceptor or some advice ?

  • You could use an interceptor. But why would you ever want to do that? You can just use a controller which accepts the encrypted one and call another method to decrypt or whatever. – 123 Apr 14 '20 at 15:05
  • I've already tried with Interceptor but it didn't help. Interceptor is allowing to inspect the request and set some additional attributes. It has no way to change the URL. The reason for not making a change in controller is that: controller could be of any Spring Boot App and i want to make this Interceptor thing an auto configurable project so it would also be an optional layer then. – Jatinder Jindal Apr 15 '20 at 08:05
  • Did you try using the ```getRequestDispatcher(...).forward(req, resp)```? – TheRealChx101 Aug 10 '21 at 14:17
  • You can make use of Filters, it's explained here better: https://stackoverflow.com/questions/2725102/how-to-use-a-servlet-filter-in-java-to-change-an-incoming-servlet-request-url – firoj_mujawar May 11 '22 at 09:27

0 Answers0