Topic
1 reply Latest Post - ‏2013-02-01T13:22:00Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts
ACCEPTED ANSWER

Pinned topic Push notifications and adapter based authentication. How to?

‏2013-02-01T11:23:48Z |
Hi,

I have two adapters, a SQL adapter and a push adapter. Both adapters deploy without errors. I (think) I would like to use one security realm. I have defined two security-tests using the same realm: one for the protected SQL calls and one for the push adapter. My authenticationConfig.xml looks like this


<securityTests> <customSecurityTest name=
"mychAdapter-securityTest"> <test isInternalUserID=
"true" realm=
"mychAuthRealm"/> </customSecurityTest> <mobileSecurityTest name=
"push-securityTest"> <testUser realm=
"mychAuthRealm"/> <testDeviceId provisioningType=
"none"/> </mobileSecurityTest> </securityTests> <realms> <realm name=
"mychAuthRealm" loginModule=
"mychAuthLoginModule"> <className>com.worklight.integration.auth.AdapterAuthenticator</className> <parameter name=
"login-function" value=
"mychAdapter.onAuthRequired"/> <parameter name=
"logout-function" value=
"mychAdapter.onLogout"/> </realm> </realms>   <loginModules> <loginModule name=
"mychAuthLoginModule"> <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className> </loginModule> </loginModule --> </loginModules>


I read that the onReadyToSubscribe event fires when the user is authenticated. When the user is authenticated (based on the customSecurityTest) the event does not fire. I do not understand why. When I try to subscribe anyway I see an error "Can't subscribe, notification token is not updated on server".

My aim is to have the user only authenticate once. When he is authenticated he should be able to subscribe to push notifications.

So, what is the best way to get this done?

Thanks for your time!
  • SystemAdmin
    SystemAdmin
    2327 Posts
    ACCEPTED ANSWER

    Re: Push notifications and adapter based authentication. How to?

    ‏2013-02-01T13:22:00Z  in response to SystemAdmin
    Well, the above does work. The problem I face has to do with a number of mistakes I made:
    1) I was testing in Browser Preview, not on a real device;
    2) I was looking for the onReadyToSubscribe test message in the wrong place (browser (client) log instead of server log);
    3) The onReadyToSubscribe event is triggered even when the user is not authenticated!!!