简体   繁体   中英

Accessing UserIdentity from adapter Java code

I am building a Worklight 6.2 adapter that uses Java. I am also using authentication through custom login and authenticator Java code by implementing WorkLightAuthLoginModule and WorkLightAuthenticator. The authentication all works fine.

My adapter code is implemented in the getProtectedAssets static method of class com.myStuff.myClass and is called from the adapter implementation with

var returnval = com.myStuff.myClass.getProtectedAssets();

getProtectedAssets requires a username and password to connect to a back-end system. Currently I have those hard-coded in the method for testing, but I need to retrieve them from the Worklight session, presumably through the UserIdentity object I set in my custom login module's createIdentity method.

Is there some way to get access to the user identity from within the adapter Java code?

Use the WL.Server.getActiveUser() method. More information about this method can be found here: https://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.0.0/com.ibm.worklight.help.doc/apiref/r_method_wl_server_getactiveuser.html?lang=en

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM