AXM: NullPointerException in Hook with InternalRuntimeAPI
RSA ClearTrust 5.5.x Server Side Hooks RSA Access Manager 6.0 Server SPI (Server Hook) RSA ClearTrust 5.5.x Property Provider API RSA Access Manager 6.0 Property Provider API
AXM: Implementing the Property Provider interface in a hook in order to access the PPI's InternalRuntimaAPI object
On accessing the InternalRuntimeAPI from a Server Side Hook, which implements the interface PropertyProvider, a NullPointerException is thrown routinely about one third of the time (which is only visible under debug logging):
java.lang.NullPointerException at sirrus.authserver.property.impl.PropertyCallbackImpl.getContext(PropertyCallbackImpl.java:198) at sirrus.authserver.runtime.impl.InternalRuntimeAPIImpl.getRequestMap(InternalRuntimeAPIImpl.java:421) at sirrus.authserver.runtime.impl.InternalRuntimeAPIImpl.createToken(InternalRuntimeAPIImpl.java:130) ...
The root cause is the absence of a ThreadLocal RequestContext object. Every request that the authorization server processes normally has a RequestContext, which contains the user map, the request map, and sometimes the resource map. This is a concurrency issue between the Property Provider API and the Server Side Hook API, where the thread executing the hook is not the same thread invoking the property provider.
This is a known scenario that is not supported due to this concurrency issue. To access the Runtime API from a server side hook, create and maintain an external connection to the authorization server in the hook.