Sending ISFSObject at Login

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

sylhouette
Posts: 20
Joined: 09 Oct 2011, 01:29
Location: Indonesia
Contact:

Sending ISFSObject at Login

Postby sylhouette » 10 Oct 2011, 12:00

How can I send a ISFSObject as additional param during login to the server extension?

My android code snippet looks like this:

Code: Select all

ISFSObject sfsObj = SFSObject.newInstance();
sfsObj.putUtfString("clearPass",securePassword);
sfsClient.send(new LoginRequest(txtUsername.getText().toString(),securePassword,getString(R.string.zone), sfsObj));


And my LoginHandler looks like this:

Code: Select all

public class LoginHandler extends BaseServerEventHandler {
public void handleServerEvent(ISFSEvent event) throws SFSException {
      String username = (String) event.getParameter(SFSEventParam.LOGIN_NAME);
      String password = (String) event
            .getParameter(SFSEventParam.LOGIN_PASSWORD);
      ISession session = (ISession) event.getParameter(SFSEventParam.SESSION);

      
                     //something here
                 
}
}


How can I retrieve the

Code: Select all

sfsObj.putUtfString("clearPass",securePassword);

I send at login? I need it to be checked using the

Code: Select all

getApi().checkSecurePassword(session, clearPass, encryptedPass);


Anyone can help me? I am very new to SFS2X development and I would love to learn more :) Thank you very much
User avatar
Bax
Site Admin
Posts: 4610
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 10 Oct 2011, 13:34

I don't understand why you need to make the client send the password in clear to the server. The checkSecurePassword method should be used to validate the encrypted password sent by the client with the one retrieved (during the login process) from a database.

Anyway, to retrieve the additional params object sent by the client you have to use:

Code: Select all

ISFSObject params = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_IN_DATA);
Paolo Bax
The SmartFoxServer Team
sylhouette
Posts: 20
Joined: 09 Oct 2011, 01:29
Location: Indonesia
Contact:

Postby sylhouette » 10 Oct 2011, 14:14

OK, thank you very much for your help :)

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 2 guests