use of com.vodafone360.people.datatypes.AuthSessionHolder in project 360-Engine-for-Android by 360.
the class LoginEngine method handleCreateSessionManualResponse.
/**
* Called when a response to the GetSessionByCredentials API is received
* (manual login). In case of success, tries to activate the account using
* the activation code received by SMS.
*
* @param data The received data
*/
private void handleCreateSessionManualResponse(List<BaseDataType> data) {
LogUtils.logD("LoginEngine.handleCreateSessionManualResponse()");
ServiceStatus errorStatus = getResponseStatus(BaseDataType.AUTH_SESSION_HOLDER_TYPE, data);
if (errorStatus == ServiceStatus.SUCCESS && (data.size() > 0)) {
setActivatedSession((AuthSessionHolder) data.get(0));
startActivateAccount();
return;
}
completeUiRequest(errorStatus, null);
}
use of com.vodafone360.people.datatypes.AuthSessionHolder in project 360-Engine-for-Android by 360.
the class Request method calculateAuth.
/**
* Calculate the Auth value for this Requester. TODO: Throttle by
* timestamp/function to prevent automatic backend log out
*/
private void calculateAuth() {
String ts = null;
if (null != mParameters) {
ts = (String) mParameters.get("timestamp");
}
if (null == ts) {
mAuthTimestamp = System.currentTimeMillis();
ts = "" + (mAuthTimestamp / 1000);
}
AuthSessionHolder session = LoginEngine.getSession();
if (session != null) {
addData("auth", SettingsManager.getProperty(Settings.APP_KEY_ID) + "::" + session.sessionID + "::" + ts);
} else {
addData("auth", SettingsManager.getProperty(Settings.APP_KEY_ID) + "::" + ts);
}
addData("auth", AuthUtils.calculateAuth(mApiMethodName, mParameters, ts, session));
/**
* if (mNeedsUserAuthentication) { addData("auth",
* AuthUtils.calculateAuth(mApiMethodName, mParameters, ts, session)); }
* else { // create the final auth without the session addData("auth",
* AuthUtils.calculateAuth(mApiMethodName, mParameters, ts, null)); }
*/
}
use of com.vodafone360.people.datatypes.AuthSessionHolder in project 360-Engine-for-Android by 360.
the class LoginEngineTest method reportBackToEngine.
@Override
public void reportBackToEngine(int reqId, EngineId engine) {
Log.d("TAG", "LoginEngineTest.reportBackToEngine");
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
switch(mState) {
case IDLE:
break;
case LOGIN_REQUEST:
case SMS_RESPONSE_SIGNIN:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
StatusMsg msg = new StatusMsg();
data.add(msg);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
mEng.onCommsInMessage();
mState = LoginTestState.LOGIN_REQUEST_VALID;
break;
case LOGIN_REQUEST_VALID:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
AuthSessionHolder sesh = new AuthSessionHolder();
data.add(sesh);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
mEng.onCommsInMessage();
mState = LoginTestState.SMS_RESPONSE_SIGNIN;
break;
case REGISTRATION:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine Registration");
data.add(mTestModule.createDummyContactData());
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SIGNUP_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case REGISTRATION_ERROR:
data.add(new ServerError(ServerError.ErrorType.UNKNOWN));
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case GET_T_AND_C:
case FETCH_PRIVACY:
case USER_NAME_STATE:
SimpleText txt = new SimpleText();
txt.addText("Simple text");
data.add(txt);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_T_AND_C_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case SERVER_ERROR:
data.add(new ServerError(ServerError.ErrorType.UNKNOWN));
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
default:
}
}
use of com.vodafone360.people.datatypes.AuthSessionHolder in project 360-Engine-for-Android by 360.
the class HeartbeatSenderThread method sendHeartbeat.
/**
* Prepares the necessary Hessian payload and writes it directly to the open
* output-stream of the socket.
*
* @throws Exception Thrown if there was an unknown problem writing to the
* output-stream.
* @throws IOException Thrown if there was a problem regarding IO while
* writing to the output-stream.
*/
public void sendHeartbeat() throws IOException, Exception {
byte[] rpgMsg = null;
try {
rpgMsg = getHeartbeatHessianPayload();
} catch (NullPointerException e) {
// Stop connnection and log out
ConnectionManager.getInstance().onLoginStateChanged(false);
EngineManager.getInstance().getLoginEngine().logoutAndRemoveUser();
}
try {
// Try and issue the request
if (Settings.sEnableProtocolTrace) {
Long userID = null;
AuthSessionHolder auth = LoginEngine.getSession();
if (auth != null) {
userID = auth.userID;
}
HttpConnectionThread.logI("RpgTcpHeartbeatSender.sendHeartbeat()", "\n * Sending a heartbeat for user ID " + userID + "----------------------------------------" + HessianUtils.getInHessian(new ByteArrayInputStream(rpgMsg), true) + "\n");
}
if (null != mOs) {
synchronized (mOs) {
mOs.write(rpgMsg);
mOs.flush();
}
}
} catch (IOException ioe) {
HttpConnectionThread.logE("RpgTcpHeartbeatSender.sendHeartbeat()", "Could not write HB to OS!", ioe);
throw ioe;
} catch (Exception e) {
HttpConnectionThread.logE("RpgTcpHeartbeatSender.sendHeartbeat()", "Could not send HB to OS! Unknown: ", e);
throw e;
} finally {
rpgMsg = null;
}
}
use of com.vodafone360.people.datatypes.AuthSessionHolder in project 360-Engine-for-Android by 360.
the class StateTable method fetchSession.
/**
* Fetches the current session from the database.
*
* @param readableDb Readable SQLite database for fetching the information
* @return The session object or null if the session was not available.
*/
public static AuthSessionHolder fetchSession(final SQLiteDatabase readableDb) {
Cursor cursor = null;
try {
cursor = readableDb.rawQuery("SELECT " + Field.SESSIONID + "," + Field.SESSIONSECRET + "," + Field.SESSIONUSERID + "," + Field.SESSIONUSERNAME + " FROM " + TABLE_NAME + " WHERE " + Field.STATEID + " = " + PRIMARY_STATE_KEY_VALUE, null);
if (!cursor.moveToFirst()) {
LogUtils.logE("StateTable.fetchSession() " + "Unable to find session info in the database");
return null;
}
if (cursor.isNull(cursor.getColumnIndex(Field.SESSIONID.toString())) || cursor.isNull(cursor.getColumnIndex(Field.SESSIONSECRET.toString())) || cursor.isNull(cursor.getColumnIndex(Field.SESSIONUSERID.toString())) || cursor.isNull(cursor.getColumnIndex(Field.SESSIONUSERNAME.toString()))) {
LogUtils.logE("StateTable.fetchSession() " + "Unable to find session data in the database");
return null;
}
final AuthSessionHolder session = new AuthSessionHolder();
session.sessionID = SqlUtils.setString(cursor, Field.SESSIONID.toString());
session.sessionSecret = SqlUtils.setString(cursor, Field.SESSIONSECRET.toString());
session.userID = SqlUtils.setLong(cursor, Field.SESSIONUSERID.toString(), -1L);
session.userName = SqlUtils.setString(cursor, Field.SESSIONUSERNAME.toString());
DatabaseHelper.trace(false, "StateTable.fetchSession() " + "Fetched session[" + session.sessionID + "]");
return session;
} catch (Exception e) {
LogUtils.logE("StateTable.fetchSession() Exception - " + "Unable to fetch session from database", e);
return null;
} finally {
CloseUtils.close(cursor);
}
}
Aggregations