I am trying to map the JSON response from other service to a POJO class(AMAUser class from an external jar ama-user-service.jar) using ObjectMapper.
I have configured the policy file as below in /elasticsearch-5.6.0/plugins/x-pack/plugin-security.policy
permission java.lang.RuntimePermission "accessDeclaredMembers";
And also wrapped up the sensitive code (mapper.readValue()) in Custom Realm as below; however, I still keep getting this access denied error in my logs and therefore mapping is not happening at all.
Would be grateful if someone please let me know if there is any issues with the code below or if there's any configurations I had missed out.
if (sm != null) {
// unprivileged code such as scripts do not have SpecialPermission
sm.checkPermission(new SpecialPermission());
}
userObj = AccessController.doPrivileged(
new PrivilegedExceptionAction<AMAUser>() {
@Override
public AMAUser run()
throws IOException, JsonGenerationException, JsonParseException {
return mapper.readValue(responseResult, AMAUser.class);
}
}
);