Тема: Login
Hello,
I am new in the use of the sdk Java of wialon. I would simply like all to connect me to the hosting
of wialon via my application server to get back certain information.
Here is the class which I established for the authentification.
public class WialonGeoZone
{
private final static Logger logger = LoggerFactory.getLogger(WialonGeoZone.class);
private String sessionId;
private long resourceId;
private final String parentLink = "http://kit-api.wialon.com/wialon/ajax.html?";
private Session session;
public WialonGeoZone()
{
session = Session.getInstance();
logger.info("session it is initialize");
sessionId = null;
resourceId = -1;
}
public void login()
{
// TODO : Change logic implementation of this method
logger.info("Beginning login Wialon SDK");
boolean b = session.initSession("http://kit-api.wialon.com");
session.loginToken("251a59d6b516d93194ebc406b8a79d19EB12425ABF6BDFEFA7C8E0D9954A5C4C235943A8",
new ResponseHandler()
{
@Override
public void onSuccess(String response)
{
super.onSuccess(response);
System.out.println(response);
logger.info("Login is executed with success");
logger.info("User Wialon it is "+session.getCurrUser().getName());
obtainSessionId();
logout(1);
}
@Override
public void onFailure(int errorCode, Throwable throwableError)
{
super.onFailure(errorCode, throwableError);
System.out.println(errorCode);
logger.info("Login is execute with error");
logger.info("Error code it is "+errorCode);
if(throwableError != null)
logger.error("Error login is caused by "+throwableError.getMessage());
else
logger.error("Error login. ThrowableError it is null");
}
});
}
public void logout(int flags)
{
session.logout(flags, new ResponseHandler()
{
@Override
public void onSuccess(String response)
{
super.onSuccess(response);
logger.info("Logout is executed with success");
logger.info("User Wialon it is "+session.getCurrUser().getName());
}
@Override
public void onFailure(int errorCode, Throwable throwableError)
{
super.onFailure(errorCode, throwableError);
logger.info("Logout is execute with error");
logger.error("Error login is caused by "+throwableError.getMessage());
}
});
}
private void obtainSessionId()
{
if(session.getId() != null)
{
sessionId = session.getId();
logger.info("SessionId it is : "+sessionId);
}
}
}
As mentioned in the documentation me got back my token from this link http://hosting.wialon.com/login.html by registering my to user name and my password.
But I receive an error (error code 8) message indicating to me that my user name or my password is not valid.
Then I tried with this code.
public class WialonGeoZone
{
private final static Logger logger = LoggerFactory.getLogger(WialonGeoZone.class);
private String sessionId;
private long resourceId;
private final String parentLink = "http://kit-api.wialon.com/wialon/ajax.html?";
private Session session;
public WialonGeoZone()
{
session = Session.getInstance();
logger.info("session it is initialize");
sessionId = null;
resourceId = -1;
}
public void login()
{
// TODO : Change logic implementation of this method
logger.info("Beginning login Wialon SDK");
boolean b = session.initSession("http://kit-api.wialon.com");
session.login("user_name","password",
new ResponseHandler()
{
@Override
public void onSuccess(String response)
{
super.onSuccess(response);
System.out.println(response);
logger.info("Login is executed with success");
logger.info("User Wialon it is "+session.getCurrUser().getName());
obtainSessionId();
logout(1);
}
@Override
public void onFailure(int errorCode, Throwable throwableError)
{
super.onFailure(errorCode, throwableError);
System.out.println(errorCode);
logger.info("Login is execute with error");
logger.info("Error code it is "+errorCode);
if(throwableError != null)
logger.error("Error login is caused by "+throwableError.getMessage());
else
logger.error("Error login. ThrowableError it is null");
}
});
}
public void logout(int flags)
{
session.logout(flags, new ResponseHandler()
{
@Override
public void onSuccess(String response)
{
super.onSuccess(response);
logger.info("Logout is executed with success");
logger.info("User Wialon it is "+session.getCurrUser().getName());
}
@Override
public void onFailure(int errorCode, Throwable throwableError)
{
super.onFailure(errorCode, throwableError);
logger.info("Logout is execute with error");
logger.error("Error login is caused by "+throwableError.getMessage());
}
});
}
private void obtainSessionId()
{
if(session.getId() != null)
{
sessionId = session.getId();
logger.info("SessionId it is : "+sessionId);
}
}
}
But I always receive the same error (error code 8).
However I arrive well at me connected to wialon hosting with my identifiers.
Sorry for my bad english.