Cred* CredentialHandler::getClientCredential() { Authentication* auth = NULL; char* credential = NULL; if (strcmp(clientAuthType, AUTH_TYPE_MD5) == 0) { credential = MD5CredentialData(username, password, clientNonce); auth = new Authentication(AUTH_TYPE_MD5, credential); // overwrite the username that for MD5 auth is the same as data auth->setUsername(username); auth->setPassword(password); if (credential) { delete [] credential; credential = NULL; } } else if (strcmp(clientAuthType, AUTH_TYPE_OAUTH) == 0) { OAuth2JsonParser jsonParser; StringBuffer creds = jsonParser.formatOAuth2CredentialData(oauth2Credentials.getAccessToken(), oauth2Credentials.getRefreshToken(), oauth2Credentials.getClientType(), oauth2Credentials.getExpiresIn(), oauth2AccessTokenSetTime); if (creds.empty()) { LOG.error("%s: could not set oauth2 auth credentials for SyncML request", __FUNCTION__); return NULL; } auth = new Authentication(AUTH_TYPE_OAUTH, creds.c_str()); auth->setUsername(username); } else if (strcmp(clientAuthType, AUTH_TYPE_RADIUS_PROXY) == 0) { auth = new Authentication(AUTH_TYPE_RADIUS_PROXY, username, "Funambol"); } else { auth = new Authentication(AUTH_TYPE_BASIC, username, password); } Cred* cred = new Cred(auth); deleteAuthentication(&auth); return cred; }
int GameLauncher::commandGen( ) { Authentication auth; auth.setUsername( username ); auth.setPassword( password ); QByteArray mainClass; QString arguments; QFile mainClassFile(QDir::currentPath()+"/versions/"+version+"/mainClass.txt" ); if( mainClassFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { QTextStream in( &mainClassFile ); mainClass = in.readAll().toLocal8Bit(); mainClassFile.close(); } else return -666; QFile argFile( QDir::currentPath()+"/versions/"+version+"/arguments.txt" ); if( argFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { QTextStream in( &argFile ); arguments = in.readAll().toLocal8Bit(); } else return -666; qDebug() << arguments; if( isLegit() ) { QString result = ""; QString gameUsername = ""; QEventLoop eventLoop; QNetworkAccessManager mgr; int errCode; errCode = auth.login( &mgr ); arguments.replace( "${auth_player_name}", auth.getGameUsername() ); arguments.replace( "${auth_session}", "token:"+auth.getAccessToken().toLocal8Bit()+":"+auth.getClientId().toLocal8Bit() ); arguments.replace( "${version_name}", version ); arguments.replace( "${game_directory}", "\""+mainPath+"\"" ); arguments.replace( "${game_assets}", "\""+mainPath+slash+"assets\"" ); command.append("java ").append(" -Djava.library.path=\""+mainPath+slash+"natives\"") .append( libPathGen() ).append(" "+mainClass+" ").append( arguments ); return errCode; } else { arguments.replace( "${auth_player_name}", auth.getUsername() ); arguments.replace( "${auth_session}", "token:"+auth.getAccessToken().toLocal8Bit()+":"+auth.getClientId().toLocal8Bit() ); arguments.replace( "${version_name}", version ); arguments.replace( "${game_directory}", "\""+mainPath+"\"" ); arguments.replace( "${game_assets}", "\""+mainPath+slash+"assets\"" ); command.append("java ").append(" -Djava.library.path=\""+mainPath+slash+"natives\"") .append( libPathGen() ).append(" "+mainClass+" ").append( arguments ); } return 0; }