Worklight: Custom Authentication Module exception -
i calling adapter , have protected adapter custom login module have not defined custom authenticator.
then created webservice calling adapter, when calling shows call goes inside custom login module credentials below exception appears.
[5/22/13 10:53:34:359 ast] 0000003a systemout o login called: aahad1234/aahad1234 5/22/13 10:53:34:359 ast] 0000003a authenticatio e com.worklight.core.auth.impl.authenticationfilter dofilter fwlse0048e: unhandled exception caught: null java.lang.nullpointerexception @ com.worklight.core.auth.impl.authenticationcontext.logloginactivity(authenticationcontext.java:352) @ com.worklight.core.auth.impl.authenticationcontext.checkauthentication(authenticationcontext.java:495) @ com.worklight.core.auth.impl.authenticationcontext.processrealms(authenticationcontext.java:396) @ com.worklight.core.auth.impl.authenticationcontext.pushcurrentresource(authenticationcontext.java:373) @ com.worklight.core.auth.impl.authenticationservicebean.accessresource(authenticationservicebean.java:63) @ com.worklight.core.auth.impl.authenticationfilter.dofilter(authenticationfilter.java:162) @ com.ibm.ws.webcontainer.filter.filterinstancewrapper.dofilter(filterinstancewrapper.java:195) @ com.ibm.ws.webcontainer.filter.webappfilterchain.dofilter(webappfilterchain.java:91) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.dofilter(webappfiltermanager.java:928) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.invokefilters(webappfiltermanager.java:1025) @ com.ibm.ws.webcontainer.servlet.cacheservletwrapper.handlerequest(cacheservletwrapper.java:87) @ com.ibm.ws.webcontainer.webcontainer.handlerequest(webcontainer.java:895) @ com.ibm.ws.webcontainer.wswebcontainer.handlerequest(wswebcontainer.java:1662) @ com.ibm.ws.webcontainer.channel.wcchannellink.ready(wcchannellink.java:195) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.handlediscrimination(httpinboundlink.java:452) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.handlenewrequest(httpinboundlink.java:511) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.processrequest(httpinboundlink.java:305) @ com.ibm.ws.http.channel.inbound.impl.httpiclreadcallback.complete(httpiclreadcallback.java:83) @ com.ibm.ws.ssl.channel.impl.sslreadservicecontext$sslreadcompletedcallback.complete(sslreadservicecontext.java:1784) @ com.ibm.ws.tcp.channel.impl.aioreadcompletionlistener.futurecompleted(aioreadcompletionlistener.java:165) @ com.ibm.io.async.abstractasyncfuture.invokecallback(abstractasyncfuture.java:217) @ com.ibm.io.async.asyncchannelfuture.firecompletionactions(asyncchannelfuture.java:161) @ com.ibm.io.async.asyncfuture.completed(asyncfuture.java:138) @ com.ibm.io.async.resulthandler.complete(resulthandler.java:204) @ com.ibm.io.async.resulthandler.runeventprocessingloop(resulthandler.java:775) @ com.ibm.io.async.resulthandler$2.run(resulthandler.java:905) @ com.ibm.ws.util.threadpool$worker.run(threadpool.java:1690) [5/22/13 10:53:34:359 ast] 0000003a localtrancoor e wltc0017e: resources rolled due setrollbackonly() being called. [5/22/13 10:53:34:359 ast] 0000003a webapp e com.ibm.ws.webcontainer.webapp.webapp logservleterror srve0293e: [servlet error]-[static file wrapper]: java.lang.nullpointerexception @ com.worklight.core.auth.impl.authenticationcontext.logloginactivity(authenticationcontext.java:352) @ com.worklight.core.auth.impl.authenticationcontext.checkauthentication(authenticationcontext.java:495) @ com.worklight.core.auth.impl.authenticationcontext.processrealms(authenticationcontext.java:396) @ com.worklight.core.auth.impl.authenticationcontext.pushcurrentresource(authenticationcontext.java:373) @ com.worklight.core.auth.impl.authenticationservicebean.accessresource(authenticationservicebean.java:63) @ com.worklight.core.auth.impl.authenticationfilter.dofilter(authenticationfilter.java:162) @ com.ibm.ws.webcontainer.filter.filterinstancewrapper.dofilter(filterinstancewrapper.java:195) @ com.ibm.ws.webcontainer.filter.webappfilterchain.dofilter(webappfilterchain.java:91) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.dofilter(webappfiltermanager.java:928) @ com.ibm.ws.webcontainer.filter.webappfiltermanager.invokefilters(webappfiltermanager.java:1025) @ com.ibm.ws.webcontainer.servlet.cacheservletwrapper.handlerequest(cacheservletwrapper.java:87) @ com.ibm.ws.webcontainer.webcontainer.handlerequest(webcontainer.java:895) @ com.ibm.ws.webcontainer.wswebcontainer.handlerequest(wswebcontainer.java:1662) @ com.ibm.ws.webcontainer.channel.wcchannellink.ready(wcchannellink.java:195) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.handlediscrimination(httpinboundlink.java:452) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.handlenewrequest(httpinboundlink.java:511) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.processrequest(httpinboundlink.java:305) @ com.ibm.ws.http.channel.inbound.impl.httpiclreadcallback.complete(httpiclreadcallback.java:83) @ com.ibm.ws.ssl.channel.impl.sslreadservicecontext$sslreadcompletedcallback.complete(sslreadservicecontext.java:1784) @ com.ibm.ws.tcp.channel.impl.aioreadcompletionlistener.futurecompleted(aioreadcompletionlistener.java:165) @ com.ibm.io.async.abstractasyncfuture.invokecallback(abstractasyncfuture.java:217) @ com.ibm.io.async.asyncchannelfuture.firecompletionactions(asyncchannelfuture.java:161) @ com.ibm.io.async.asyncfuture.completed(asyncfuture.java:138) @ com.ibm.io.async.resulthandler.complete(resulthandler.java:204) @ com.ibm.io.async.resulthandler.runeventprocessingloop(resulthandler.java:775) @ com.ibm.io.async.resulthandler$2.run(resulthandler.java:905) @ com.ibm.ws.util.threadpool$worker.run(threadpool.java:1690)
my custom login module:
public class mycustomloginmodule implements worklightloginmodule { private string username ,password; public void init(map<string, string> options) throws missingconfigurationoptionexception { } public mycustomloginmodule() { resourcebundle rb = resourcebundle.getbundle("cardappsettings", locale.english); username = rb.getstring("dispatcherpushuserid") ; password = rb.getstring("dispatcherpushuserpassword") ; } public boolean login(map<string, object> authenticationdata) { system.out.println("inside push adapter "); system.out.println("login called: " + ((string)authenticationdata.get("user.name")) +"/"+ ((string)authenticationdata.get("user.password"))); system.out.println("user name:"+ ((string)authenticationdata.get("user.name")).equals(username) ); system.out.println("user password:"+ ((string)authenticationdata.get("user.password")).equals(password) ); if (((string)authenticationdata.get("user.name")).equals(username) && ((string)authenticationdata.get("user.password")).equals(password)) { system.out.println("mycustomloginmodule - user authenticated successfully"); return true; } else { system.out.println("mycustomloginmodule - throwing exception..."); throw new runtimeexception("invalid credentials");} } public useridentity createidenity(string loginmodule) { hashmap<string, object> customattributes = new hashmap<string, object>(); customattributes.put("authenticationdate", new date()); useridentity identity = new useridentity(loginmodule, username, null, null, customattributes, password); return identity; } public void logout() { username = null; password = null; } public void abort() { username = null; password = null; } @override public mycustomloginmodule clone() throws clonenotsupportedexception { return (mycustomloginmodule) super.clone(); } }
my authenticationconfig.xml
<loginmodule name="pushapploginmodule"> <classname>com.rc.mycustomloginmodule</classname> </loginmodule>
please suggest, do need declare custom authenticator ? or else missing.
thanks alot
first of all, must use authenticator , loginmodule together. login module knows how validate credentials, doesn't have clue on how collect them. according login module code looks credentials username , password. in case can use formbasedauthenticator available out of box (see wl gettings started). in case need custom logic need implement custom authenticator login module.
Comments
Post a Comment