コード例 #1
0
// --------------------------------
// CNSmlRoamTable::PutItemsL( TInt aProfileId, CNSmlIAPArray* aItems )
// Put items from array to table for profile id
// --------------------------------
//
EXPORT_C void CNSmlRoamTable::PutItemsL( TInt aProfileId, CNSmlIAPArray* aItems )
	{
	TInt count(0);
	
	RDbView view;
	CleanupClosePushL( view );

	CNSmlRoamItem item;

	User::LeaveIfNull( aItems );

	if (! IsNewItemL(view, aProfileId))
		{
		count = view.CountL();
		
		if ( count > aItems->Count() )
			{
			RemoveAllByIdL(aProfileId);
			}
		}

	for (TInt i = 0; i < aItems->Count(); i++)
		{
		item.iProfileId= aProfileId;
		item.iPriority = i;
		item.iIAPId = aItems->At(i);
		HandleItemL( item );
		}
	
	CleanupStack::PopAndDestroy(); //view
	}
コード例 #2
0
//Read aItem from DSC DB either by fileName, argList and dscId, or by itemId and dscId	
void CDscDatabase::ReadItemL(CDscItem& aItem)
	{
	//Leave if DB is opened for enumeration	
	if (iIsEnumOpened)
		{
		User::Leave(KErrLocked);
		}
		
	DatabaseBeginLC();	

	RDbView view;
	CleanupClosePushL(view);
	
	QueryItemL(view,  aItem);
	if(view.CountL()==0)
		{
		 //aItem does not exist
		User::Leave(KErrNotFound);	
		}
	else
		{
		view.FirstL(); 
		ReadDscItemL(view, aItem);
		}
	
	CleanupStack::PopAndDestroy(2); //view and CleanupDatabaseRollback
	}
コード例 #3
0
TBool CSCPParamDB :: IsParamValueSharedL(HBufC* aParamValue, const TInt32 aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> IsParamValueShared >>>"));
    
    if(aParamValue == NULL) {
        return KErrArgument;
    }
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry  = HBufC :: NewLC(KSelectAppIDParamValNotIn().Length() + aParamValue->Des().Length() + 50);
    lSelectQry->Des().Format(KSelectAppIDParamValNotIn, aApp, &aParamValue->Des());
    
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    
    TInt lRowCnt(0);
    TInt lStatus(KErrNone);
    
    TRAP(lStatus, lRowCnt = lDBView.CountL());
    
    if(lStatus != KErrNone) {
        _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: Unable to determine row count..."));    
    }
    else {
        if(lRowCnt > 0) {
            CleanupStack :: PopAndDestroy(2);
            return ETrue;
        }
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> IsParamValueShared <<<"));
    CleanupStack :: PopAndDestroy(2);
    return EFalse;
}
コード例 #4
0
TInt CSCPParamDB :: GetValueForParameterL(TInt aParamID, TInt32& aValue, TInt32& aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL >>>"));

    RDbView lDBView;
    CleanupClosePushL(lDBView);

    HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamId().Length() + 15);
    lSelectQry->Des().Format(KSelectWhereParamId, aParamID);

    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    if( lDBView.FirstL())
    {
    	TInt lRowCount = lDBView.CountL();

    	if(lRowCount == 0) {
        _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
        CleanupStack :: PopAndDestroy(2);
        return KErrNotFound;
    	}
    	else if(lRowCount > 1) {
        _SCPDB_LOG(_L("[CSCPParamDB]-> ERROR: More than one record matches the criterion. Db is corrupt! Leaving..."));
        User :: Leave(KErrCorrupt);
    	}

    	lDBView.GetL();
    	aApp = lDBView.ColInt(iColSet->ColNo(KColAppId));
    	aValue = lDBView.ColInt(iColSet->ColNo(KColValueInt));
    }
    CleanupStack :: PopAndDestroy(2);

    _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL <<<"));
    return KErrNone;
}
コード例 #5
0
/**
@SYMTestCaseID SYSLIB-DBMS-CT-0018
@SYMTestCaseDesc Open table test.
				 This test app has no capabilities and it is restricted to be able to
				 open tables B and C in read-only mode.
@SYMTestPriority High
@SYMTestActions  Open table test.
@SYMTestExpectedResults The test must not fail.
@SYMREQ REQ2429
                 DBMS shall provide an API to apply security policies to database tables.
*/
static void Test1L()
	{
	TheTest.Printf(_L("An attempt to open tables in update/insert mode\n"));
	//The test must fail, because the test app cannot satisfy table A, B, C, policy W.
	TInt err = TheTbl.Open(TheDb, KTblNameA);
	TEST2(err, KErrPermissionDenied);
	err = TheTbl.Open(TheDb, KTblNameB);
	TEST2(err, KErrPermissionDenied);
	err = TheTbl.Open(TheDb, KTblNameC);
	TEST2(err, KErrPermissionDenied);

	TheTest.Printf(_L("An attempt to open tables in read-only mode\n"));
	//The test must pass for table B & C, but the test app cannot satisfy table A, policy R.
	err = TheTbl.Open(TheDb, KTblNameA, RDbRowSet::EReadOnly);
	TEST2(err, KErrPermissionDenied);
	err = TheTbl.Open(TheDb, KTblNameB, RDbRowSet::EReadOnly);
	TEST2(err, KErrNone);
	TheTbl.Close();
	err = TheTbl.Open(TheDb, KTblNameC, RDbRowSet::EReadOnly);
	TEST2(err, KErrNone);
	TheTbl.Close();

	TheTest.Printf(_L("An attempt to read tables\n"));
	//The test must pass for table B & C, but the test app cannot satisfy table A, policy R.
	err = TheView.Prepare(TheDb, TDbQuery(_L("SELECT * FROM A")));
	TEST2(err, KErrPermissionDenied);
	err = TheView.Prepare(TheDb, TDbQuery(_L("SELECT * FROM B")));
	TEST2(err, KErrNone);
	TInt cnt = TheView.CountL();
	TEST(cnt > 0);
	TheView.Close();
	err = TheView.Prepare(TheDb, TDbQuery(_L("SELECT * FROM C")));
	TEST2(err, KErrNone);
	cnt = TheView.CountL();
	TEST(cnt > 0);
	TheView.Close();
	}
コード例 #6
0
TInt CSCPParamDB :: GetValuesForParameterL(TInt aParamID, RPointerArray <HBufC>& aParamValues, const TInt32 aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetValueForParameterL >>>"));

    RDbView lDBView;
    CleanupClosePushL(lDBView);

    HBufC* lSelectQry  = HBufC :: NewLC(KSelectWhereParamIdAppID().Length() + 40);
    lSelectQry->Des().Format (KSelectWhereParamIdAppID, aParamID, aApp);

    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());
    
    if (lDBView.FirstL())
    {
    	TInt size(0);
    	TInt lRowCount = lDBView.CountL();

    	if(lRowCount == 0) {
        _SCPDB_LOG(_L("[CSCPParamDB]-> No Rows found for this parameter"));
        CleanupStack :: PopAndDestroy(2);
        return KErrNotFound;
    	}
    
    	TInt lErr(KErrNone);
    
    	do {
        lDBView.GetL();
        size = lDBView.ColDes(iColSet->ColNo(KColValueDes)).Size();

        if(size) {
            HBufC* lBuff = HBufC :: NewL(size);
            TPtr lPtr(lBuff->Des());
            lPtr.Copy(lDBView.ColDes(iColSet->ColNo(KColValueDes)));
          
            TRAP(lErr, aParamValues.AppendL(lBuff));
            
            if(lErr != KErrNone) {
                aParamValues.ResetAndDestroy();
                User :: Leave(lErr);
            }
        }
    	}
    	while(lDBView.NextL());
    }

    CleanupStack :: PopAndDestroy(2);
    _SCPDB_LOG(_L("[CSCPParamDB]-> GetValuesForParameterL <<<"));
    return KErrNone;   
}
コード例 #7
0
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
EXPORT_C void PosLmLandmarkHandler::GetAllLandmarkIdsL(
    CPosLmLocalDbAccess& aDbAccess,
    TBool aUseSort,
    TBool aSortDescending,
    RArray<TPosLmItemId>& aLandmarkIds)
    {
    aLandmarkIds.Reset();

    HBufC* sql = HBufC::NewLC(KPosLmSqlStatementMaxLen);

    if (aUseSort)
        {
        sql->Des().Format(KPosLmSqlSelectOrderByString, &KPosLmLandmarkIdCol,
            &KPosLmLandmarkTable, &KPosLmNameCol);

        if (aSortDescending)
            {
            sql->Des().Append(KPosLmSqlDescOrder);
            }
        }
    else
        {
        sql->Des().Format(KPosLmSqlSelect, &KPosLmLandmarkIdCol,
            &KPosLmLandmarkTable);
        }

    RDbView view;
    aDbAccess.PrepareViewLC(CPosLmLocalDbAccess::EUpdatablePreparation, view,
        *sql, EDbCompareCollated);

    aLandmarkIds.ReserveL( view.CountL() );
    while ( view.NextL() )
        {
        view.GetL();
        aLandmarkIds.AppendL( view.ColUint32(1) );
        }

    CleanupStack::PopAndDestroy(2, sql); //&view
    }
コード例 #8
0
/**
@SYMTestCaseID			SYSLIB-DBMS-CT-3407
@SYMTestCaseDesc		Test for defect DEF103023 - DBMS requires ReadDeviceData and WriteDeviceData capability to read from the db.
 						The current test application has no capabilities at all.
 						"C:TestDB.DB" database is a secure shared database with:
 							- no "READ" polycy (no restrictions apply to the database read operations);
 							- "WRITE" policy with "WriteUserData" capability defined;
 							- "SCHEMA" policy with "NetworkServices" capability defined;
 							- table C has no defined securoty policy, so the database security policy will be used;
 						The current test application should be able to:
 							- begin/commit/rollback a "read-only" transaction;
 						But should fail if:
 							- begin a transaction and try to modify the database within the transaction;
 						This test function asserts the test cases described above.
@SYMTestPriority		High
@SYMTestActions			Test for defect DEF103023 - DBMS requires ReadDeviceData and WriteDeviceData capability to read from the db.
@SYMTestExpectedResults Test must not fail
@SYMDEF					DEF103023
*/
void DEF103023L()
	{
	TheTest.Printf(_L("Begin a transaction. Read-only operations tested\n"));
	TInt err = TheDb.Begin();
	TEST2(err, KErrNone);
	TheTest.Printf(_L("Perform some read-only operations inside the transaction\n"));
	err = TheView.Prepare(TheDb, _L("SELECT * FROM C"));
	TEST2(err, KErrNone);
	err = TheView.EvaluateAll();
	TEST2(err, KErrNone);
	TInt cnt = TheView.CountL();
	TEST(cnt > 0);
	TBool rc = TheView.FirstL();
	TEST(rc);
	TheView.GetL();
	TInt val = TheView.ColInt32(1);
	rc = TheView.LastL();
	TEST(rc);
	rc = TheView.NextL();
	TEST(!rc);
	rc = TheView.PreviousL();
	TEST(rc);
	TheView.BeginningL();
	TheView.EndL();
	TheView.Close();
	TheTest.Printf(_L("Commit a transaction\n"));
	err = TheDb.Commit();
	TEST2(err, KErrNone);
	//
	TheTest.Printf(_L("Begin a transaction. Read-only operations tested\n"));
	err = TheDb.Begin();
	TEST2(err, KErrNone);
	err = TheView.Prepare(TheDb, _L("SELECT * FROM C"));
	TEST2(err, KErrNone);
	err = TheView.EvaluateAll();
	TEST2(err, KErrNone);
	cnt = TheView.CountL();
	TEST(cnt > 0);
	TheView.Close();
	TheTest.Printf(_L("Rollback a transaction\n"));
	TheDb.Rollback();
	//
	TheTest.Printf(_L("Begin a transaction. Tested operations violate the database security\n"));
	err = TheDb.Begin();
	TEST2(err, KErrNone);
	err = TheView.Prepare(TheDb, _L("SELECT * FROM C"));
	TEST2(err, KErrNone);
	err = TheView.EvaluateAll();
	TEST2(err, KErrNone);
	rc = TheView.FirstL();
	TEST(rc);
	TheView.GetL();
	TheTest.Printf(_L("An attempt to update a record within the transaction\n"));
	TRAP(err, TheView.UpdateL());
	TEST2(err, KErrPermissionDenied);
	TheTest.Printf(_L("An attempt to delete a record within the transaction\n"));
	TRAP(err, TheView.DeleteL());
	TEST2(err, KErrPermissionDenied);
	TheTest.Printf(_L("An attempt to insert a record within the transaction\n"));
	TRAP(err, TheView.InsertL());
	TEST2(err, KErrPermissionDenied);
	TheView.Close();
	TheTest.Printf(_L("An attempt to modify the database schema within the transaction\n"));
	err = TheDb.Execute(_L("CREATE TABLE C2(Id INTEGER, Z INTEGER)"));
	TEST2(err, KErrPermissionDenied);
	TheTest.Printf(_L("An attempt to execute an INSERT statement within the transaction\n"));
	err = TheDb.Execute(_L("INSERT INTO C VALUES(100)"));
	TEST2(err, KErrPermissionDenied);
	TheTest.Printf(_L("An attempt to modify the database within the transaction using RDbUpdate\n"));
	RDbUpdate update;
	err = update.Execute(TheDb, _L("INSERT INTO C VALUES(200)"));
	TEST2(err, KErrPermissionDenied);
	update.Close();
	TheTest.Printf(_L("Rollback a transaction\n"));
	TheDb.Rollback();
	}
void eapol_am_wlan_authentication_symbian_c::RetrievePSKL(TPSKEntry& entry)
{
	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT, 
		(EAPL("eapol_am_wlan_authentication_symbian_c::RetrievePSKL(): this = 0x%08x\n"),
		this));
	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::RetrievePSKL()");

	// Open database
	RDbNamedDatabase db;

	TFileName aPrivateDatabasePathName;

	EapPluginTools::GetPrivatePathL(
		m_session,
		aPrivateDatabasePathName);

	aPrivateDatabasePathName.Append(KEapolDatabaseName);

	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
		aPrivateDatabasePathName.Ptr(),
		aPrivateDatabasePathName.Size()));

	TInt error = db.Open(m_session, aPrivateDatabasePathName);

	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT, 
		(EAPL("eapol_am_wlan_authentication_symbian_c::RetrievePSKL(): db.Open(), error = %d\n"),
		 error));

	User::LeaveIfError(error);
	
	CleanupClosePushL(db);

	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
	TPtr sqlStatement = sqlbuf->Des();

	RDbView view;

	CleanupClosePushL(view);

	_LIT(KSQL, "SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d");

	sqlStatement.Format(KSQL, &KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK,
		&KEapolPSKTableName, &KServiceType, entry.indexType, &KServiceIndex, entry.index);
		
	User::LeaveIfError(view.Prepare(db, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
	User::LeaveIfError(view.EvaluateAll());	

	TInt rows = view.CountL();
	
	if (rows == 0)
	{
		// No saved PSK
		User::Leave(KErrNotFound);
	}
	view.FirstL();
	view.GetL();

	entry.ssid.Copy(view.ColDes8(3));
	entry.password.Copy(view.ColDes8(4));
	entry.psk.Copy(view.ColDes8(5));

	CleanupStack::PopAndDestroy(&view);
	CleanupStack::PopAndDestroy(sqlbuf);
	CleanupStack::PopAndDestroy(&db);
}
コード例 #10
0
/**
@SYMTestCaseID SYSLIB-DBMS-CT-0016
@SYMTestCaseDesc R/W operations at a table level.
				 This test app has "PowerMgmt" (TABLE A: READ) capability, which allows it to
				 read data from table A. B and C tables can be read too, because they do
				 not have read security policy.
@SYMTestPriority High
@SYMTestActions  R/W table operations.
@SYMTestExpectedResults The test must not fail.
@SYMREQ REQ2429
                 DBMS shall provide an API to apply security policies to database tables.
*/
static void TblRWL()
	{
	TheTest.Printf(_L("Table A - Write\n"));
	TInt err = TheTbl.Open(TheDb, KTblNameA, RDbRowSet::EReadOnly);
	TEST2(err, KErrNone);
	//The test must fail, because the test app cannot satisfy table A, policy W.
	TRAP(err, TheTbl.InsertL());
	TEST2(err, KErrPermissionDenied);
	err = TheDb.Execute(_L("UPDATE A SET DATA1 = 400 WHERE ID < 10"));
	TEST2(err, KErrPermissionDenied);

	TheTest.Printf(_L("Table A - Read\n"));
	//The test must pass, because the test app can satisfy table A, policy R.
	TBool res = EFalse;
	TRAP(err, res = TheTbl.FirstL());
	TEST2(err, KErrNone);
	TEST(res);
	TInt cnt = TheTbl.CountL();
	TEST(cnt > 0);
	err = TheView.Prepare(TheDb, TDbQuery(_L("SELECT * FROM A")));
	TEST2(err, KErrNone);
	cnt = TheView.CountL();
	TEST(cnt > 0);
	TheView.Close();

	TheTbl.Close();

	TheTest.Printf(_L("Table B - Write\n"));
	err = TheTbl.Open(TheDb, KTblNameB, RDbRowSet::EReadOnly);
	TEST2(err, KErrNone);
	//The test must fail, because the test app cannot satisfy table B, policy W.
	TRAP(err, TheTbl.InsertL());
	TEST2(err, KErrPermissionDenied);
	err = TheDb.Execute(_L("INSERT INTO B (DATA2) VALUES (45)"));
	TEST2(err, KErrPermissionDenied);

	TheTest.Printf(_L("Table B - Read\n"));
	//The test must pass, because table B has no R policy.
	TRAP(err, res = TheTbl.FirstL());
	TEST2(err, KErrNone);
	TEST(res);
	cnt = TheTbl.CountL();
	TEST(cnt > 0);
	err = TheView.Prepare(TheDb, TDbQuery(_L("SELECT * FROM B")));
	TEST2(err, KErrNone);
	cnt = TheView.CountL();
	TEST(cnt > 0);
	TheView.Close();

	TheTbl.Close();

	TheTest.Printf(_L("Table C - Write\n"));
	err = TheTbl.Open(TheDb, KTblNameC);
	//The test must fail, because the test app cannot satisfy table C, policy W.
	TEST2(err, KErrPermissionDenied);
	err = TheTbl.Open(TheDb, KTblNameC, RDbRowSet::EReadOnly);
	TEST2(err, KErrNone);
	TRAP(err, TheTbl.InsertL());
	TEST2(err, KErrPermissionDenied);
	err = TheDb.Execute(_L("UPDATE C SET DATA1 = 400 WHERE ID < 10"));
	TEST2(err, KErrPermissionDenied);

	TheTest.Printf(_L("Table C - Read\n"));
	//The test must pass, because table C has no R policy.
	TRAP(err, res = TheTbl.FirstL());
	TEST2(err, KErrNone);
	TEST(res);
	cnt = TheTbl.CountL();
	TEST(cnt > 0);
	err = TheView.Prepare(TheDb, TDbQuery(_L("SELECT * FROM C")));
	TEST2(err, KErrNone);
	cnt = TheView.CountL();
	TEST(cnt > 0);
	TheView.Close();

	TheTbl.Close();
	}