0

When sending web service requests in our Java application, we read a couple of properties as url, username, password etc. from a property-file and then set them in a request object that is then passed to the web service.

As we log the outgoing request and response objects (with an ObjectMapper), the passwords are printed in clear text in the log file, which is not good. Since we don't have control over the request objects we cannot annotate the property to remove it.

Is there a way of telling the ObjectMapper to ignore getters with certain names or something similar? I have looked at the documentation but cannot find anything that I find suitable (doesn't mean it's not there).

I'm using version 1.9.13 of the jackson-mapper-asl maven dependency to be able to use the ObjectMapper.

Mithical
  • 603
  • 1
  • 17
  • 28
MartinH
  • 11
  • 3
  • http://stackoverflow.com/questions/5455014/ignoring-new-fields-on-json-objects-using-jackson – Héctor Feb 23 '15 at 13:00
  • Thanks, but doesn't that ignore all fields? I want to ignore specific fields, not all of them. – MartinH Feb 23 '15 at 13:07
  • You can annotate the fields you don't want serialize with @JsonIgnore – Héctor Feb 23 '15 at 13:57
  • Unfortunately I don't have control over the fields so I cannot annotate them. I receive an object from a web service and contains fields that shouldn't be in a log. So e.g. I want to remove everything that has a getter containing the name "secretPassword". – MartinH Mar 20 '15 at 14:59
  • Write a custom mapping function and use that instead – jlewkovich Mar 05 '17 at 21:07

0 Answers0