How to get Active User information in MobileFirst 8 Java Adapters? -
i have defined userlogin security check extending userauthenticationsecuritycheck class
. once user authenticated need set attributes when creating user in protected authenticateduser createuser()
function in order use them later headers in java adapter.
my problem i'm not able active user information adapter resource secured @oauthsecurity(scope = "userlogin")
. have tried defining in securitycheck following function:
public authenticateduser getuser() { return authorizationcontext.getactiveuser(); }
and calling on way adapter:
userlogin userlogin; logger.info("logging info message..."+userlogin.getuser().getid());
but returns null pointer exception.
how suppose active user information java adapters?
the adaptersecuritycontext class provides security context of adapter rest call.
inside java adapter class, add following @ class level:
@context adaptersecuritycontext securitycontext;
you can current authenticateduser using:
authenticateduser currentuser = securitycontext.getauthenticateduser();
you can find example in resourceadapter sample (under transactions enpoint).
Comments
Post a Comment