Esempio n. 1
0
// Main prompts player to indicate new or existing user, then calls the appropriate function for either. Afterward,
// the function containing the adventure game is called.
int main(int argc, char *argv[]) {
    msgDisplay(0);
    void gameBegin(string);
    bool rightInp = false;

    while (rightInp == false){	
        string input;
	cout << "> ";
	cin >> input;
	if (input == "l"){          // Existing user
		rightInp = true;
		game.login(); 
		gameBegin(game.getUserName());
	}
	else if ( input == "n"){    // New user
		rightInp = true;
		game.newUser();
		gameBegin(game.getUserName());
	}
	else {
		msgDisplay(1);     // Instructions reiterated if invalid entry given
	}
    }
   return 0;
}
Esempio n. 2
0
void TcpClient::handleRegisterAck(RecvStream *prs)
{
	RegisterAck ra;
	ra.fromStream(prs->stream, prs->size);
	WORD serialNumber = ra.sn;
	cout<<"sn:"<<ra.sn<<endl;
	pthread_mutex_lock(&mutexserialNumber);
	serialNumberList.push_front(serialNumber);
	pthread_mutex_unlock(&mutexserialNumber);

	if(ra.result == 0)
	{
		Authentication au;
		au.code = ra.authenticationCode;
		au.header.property = 12+au.code.length() +1;
		memcpy(au.header.phoneNumber, m_phoneNumber,6);
		Msg msg;
		unsigned char ori[1024];
		int len;
		len = au.toStream(ori);
		len = addCheckCode(ori,len);

		toComposedMsg(ori,len, msg.stream, &(msg.len));
		msg.resendTimes=0;
		msg.msgSerialNumber = au.header.msgSerialNumber;
		msg.sendChars = 0;
		msg.complete = false;
		pthread_mutex_lock(&mutex);
		msgList.push_front(msg);
		pthread_mutex_unlock(&mutex);

	}
}
Esempio n. 3
0
void Session::Impl::SetAuth(const Authentication& auth) {
    auto curl = curl_->handle;
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_easy_setopt(curl, CURLOPT_USERPWD, auth.GetAuthString());
    }
}
	status_t SetAuthentication(const char* share, const char* user,
		const char* password)
	{
		// check, if an entry already exists for the share -- if it does,
		// just set it
		Authentication* authentication = fAuthentications.Get(share);
		if (authentication)
			return authentication->SetTo(user, password);
		// the entry does not exist yet: create and add a new one
		authentication = new(nothrow) Authentication;
		if (!authentication)
			return B_NO_MEMORY;
		status_t error = authentication->SetTo(user, password);
		if (error == B_OK)
			error = fAuthentications.Put(share, authentication);
		if (error != B_OK)
			delete authentication;
		return error;
	}
Esempio n. 5
0
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;

}
Esempio n. 6
0
void RtspSocket::slotAuthenticationRequired ( QNetworkReply * , QAuthenticator * authenticator )
{
    QDEBUG << tr("User: ")+authenticator->user();
    if( !authenticator->user().isEmpty() )
    {
        if( authenticator->user() == _url.userName() && authenticator->password() == _url.password() )
        {
            _url.setUserName(DEFAULT_USERNAME);
            _url.setPassword(DEFAULT_PASSWORD);
        } else
        {
            Authentication auth;
            auth.setValues(_url.userName(), _url.password(), false);
            auth.show();
            if( auth.exec() )
            {
                _url.setUserName(auth.getUser());
                _url.setPassword(auth.getPass());
            }
        }
    }
    authenticator->setUser(_url.userName());
    authenticator->setPassword(_url.password());
}
Esempio n. 7
0
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;
}