os/security/authorisation/userpromptservice/server/source/upsclient/upsclientserver.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
* Implements an interface to keep and access decision record fields.
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file
sl@0
    22
 @internalTechnology
sl@0
    23
 @released
sl@0
    24
*/
sl@0
    25
#include <s32strm.h>
sl@0
    26
#include <ups/upstypes.h>
sl@0
    27
#include <ups/upsconst.h>
sl@0
    28
#include "upslog.h"
sl@0
    29
#include <ups/upserr.h>
sl@0
    30
#include "upscommon.h"
sl@0
    31
sl@0
    32
namespace UserPromptService {
sl@0
    33
sl@0
    34
CDecisionRecord::CDecisionRecord()
sl@0
    35
/**
sl@0
    36
	Constructor for the decision record. 
sl@0
    37
 */								 
sl@0
    38
	{
sl@0
    39
	
sl@0
    40
	}
sl@0
    41
sl@0
    42
CDecisionRecord::CDecisionRecord(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
sl@0
    43
								 const TUint8 aResult, const TUint16& aMajorPolicyVersion, const TUint32 aEvaluatorInfo, const TUint32& aRecordId)
sl@0
    44
/**
sl@0
    45
	Constructor for the decision record. Assigns the ID values. 
sl@0
    46
 */								 
sl@0
    47
	:iClientSid(aClientSid),iEvaluatorId(aEvaluatorId),
sl@0
    48
	 iServiceId(aServiceId),iServerSid(aServerSid),
sl@0
    49
	 iResult(aResult),iMajorPolicyVersion(aMajorPolicyVersion),
sl@0
    50
	 iRecordId(aRecordId),iEvaluatorInfo(aEvaluatorInfo)
sl@0
    51
	{
sl@0
    52
	
sl@0
    53
	}
sl@0
    54
sl@0
    55
sl@0
    56
CDecisionRecord::~CDecisionRecord()
sl@0
    57
/**
sl@0
    58
	Destructor for the decision record object
sl@0
    59
 */
sl@0
    60
	{
sl@0
    61
	iFingerprint.Close();		
sl@0
    62
	iClientEntity.Close();
sl@0
    63
	iDescription.Close();
sl@0
    64
	}
sl@0
    65
	
sl@0
    66
EXPORT_C CDecisionRecord* CDecisionRecord::NewL(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
sl@0
    67
								 	            const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TDesC& aDescription, const TUint8 aResult, 
sl@0
    68
								 	            const TUint16& aMajorPolicyVersion, const TUint32 aEvaluatorInfo, const TUint32& aRecordId)
sl@0
    69
/**
sl@0
    70
	Creates a decision record object. The function leaves, if creation of the record object fails.
sl@0
    71
	 
sl@0
    72
	@param aClientSid	  Secure Id of client application
sl@0
    73
	@param aEvaluatorId	  UID for the policy evaluator DLL
sl@0
    74
	@param aServiceId 	  UID for service e.g. sms, mms, telephony, gprs
sl@0
    75
	@param aServerSid  	  Secure Id for the system server that the decision applies to
sl@0
    76
	@param aFingerprint   Hash of the destination and/or opaque data. Maximum length is 32 bytes.
sl@0
    77
	@param aClientEntity  The name of the entity within the client that requested the service. Maximum length is 32 bytes. 
sl@0
    78
	@param aDescription	  A copy of description and/or opaque. 
sl@0
    79
	@param aResult		  Whether the request should be approved (=1) or denied (=0)
sl@0
    80
	@param aMajorPolicyVersion The major version of the policy file.
sl@0
    81
	@param aEvaluatorInfo Policy evaluator specific data
sl@0
    82
	@param aRecordId	  An auto-incrementing record number.
sl@0
    83
	
sl@0
    84
	@return    			  A pointer to the newly allocated decision record object, if creation is successful.
sl@0
    85
 */								 	   
sl@0
    86
	{
sl@0
    87
	CDecisionRecord* self = CDecisionRecord::NewLC(aClientSid,aEvaluatorId,aServiceId,aServerSid,aFingerprint,aClientEntity,
sl@0
    88
												   aDescription,aResult,aMajorPolicyVersion,aEvaluatorInfo,aRecordId);
sl@0
    89
	CleanupStack::Pop(self);
sl@0
    90
	return self;
sl@0
    91
	}
sl@0
    92
sl@0
    93
sl@0
    94
EXPORT_C CDecisionRecord* CDecisionRecord::NewLC(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
sl@0
    95
								 	    		 const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TDesC& aDescription, const TUint8 aResult, 
sl@0
    96
								 	    		 const TUint16& aMajorPolicyVersion, const TUint32 aEvaluatorInfo, const TUint32& aRecordId)
sl@0
    97
/**
sl@0
    98
	Creates a decision record object. The function leaves, if creation of the record object fails.
sl@0
    99
	
sl@0
   100
	@return    			  A pointer to the newly allocated decision record object, if creation is successful.
sl@0
   101
				  		  The pointer is also put onto the cleanup stack.
sl@0
   102
	@see CDecisionRecord::NewL()
sl@0
   103
 */									 	   
sl@0
   104
	{
sl@0
   105
	CDecisionRecord* self = new (ELeave) CDecisionRecord(aClientSid,aEvaluatorId,aServiceId,aServerSid,aResult,
sl@0
   106
														 aMajorPolicyVersion,aEvaluatorInfo,aRecordId);
sl@0
   107
	CleanupStack::PushL(self);
sl@0
   108
	self->ConstructL(aFingerprint,aClientEntity,aDescription);
sl@0
   109
	return self;
sl@0
   110
	}	
sl@0
   111
sl@0
   112
EXPORT_C CDecisionRecord* CDecisionRecord::NewLC()
sl@0
   113
/**
sl@0
   114
	Creates a decision record object. The function leaves, if creation of the record object fails.
sl@0
   115
	
sl@0
   116
	@return    			  A pointer to the newly allocated decision record object, if creation is successful.
sl@0
   117
				  		  The pointer is also put onto the cleanup stack.
sl@0
   118
 */									 	   
sl@0
   119
	{
sl@0
   120
	CDecisionRecord* self = new (ELeave) CDecisionRecord();
sl@0
   121
	CleanupStack::PushL(self);
sl@0
   122
	return self;
sl@0
   123
	}	
sl@0
   124
	
sl@0
   125
void CDecisionRecord::ConstructL(const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TDesC& aDescription)
sl@0
   126
/**
sl@0
   127
	Second phase constructor for the decision record. Sets members allocated on the heap.
sl@0
   128
	The function leaves, if any buffer allocation fails.
sl@0
   129
	@see CDecisionRecord::NewL()
sl@0
   130
 */
sl@0
   131
	{
sl@0
   132
		
sl@0
   133
	iFingerprint.CreateL(aFingerprint);
sl@0
   134
	
sl@0
   135
	iClientEntity.CreateL(aClientEntity);
sl@0
   136
	
sl@0
   137
	iDescription.CreateL(aDescription);
sl@0
   138
sl@0
   139
	ValidateL();
sl@0
   140
	}
sl@0
   141
sl@0
   142
void CDecisionRecord::ValidateL()
sl@0
   143
/**
sl@0
   144
	Check both the fingerprint and client entity are not too long.
sl@0
   145
	An absent fingerprint or client entity is represent by an empty string.
sl@0
   146
*/
sl@0
   147
	{
sl@0
   148
	if(iFingerprint.Length()  > (TInt)KUpsMaxFingerprintLength)
sl@0
   149
	    {
sl@0
   150
	    DEBUG_PRINTF2(_L8("The fingerprint length (%d) has not been satisfied during decision construction!"),iFingerprint.Length());
sl@0
   151
	    User::Leave(KErrUpsBadFingerprintLength);
sl@0
   152
	    }
sl@0
   153
	    	
sl@0
   154
	if(iClientEntity.Length() > (TInt)KUpsMaxClientEntityLength)
sl@0
   155
		{
sl@0
   156
		DEBUG_PRINTF2(_L8("The client entity length (%d) has not been satisfied during decision construction!"),iClientEntity.Length());
sl@0
   157
		User::Leave(KErrUpsBadClientEntityLength);
sl@0
   158
		}
sl@0
   159
	}
sl@0
   160
sl@0
   161
EXPORT_C void CDecisionRecord::ExternalizeL(RWriteStream& aStream) const
sl@0
   162
/**
sl@0
   163
	Externalise this CDecisionRecord object to the specified stream.
sl@0
   164
*/
sl@0
   165
	{
sl@0
   166
	aStream.WriteUint32L(iClientSid.iId);
sl@0
   167
	aStream.WriteInt32L(iEvaluatorId.iUid);
sl@0
   168
	aStream.WriteInt32L(iServiceId.iUid);
sl@0
   169
	aStream.WriteUint32L(iServerSid.iId);
sl@0
   170
	aStream << iFingerprint;
sl@0
   171
	aStream << iClientEntity;
sl@0
   172
	aStream << iDescription;
sl@0
   173
	aStream << iResult;
sl@0
   174
	aStream << iMajorPolicyVersion;
sl@0
   175
	aStream << iRecordId;
sl@0
   176
	aStream << iEvaluatorInfo;
sl@0
   177
	}
sl@0
   178
sl@0
   179
EXPORT_C void CDecisionRecord::InternalizeL(RReadStream& aStream)
sl@0
   180
/**
sl@0
   181
	Internalise this CDecisionRecord object from the specified stream.
sl@0
   182
*/
sl@0
   183
	{
sl@0
   184
	iClientSid.iId= aStream.ReadUint32L();
sl@0
   185
	iEvaluatorId.iUid = aStream.ReadInt32L();
sl@0
   186
	iServiceId.iUid = aStream.ReadInt32L();
sl@0
   187
	iServerSid.iId = aStream.ReadUint32L();
sl@0
   188
sl@0
   189
	iFingerprint.Close();
sl@0
   190
	iFingerprint.CreateL(aStream, KMaskDesLength8);
sl@0
   191
sl@0
   192
	iClientEntity.Close();
sl@0
   193
	iClientEntity.CreateL(aStream, KMaskDesLength8);
sl@0
   194
sl@0
   195
	iDescription.Close();
sl@0
   196
	iDescription.CreateL(aStream, KMaskDesLength16);
sl@0
   197
sl@0
   198
	aStream >> iResult;
sl@0
   199
	aStream >> iMajorPolicyVersion;
sl@0
   200
	aStream >> iRecordId;
sl@0
   201
	aStream >> iEvaluatorInfo;
sl@0
   202
sl@0
   203
	ValidateL();
sl@0
   204
	}
sl@0
   205
sl@0
   206
CDecisionFilter::CDecisionFilter()
sl@0
   207
/**
sl@0
   208
	Constructor for an empty decision filter.
sl@0
   209
 */
sl@0
   210
	{
sl@0
   211
	
sl@0
   212
	}
sl@0
   213
sl@0
   214
	
sl@0
   215
CDecisionFilter::CDecisionFilter(const TSecureId& aClientSid, const TUid& aEvaluatorId, 
sl@0
   216
	const TUid& aServiceId, const TSecureId& aServerSid, const TUint16& aVersion)
sl@0
   217
	:iClientSid(aClientSid),iEvaluatorId(aEvaluatorId),iServiceId(aServiceId),
sl@0
   218
	iServerSid(aServerSid),iMajorPolicyVersion(aVersion)
sl@0
   219
/**
sl@0
   220
	Constructor for the decision filter. Assigns the ID values.
sl@0
   221
 */
sl@0
   222
	{
sl@0
   223
	iSetFlag[KPosClientSid]	  = KSetClientSid	| UserPromptService::EEqual;
sl@0
   224
	iSetFlag[KPosEvaluatorId] = KSetEvaluatorId | UserPromptService::EEqual;
sl@0
   225
	iSetFlag[KPosServiceId]	  = KSetServiceId	| UserPromptService::EEqual;
sl@0
   226
	iSetFlag[KPosServerSid]	  = KSetServerSid	| UserPromptService::EEqual;
sl@0
   227
	iSetFlag[KPosMajorPolicyVersion] = KSetMajorPolicyVersion | UserPromptService::EEqual;
sl@0
   228
	}
sl@0
   229
		
sl@0
   230
				
sl@0
   231
CDecisionFilter::~CDecisionFilter()
sl@0
   232
/**
sl@0
   233
	Destructor for the decision filter
sl@0
   234
 */
sl@0
   235
	{
sl@0
   236
	delete iFingerprint;
sl@0
   237
	delete iClientEntity;	
sl@0
   238
	}
sl@0
   239
	
sl@0
   240
	
sl@0
   241
EXPORT_C CDecisionFilter* CDecisionFilter::NewL()
sl@0
   242
/**
sl@0
   243
	Creates an empty filter object. The function is used to define any number of filter keys.
sl@0
   244
	It leaves, if the creation of the filter object fails.
sl@0
   245
		
sl@0
   246
	@return	   A pointer to the newly allocated filter object, if creation is successful. 
sl@0
   247
 */
sl@0
   248
	{
sl@0
   249
	CDecisionFilter* self = CDecisionFilter::NewLC();
sl@0
   250
	CleanupStack::Pop(self);
sl@0
   251
	return self;
sl@0
   252
	}
sl@0
   253
	
sl@0
   254
	
sl@0
   255
EXPORT_C CDecisionFilter* CDecisionFilter::NewLC()
sl@0
   256
/**
sl@0
   257
	Creates an empty filter object. The function is used to define any number of filter keys.
sl@0
   258
	It leaves, if the creation of the filter object fails.
sl@0
   259
sl@0
   260
	@return	   A pointer to the newly allocated filter object, if creation is successful. 
sl@0
   261
			   The pointer is also put onto the cleanup stack.
sl@0
   262
 */
sl@0
   263
	{
sl@0
   264
	CDecisionFilter* self = new (ELeave) CDecisionFilter();
sl@0
   265
	CleanupStack::PushL(self);
sl@0
   266
	return self;
sl@0
   267
	}
sl@0
   268
	
sl@0
   269
	
sl@0
   270
EXPORT_C CDecisionFilter* CDecisionFilter::NewL(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
sl@0
   271
												const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TUint16& aVersion)
sl@0
   272
/**
sl@0
   273
	Creates a filter object and assigns all filter keys. The function leaves, if creation of the filter object fails.
sl@0
   274
	 
sl@0
   275
	@param aClientSid	 Secure Id of client application
sl@0
   276
	@param aEvaluatorId	 UID for the policy evaluator DLL
sl@0
   277
	@param aServiceId	 UID for service e.g. sms, mms, telephony, gprs
sl@0
   278
	@param aServerSid	 Secure Id for the system server that the decision applies to
sl@0
   279
	@param aFingerprint	 Hash of the destination and/or opaque data.
sl@0
   280
	@param aClientEntity The name of the entity within the client that requested the service. 
sl@0
   281
	@param aVersion      Major version of policy file.
sl@0
   282
	@return				 A pointer to the newly allocated filter object, if creation is successful.
sl@0
   283
 */									
sl@0
   284
	{
sl@0
   285
	CDecisionFilter* self = CDecisionFilter::NewLC(aClientSid,aEvaluatorId,aServiceId,aServerSid,aFingerprint,aClientEntity,aVersion);
sl@0
   286
	CleanupStack::Pop(self);
sl@0
   287
	return self;
sl@0
   288
	}
sl@0
   289
	
sl@0
   290
	
sl@0
   291
EXPORT_C CDecisionFilter* CDecisionFilter::NewLC(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
sl@0
   292
												 const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TUint16& aVersion)
sl@0
   293
/**
sl@0
   294
	Creates a filter object and assigns all filter keys. The function leaves, if creation of the filter object fails.
sl@0
   295
	 
sl@0
   296
	@param aClientSid	 Secure Id of client application
sl@0
   297
	@param aEvaluatorId	 UID for the policy evaluator DLL
sl@0
   298
	@param aServiceId	 UID for service e.g. sms, mms, telephony, gprs
sl@0
   299
	@param aServerSid	 Secure Id for the system server that the decision applies to
sl@0
   300
	@param aFingerprint	 Hash of the destination and/or opaque data.
sl@0
   301
	@param aClientEntity The name of the entity within the client that requested the service.
sl@0
   302
	@param aVersion      Major version of policy file.
sl@0
   303
	@return				 A pointer to the newly allocated filter object, if creation is successful.
sl@0
   304
						 The pointer is also put onto the cleanup stack.
sl@0
   305
 */												 
sl@0
   306
	{
sl@0
   307
	CDecisionFilter* self = new (ELeave) CDecisionFilter(aClientSid,aEvaluatorId,aServiceId,aServerSid,aVersion);
sl@0
   308
	CleanupStack::PushL(self);
sl@0
   309
	self->ConstructL(aFingerprint,aClientEntity);
sl@0
   310
	return self;
sl@0
   311
	}	
sl@0
   312
sl@0
   313
sl@0
   314
void CDecisionFilter::ConstructL(const TDesC8& aFingerprint, const TDesC8& aClientEntity)
sl@0
   315
/**
sl@0
   316
	Second phase constructor for the decision filter. Sets members allocated on the heap.
sl@0
   317
	The function leaves, if any buffer allocation fails.
sl@0
   318
 */
sl@0
   319
	{
sl@0
   320
		
sl@0
   321
	iFingerprint = aFingerprint.AllocL();
sl@0
   322
	iSetFlag[KPosFingerprint] |= KSetFingerprint;
sl@0
   323
	
sl@0
   324
	iClientEntity = aClientEntity.AllocL();
sl@0
   325
	iSetFlag[KPosClientEntity] |= KSetClientEntity;
sl@0
   326
sl@0
   327
	ValidateL();
sl@0
   328
	}
sl@0
   329
	
sl@0
   330
void CDecisionFilter::ValidateL()
sl@0
   331
/**
sl@0
   332
	Check fingerprint and client entity lengths are valid.
sl@0
   333
*/
sl@0
   334
	{
sl@0
   335
	if((iSetFlag[KPosFingerprint] & KSetFingerprint) &&
sl@0
   336
		((iFingerprint == 0) || (iFingerprint->Length()	> KUpsMaxFingerprintLength)))
sl@0
   337
		{
sl@0
   338
		DEBUG_PRINTF2(_L8("The fingerprint length (%d) has not been satisfied during filter construction!"),(iFingerprint) ? (iFingerprint->Length()) : (0));
sl@0
   339
		User::Leave(KErrUpsBadFingerprintLength);
sl@0
   340
		}
sl@0
   341
		
sl@0
   342
	if((iSetFlag[KPosClientEntity] & KSetClientEntity) &&
sl@0
   343
		((iClientEntity == 0) || (iClientEntity->Length() > KUpsMaxClientEntityLength)))
sl@0
   344
		{
sl@0
   345
		DEBUG_PRINTF2(_L8("The client entity length (%d) has not been satisfied during filter construction!"),(iClientEntity) ? (iClientEntity->Length()) : (0));
sl@0
   346
		User::Leave(KErrUpsBadClientEntityLength);
sl@0
   347
		}
sl@0
   348
	}
sl@0
   349
	
sl@0
   350
EXPORT_C void CDecisionFilter::SetClientSid(const TSecureId& aSid, TComparisonOp aOp)
sl@0
   351
/**
sl@0
   352
	Sets the Secure ID of the client application.
sl@0
   353
sl@0
   354
	@param aUid		SID for the client application
sl@0
   355
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   356
 */
sl@0
   357
	{
sl@0
   358
	iClientSid = aSid;
sl@0
   359
	iSetFlag[KPosClientSid] |= KSetClientSid;
sl@0
   360
	iSetFlag[KPosClientSid] |= aOp;
sl@0
   361
	}
sl@0
   362
	
sl@0
   363
	
sl@0
   364
EXPORT_C void CDecisionFilter::SetEvaluatorId(const TUid& aUid, TComparisonOp aOp)
sl@0
   365
/**
sl@0
   366
	Sets the UID of the policy evaluator DLL.
sl@0
   367
sl@0
   368
	@param aUid		UID for the policy evaluator DLL
sl@0
   369
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   370
 */
sl@0
   371
	{
sl@0
   372
	iEvaluatorId = aUid;
sl@0
   373
	iSetFlag[KPosEvaluatorId] |= KSetEvaluatorId;
sl@0
   374
	iSetFlag[KPosEvaluatorId] |= aOp;
sl@0
   375
	}
sl@0
   376
sl@0
   377
sl@0
   378
EXPORT_C void CDecisionFilter::SetServiceId(const TUid& aUid, TComparisonOp aOp)
sl@0
   379
/**
sl@0
   380
	Sets the Secure ID of the service.
sl@0
   381
sl@0
   382
	@param aUid		UID for the service
sl@0
   383
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   384
 */
sl@0
   385
	{
sl@0
   386
	iServiceId = aUid;
sl@0
   387
	iSetFlag[KPosServiceId] |= KSetServiceId;
sl@0
   388
	iSetFlag[KPosServiceId] |= aOp;
sl@0
   389
	}
sl@0
   390
	
sl@0
   391
		
sl@0
   392
EXPORT_C void CDecisionFilter::SetServerSid(const TSecureId& aSid, TComparisonOp aOp)
sl@0
   393
/**
sl@0
   394
	Sets the Secure ID of the system server.
sl@0
   395
	
sl@0
   396
	@param aUid		UID for the system server
sl@0
   397
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   398
 */
sl@0
   399
	{
sl@0
   400
	iServerSid = aSid;
sl@0
   401
	iSetFlag[KPosServerSid] |= KSetServerSid;
sl@0
   402
	iSetFlag[KPosServerSid] |= aOp;
sl@0
   403
	}
sl@0
   404
	
sl@0
   405
	
sl@0
   406
EXPORT_C void CDecisionFilter::SetFingerprintL(const TDesC8& aFingerprint, TComparisonOp aOp)
sl@0
   407
/**
sl@0
   408
	Sets the fingerprint. A buffer is allocated on the heap and aFingerprint copied into it.
sl@0
   409
	The function leaves, if the buffer allocation fails.
sl@0
   410
	 
sl@0
   411
	@param aFingerprint		Hash of the destination and/or opaque data. (Maximum length is 32 bytes)
sl@0
   412
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   413
 */
sl@0
   414
	{
sl@0
   415
	//Fingerprint's length can not be longer than KUpsMaxFingerprintLength
sl@0
   416
	if(aFingerprint.Length() > KUpsMaxFingerprintLength)
sl@0
   417
		{
sl@0
   418
		User::Leave(KErrUpsBadFingerprintLength);
sl@0
   419
		}
sl@0
   420
sl@0
   421
	delete iFingerprint;
sl@0
   422
	iFingerprint = 0;
sl@0
   423
			
sl@0
   424
	iFingerprint = aFingerprint.AllocL();
sl@0
   425
	iSetFlag[KPosFingerprint] |= KSetFingerprint;
sl@0
   426
	iSetFlag[KPosFingerprint] |= aOp;
sl@0
   427
	}
sl@0
   428
	
sl@0
   429
	
sl@0
   430
EXPORT_C void CDecisionFilter::SetClientEntityL(const TDesC8& aClientEntity, TComparisonOp aOp)
sl@0
   431
/**
sl@0
   432
	Sets the client entity. A buffer is allocated on the heap and aClientEntity copied into it.
sl@0
   433
	The function leaves, if the buffer allocation fails.
sl@0
   434
	 
sl@0
   435
	@param aClientEntity	The name of the entity within the client. (Maximum length is 32 bytes) 
sl@0
   436
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   437
 */
sl@0
   438
	{
sl@0
   439
	//ClientEntity's length can not be longer than KUpsMaxClientEntityLength
sl@0
   440
	if(aClientEntity.Length() > KUpsMaxClientEntityLength)
sl@0
   441
		{
sl@0
   442
		User::Leave(KErrUpsBadClientEntityLength);
sl@0
   443
		}
sl@0
   444
		
sl@0
   445
	delete iClientEntity;
sl@0
   446
	iClientEntity = 0;
sl@0
   447
		
sl@0
   448
	iClientEntity = aClientEntity.AllocL();
sl@0
   449
	iSetFlag[KPosClientEntity] |= KSetClientEntity;
sl@0
   450
	iSetFlag[KPosClientEntity] |= aOp;
sl@0
   451
	}
sl@0
   452
sl@0
   453
sl@0
   454
EXPORT_C void CDecisionFilter::SetMajorPolicyVersion(const TUint16& aVersion, TComparisonOp aOp)
sl@0
   455
/**
sl@0
   456
	Sets the major version of the policy file.
sl@0
   457
	
sl@0
   458
	@param aVersion		Major policy version.
sl@0
   459
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   460
 */
sl@0
   461
	{
sl@0
   462
	iMajorPolicyVersion = aVersion;
sl@0
   463
	iSetFlag[KPosMajorPolicyVersion] |= KSetMajorPolicyVersion;
sl@0
   464
	iSetFlag[KPosMajorPolicyVersion] |= aOp;
sl@0
   465
	}
sl@0
   466
sl@0
   467
sl@0
   468
EXPORT_C void CDecisionFilter::SetRecordId(const TUint32& aId, TComparisonOp aOp)
sl@0
   469
/**
sl@0
   470
	Sets the unique Id number of the decision record which is searched.
sl@0
   471
	
sl@0
   472
	@param aId	A unique record Id.
sl@0
   473
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   474
 */
sl@0
   475
	{
sl@0
   476
	iRecordId = aId;
sl@0
   477
	iSetFlag[KPosRecordId] |= KSetRecordId;
sl@0
   478
	iSetFlag[KPosRecordId] |= aOp;
sl@0
   479
	}
sl@0
   480
sl@0
   481
sl@0
   482
EXPORT_C void CDecisionFilter::SetDescriptionL(const TDesC& aDescription, const TComparisonOp aOp)
sl@0
   483
/**
sl@0
   484
	Sets the description field. A buffer is allocated on the heap and aDescription copied into it.
sl@0
   485
	The function leaves, if the buffer allocation fails.
sl@0
   486
	 
sl@0
   487
	@param aDescription	A copy of description and/or opaque. (Maximum length is 32 bytes) 
sl@0
   488
	@param aOp			Comparision operator which is used to create SQL statement.
sl@0
   489
 */
sl@0
   490
	{	
sl@0
   491
	delete iDescription;
sl@0
   492
	iDescription = 0;
sl@0
   493
		
sl@0
   494
	iDescription = aDescription.AllocL();
sl@0
   495
	iSetFlag[KPosDescription] |= KSetDescription;
sl@0
   496
	iSetFlag[KPosDescription] |= aOp;
sl@0
   497
	}
sl@0
   498
	
sl@0
   499
	
sl@0
   500
EXPORT_C void CDecisionFilter::SetResult(const TUint8& aResult, const TComparisonOp aOp)
sl@0
   501
/**
sl@0
   502
	Sets the result field of the decision record which is searched.
sl@0
   503
	
sl@0
   504
	@param aResult	Whether the request should be approved.
sl@0
   505
	@param aOp		Comparision operator which is used to create SQL statement.
sl@0
   506
 */
sl@0
   507
	{
sl@0
   508
	iResult = aResult;
sl@0
   509
	iSetFlag[KPosResult] |= KSetResult;
sl@0
   510
	iSetFlag[KPosResult] |= aOp;
sl@0
   511
	}
sl@0
   512
	
sl@0
   513
	
sl@0
   514
EXPORT_C void CDecisionFilter::SetEvaluatorInfo(const TUint32& aEvaluatorInfo, const TComparisonOp aOp)
sl@0
   515
/**
sl@0
   516
	Sets the evaluator info field of the decision record which is searched.
sl@0
   517
	
sl@0
   518
	@param aEvaluatorInfo	Policy evaluator specific data
sl@0
   519
	@param aOp				Comparision operator which is used to create SQL statement.
sl@0
   520
 */
sl@0
   521
	{
sl@0
   522
	iEvaluatorInfo = aEvaluatorInfo;
sl@0
   523
	iSetFlag[KPosEvaluatorInfo] |= KSetEvaluatorInfo;
sl@0
   524
	iSetFlag[KPosEvaluatorInfo] |= aOp;
sl@0
   525
	}
sl@0
   526
	
sl@0
   527
	
sl@0
   528
EXPORT_C void CDecisionFilter::ExternalizeL(RWriteStream& aStream) const
sl@0
   529
/**
sl@0
   530
	Externalise this CDecisionFilter object to the specified stream.
sl@0
   531
*/
sl@0
   532
	{
sl@0
   533
	aStream << iClientSid.iId;		// TSecureId 
sl@0
   534
	aStream << iEvaluatorId.iUid;	// TUid 
sl@0
   535
	aStream << iServiceId.iUid;		// TUid 
sl@0
   536
	aStream << iServerSid.iId;		// TSecureId 
sl@0
   537
sl@0
   538
	aStream << ((iFingerprint) ? (*iFingerprint) : (KNullDesC8())); 	// HBufC8* 
sl@0
   539
	aStream << ((iClientEntity) ? (*iClientEntity) : (KNullDesC8()));	// HBufC8* 
sl@0
   540
sl@0
   541
	for(int i = 0; i < KFilterKeysNumber; ++i)
sl@0
   542
		{
sl@0
   543
		aStream.WriteUint16L(iSetFlag[i]);// TUint16 
sl@0
   544
		}
sl@0
   545
sl@0
   546
	aStream << iMajorPolicyVersion;// TUint16 
sl@0
   547
	aStream << iRecordId;// TUint32 
sl@0
   548
	}
sl@0
   549
EXPORT_C void CDecisionFilter::InternalizeL(RReadStream& aStream)
sl@0
   550
/**
sl@0
   551
	Internalise this CDecisionFilter object from the specified stream.
sl@0
   552
*/
sl@0
   553
	{
sl@0
   554
	iClientSid.iId= aStream.ReadUint32L();		// TSecureId 
sl@0
   555
	iEvaluatorId.iUid= aStream.ReadInt32L();	// TUid 
sl@0
   556
	iServiceId.iUid= aStream.ReadInt32L();		// TUid 
sl@0
   557
	iServerSid.iId= aStream.ReadUint32L();		// TSecureId 
sl@0
   558
sl@0
   559
	// iFingerprint is always present in stream, so internalise it and then delete it if it is not setup.
sl@0
   560
	delete iFingerprint;
sl@0
   561
	iFingerprint = 0;
sl@0
   562
	iFingerprint = HBufC8::NewL(aStream, KMaskDesLength8);
sl@0
   563
sl@0
   564
	// iClientEntity is always present in stream, so internalise it and then delete it if it is not setup.
sl@0
   565
	delete iClientEntity;
sl@0
   566
	iClientEntity = 0;
sl@0
   567
	iClientEntity = HBufC8::NewL(aStream, KMaskDesLength8);
sl@0
   568
	
sl@0
   569
	for(int i = 0; i < KFilterKeysNumber; ++i)
sl@0
   570
		{
sl@0
   571
		iSetFlag[i] = aStream.ReadUint16L();// TUint16 
sl@0
   572
		}
sl@0
   573
sl@0
   574
	// Delete iFingerprint if not setup
sl@0
   575
	if((iSetFlag[KPosFingerprint] & KSetFingerprint) == 0)
sl@0
   576
		{
sl@0
   577
		delete iFingerprint;
sl@0
   578
		iFingerprint = 0;
sl@0
   579
		}
sl@0
   580
sl@0
   581
	// Delete iClientEntity if not setup
sl@0
   582
	if((iSetFlag[KPosClientEntity] & KSetClientEntity) == 0)
sl@0
   583
		{
sl@0
   584
		delete iClientEntity;
sl@0
   585
		iClientEntity = 0;
sl@0
   586
		}
sl@0
   587
sl@0
   588
	iMajorPolicyVersion = aStream.ReadUint16L();// TUint16 
sl@0
   589
	iRecordId = aStream.ReadUint32L();// TUint32 
sl@0
   590
sl@0
   591
	ValidateL();
sl@0
   592
	}
sl@0
   593
sl@0
   594
} // End of  UserPromptService namespace
sl@0
   595
// End of file