void Gui_Admin::addUser(){ //QTextStream(stdout)<<_type->currentIndex(); if(_username->text()!= "" && _password->text()!= "" && _name->text()!= "" && _surname->text()!= ""){ Username credential(_username->text().toStdString(),_password->text().toStdString()); Info* info = new Info(QDate::currentDate(), _name->text().toStdString(), _surname->text().toStdString()); accountType t = static_cast<accountType>(_type->currentIndex()); Account* acc=new Account(info, credential, t); User* usr = NULL; switch(t){ case 0: usr = new BasicUser(acc); break; case 1: usr = new BusinessUser(acc); break; case 2: usr = new ExecutiveUser(acc); break; } db->addUser(usr); db->save(); usersList->insertItem(usersList->count(), _username->text()); addUserPage->close(); } else{ QMessageBox* err = new QMessageBox(); err->setText("All fields are mandatory"); err->show(); } }
void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) { LOG(Network, "CFNet - didReceiveAuthenticationChallenge()"); ASSERT(d->m_currentWebChallenge.isNull()); // Since CFURLConnection networking relies on keeping a reference to the original CFURLAuthChallengeRef, // we make sure that is actually present ASSERT(challenge.cfURLAuthChallengeRef()); ASSERT(challenge.authenticationClient() == this); // Should be already set. if (!d->m_user.isNull() && !d->m_pass.isNull()) { RetainPtr<CFStringRef> user(AdoptCF, d->m_user.createCFString()); RetainPtr<CFStringRef> pass(AdoptCF, d->m_pass.createCFString()); RetainPtr<CFURLCredentialRef> credential(AdoptCF, CFURLCredentialCreate(kCFAllocatorDefault, user.get(), pass.get(), 0, kCFURLCredentialPersistenceNone)); KURL urlToStore; if (challenge.failureResponse().httpStatusCode() == 401) urlToStore = firstRequest().url(); CredentialStorage::set(core(credential.get()), challenge.protectionSpace(), urlToStore); CFURLConnectionUseCredential(d->m_connection.get(), credential.get(), challenge.cfURLAuthChallengeRef()); d->m_user = String(); d->m_pass = String(); // FIXME: Per the specification, the user shouldn't be asked for credentials if there were incorrect ones provided explicitly. return; } if (!client() || client()->shouldUseCredentialStorage(this)) { if (!d->m_initialCredential.isEmpty() || challenge.previousFailureCount()) { // The stored credential wasn't accepted, stop using it. // There is a race condition here, since a different credential might have already been stored by another ResourceHandle, // but the observable effect should be very minor, if any. CredentialStorage::remove(challenge.protectionSpace()); } if (!challenge.previousFailureCount()) { Credential credential = CredentialStorage::get(challenge.protectionSpace()); if (!credential.isEmpty() && credential != d->m_initialCredential) { ASSERT(credential.persistence() == CredentialPersistenceNone); if (challenge.failureResponse().httpStatusCode() == 401) { // Store the credential back, possibly adding it as a default for this directory. CredentialStorage::set(credential, challenge.protectionSpace(), firstRequest().url()); } RetainPtr<CFURLCredentialRef> cfCredential(AdoptCF, createCF(credential)); CFURLConnectionUseCredential(d->m_connection.get(), cfCredential.get(), challenge.cfURLAuthChallengeRef()); return; } } } d->m_currentWebChallenge = challenge; if (client()) client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); }
void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) { if (!d->m_user.isNull() && !d->m_pass.isNull()) { Credential credential(d->m_user, d->m_pass, CredentialPersistenceNone); URL urlToStore; if (challenge.failureResponse().httpStatusCode() == 401) urlToStore = challenge.failureResponse().url(); CredentialStorage::set(credential, challenge.protectionSpace(), urlToStore); String userpass = credential.user() + ":" + credential.password(); curl_easy_setopt(d->m_handle, CURLOPT_USERPWD, userpass.utf8().data()); d->m_user = String(); d->m_pass = String(); // FIXME: Per the specification, the user shouldn't be asked for credentials if there were incorrect ones provided explicitly. return; } if (shouldUseCredentialStorage()) { if (!d->m_initialCredential.isEmpty() || challenge.previousFailureCount()) { // The stored credential wasn't accepted, stop using it. // There is a race condition here, since a different credential might have already been stored by another ResourceHandle, // but the observable effect should be very minor, if any. CredentialStorage::remove(challenge.protectionSpace()); } if (!challenge.previousFailureCount()) { Credential credential = CredentialStorage::get(challenge.protectionSpace()); if (!credential.isEmpty() && credential != d->m_initialCredential) { ASSERT(credential.persistence() == CredentialPersistenceNone); if (challenge.failureResponse().httpStatusCode() == 401) { // Store the credential back, possibly adding it as a default for this directory. CredentialStorage::set(credential, challenge.protectionSpace(), challenge.failureResponse().url()); } String userpass = credential.user() + ":" + credential.password(); curl_easy_setopt(d->m_handle, CURLOPT_USERPWD, userpass.utf8().data()); return; } } } d->m_currentWebChallenge = challenge; if (client()) client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); }
void TestController::didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge) { String message; if (!m_handlesAuthenticationChallenges) message = "<unknown> - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n"; else message = String::format("<unknown> - didReceiveAuthenticationChallenge - Responding with %s:%s\n", m_authenticationUsername.utf8().data(), m_authenticationPassword.utf8().data()); m_currentInvocation->outputText(message); WKAuthenticationDecisionListenerRef decisionListener = WKAuthenticationChallengeGetDecisionListener(authenticationChallenge); if (!m_handlesAuthenticationChallenges) { WKAuthenticationDecisionListenerUseCredential(decisionListener, 0); return; } WKRetainPtr<WKStringRef> username(AdoptWK, WKStringCreateWithUTF8CString(m_authenticationUsername.utf8().data())); WKRetainPtr<WKStringRef> password(AdoptWK, WKStringCreateWithUTF8CString(m_authenticationPassword.utf8().data())); WKRetainPtr<WKCredentialRef> credential(AdoptWK, WKCredentialCreate(username.get(), password.get(), kWKCredentialPersistenceForSession)); WKAuthenticationDecisionListenerUseCredential(decisionListener, credential.get()); }
void storeCredential(const char* url, WebString& realm, WebString& scheme, WebString& user, WebString& password) { WebCore::Credential credential(user, password, WebCore::CredentialPersistenceForSession); WebCore::CredentialStorage::set(credential, getProtectionSpace(url, realm, scheme), WebCore::KURL(WebCore::KURL(), url)); }
// --------------------------------------------------------- // CNSmlCmdsBase::ProcessSyncHdrL // Process received SyncHdr element // --------------------------------------------------------- EXPORT_C void CNSmlCmdsBase::ProcessSyncHdrL( SmlSyncHdr_t* aSyncHdr ) { if ( !aSyncHdr ) { User::Leave( TNSmlError::ESmlSyncHdrMissing ); } // Status response flag if ( IsFlagSet( aSyncHdr->flags, SmlNoResp_f ) ) { iStatusToServerNoResponse = ETrue; } else { iStatusToServerNoResponse = EFalse; } // build corresponding status element to server if ( !iStatusToServer ) { iStatusToServer = CNSmlStatusContainer::NewL(); } iStatusToServer->InitMsgRefL( aSyncHdr->msgID ); delete iCurrServerMsgID; iCurrServerMsgID = NULL; iCurrServerMsgID = HBufC8::NewL(0); TInt statusID; statusID = iStatusToServer->CreateNewStatusElementL(); HBufC8* cmdRef = HBufC8::NewLC( KNSmlAgentSyncHdrCmdID.iTypeLength ); *cmdRef = KNSmlAgentSyncHdrCmdID; SmlPcdata_t* cmdRefElement; PcdataNewL ( cmdRefElement, *cmdRef ); CleanupStack::PushL( cmdRefElement ); iStatusToServer->SetCmdRefL( statusID, cmdRefElement ); CleanupStack::PopAndDestroy( 2 ); //cmdRefElement, cmdRef iStatusToServer->SetCmdL( statusID, KNSmlAgentSyncHdr ); iStatusToServer->SetNoResponse( statusID, IsFlagSet( aSyncHdr->flags, SmlNoResp_f ) ); iStatusToServer->AddTargetRefL( statusID, aSyncHdr->target ); iStatusToServer->AddSourceRefL( statusID, aSyncHdr->source ); iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusOK ); //respURI if ( aSyncHdr->respURI ) { HBufC* respURI; PCDATAToUnicodeLC( *aSyncHdr->respURI, respURI ); respURI->Des().TrimRight(); if ( respURI->Length() > 0 ) { delete iRespURI; iRespURI = NULL; iRespURI = CNSmlURI::NewL( *respURI ); } CleanupStack::PopAndDestroy(); //respURI } // verDTD and verProto (Check only once) // sync is interrupted if version is other than 1.1 if ( !iVersionCheck ) { iVersionIsChecked = ETrue; } if ( !iVersionIsChecked ) { if ( !aSyncHdr->version->content ) { iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusVersionNotSupported ); iAgent->Interrupt( TNSmlError::ESmlVerDTDMissing, EFalse, EFalse ); return; } TPtr8 verDTD( (TUint8*) aSyncHdr->version->content, aSyncHdr->version->length, aSyncHdr->version->length ); TrimRightSpaceAndNull( verDTD ); //1.2 CHANGES: 1.1 and 1.2 version support if ( ( verDTD != KNSmlAgentVerDTD11 ) && (verDTD != KNSmlAgentVerDTD12 )) { iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusVersionNotSupported ); SmlPcdata_t* data = NULL; PcdataNewL( data, *iVerDTD ); //changes end CleanupStack::PushL( data ); iStatusToServer->AddItemDataL( statusID, data ); CleanupStack::PopAndDestroy(); //data iAgent->Interrupt( TNSmlError::ESmlVerDTDNotSupported, EFalse, EFalse ); return; } if ( !aSyncHdr->proto->content ) { iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusProtocolVersionNotSupported ); iAgent->Interrupt( TNSmlError::ESmlVerProtoMissing, EFalse, EFalse ); return; } TPtr8 verProto( (TUint8*) aSyncHdr->proto->content, aSyncHdr->proto->length, aSyncHdr->proto->length ); TrimRightSpaceAndNull( verProto ); if ( verProto != *iVerProto ) { iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusProtocolVersionNotSupported ); SmlPcdata_t* data = NULL; PcdataNewL( data, *iVerProto ); CleanupStack::PushL( data ); iStatusToServer->AddItemDataL( statusID, data ); CleanupStack::PopAndDestroy(); //data iAgent->Interrupt( TNSmlError::ESmlVerProtoNotSupported, EFalse, EFalse ); return; } iVersionIsChecked = ETrue; } // msgID TPtr8 msgID( (TUint8*) aSyncHdr->msgID->content, aSyncHdr->msgID->length, aSyncHdr->msgID->length ); delete iCurrServerMsgID; iCurrServerMsgID = NULL; iCurrServerMsgID = msgID.AllocL(); if ( msgID.Length() == 0 ) { iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusIncompleteCommand ); iAgent->Interrupt( TNSmlError::ESmlMsgIDMissing, EFalse, EFalse ); return; } // target // here must be client's Source (IMEI), check that client has got its message if ( !aSyncHdr->target ) { iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusIncompleteCommand ); iAgent->Interrupt( TNSmlError::ESmlTargetLocURIMissing, EFalse, EFalse ); return; } else if ( !aSyncHdr->target->locURI ) { iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusIncompleteCommand ); iAgent->Interrupt( TNSmlError::ESmlTargetLocURIMissing, EFalse, EFalse ); return; } else { HBufC* syncHdrTarget; PCDATAToUnicodeLC( *aSyncHdr->target->locURI, syncHdrTarget ); syncHdrTarget->Des().TrimRight(); CNSmlURI* syncHdrTargetURI = CNSmlURI::NewLC( *syncHdrTarget ); if ( syncHdrTargetURI->HostName().Length() != 0 && syncHdrTargetURI->HostName() != _L("/") ) { HBufC* imeiCode = HBufC::NewLC( 50 ); TPtr imeiCodePtr = imeiCode->Des(); iPhoneInfo->PhoneDataL( CNSmlPhoneInfo::EPhoneSerialNumber, imeiCodePtr ); if ( syncHdrTargetURI->HostName() != *imeiCode ) { iUnknownDevice = ETrue; iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusNotFound ); CleanupStack::PopAndDestroy( 3 ); //imeiCode, syncHdrTargetURI,syncHdrTarget iAgent->Interrupt( TNSmlError::ESmlTargetLocURIInvalid, EFalse, EFalse ); return; } CleanupStack::PopAndDestroy(); //imeiCode } CleanupStack::PopAndDestroy( 2 ); //syncHdrTargetURI, syncHdrTarget } // Cred if ( aSyncHdr->cred ) { HBufC8* type = MetaTypeInUtf8LC( aSyncHdr->cred->meta ); iServerAuth->SetTypeL( *type ); CleanupStack::PopAndDestroy(); //type HBufC8* format = MetaFormatInUtf8LC( aSyncHdr->cred->meta ); iServerAuth->SetFormatL( *format ); CleanupStack::PopAndDestroy(); //format if ( aSyncHdr->cred->data ) { if ( aSyncHdr->cred->data->content ) { TPtr8 credential( (TUint8*) aSyncHdr->cred->data->content, aSyncHdr->cred->data->length, aSyncHdr->cred->data->length ); iServerAuth->SetCredentialL( credential ); } } } TNSmlError::TNSmlSyncMLStatusCode authStatus = iServerAuth->StatusCodeL(); iStatusToServer->SetStatusCodeL( statusID, authStatus ); if ( authStatus == TNSmlError::ESmlStatusUnauthorized ) { iAgent->Interrupt( TNSmlError::ESmlServerUnauthorized, EFalse, ETrue ); iServerAuth->CreateAndSaveNewNonceL(); } if ( iServerAuth->ChallengeNeeded() ) { iStatusToServer->SetChalL( statusID, iServerAuth->NonceL() ); iServerAuth->SetChallenced(); } //MaxMsgSize //Client must obey this value in the next message to server if ( aSyncHdr->meta ) { if ( ( aSyncHdr->meta->content ) && ( aSyncHdr->meta->contentType == SML_PCDATA_EXTENSION ) && ( aSyncHdr->meta->extension == SML_EXT_METINF ) ) { SmlMetInfMetInf_t* metInf; metInf = (SmlMetInfMetInf_t*) aSyncHdr->meta->content; if ( metInf->maxmsgsize ) { if ( metInf->maxmsgsize->content ) { TPtr8 maxMsgSize( (TUint8*) metInf->maxmsgsize->content, metInf->maxmsgsize->length, metInf->maxmsgsize->length ); TrimRightSpaceAndNull( maxMsgSize ); TLex8 lexicalValue( maxMsgSize ); TInt maxMsgSizeNum; if ( lexicalValue.Val( maxMsgSizeNum ) != KErrNone ) { iStatusToServer->SetStatusCodeL( statusID, TNSmlError::ESmlStatusIncompleteCommand ); iAgent->Interrupt( TNSmlError::ESmlMaxMsgSizeInvalid, EFalse, EFalse ); return; } else { if ( maxMsgSizeNum < KNSmlMininumWorkspaceSize ) { iWorkspaceSize = maxMsgSizeNum; } else { if ( maxMsgSizeNum > iMaxWorkspaceSize ) { iWorkspaceSize = iMaxWorkspaceSize; } else { iWorkspaceSize = maxMsgSizeNum; } } } } } } } iServerMaxObjectSize = ServerMaxObjSize( aSyncHdr->meta ); }