os/security/authorisation/userpromptservice/policies/source/promptrequest.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/authorisation/userpromptservice/policies/source/promptrequest.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,214 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include <ups/promptrequest.h>
    1.23 +
    1.24 +using namespace UserPromptService;
    1.25 +
    1.26 +EXPORT_C CPromptRequest* CPromptRequest::NewL(
    1.27 +		const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId,
    1.28 +		const TSecureId& aServerSid, const TServiceId& aServiceId, RBuf& aDestination, RBuf8& aOpaqueData, 
    1.29 +		TBool aSecurityResult)
    1.30 +/**
    1.31 +Creates a new prompt request object.\n
    1.32 +
    1.33 +The ownership of the aDestination and aOpaqueData RBufs is transfered
    1.34 +to this class. The callers RBufs will be empty after this call.
    1.35 +
    1.36 +
    1.37 +@param aClientSid		The SID of the client process requesting the service.
    1.38 +@param aClientVid		The VID of the client process requesting the service.
    1.39 +@param aClientThreadId	The id of the thread within the client process requesting the service.
    1.40 +@param aServerSid		The SID of the system server that provides the service.
    1.41 +@param aServiceId		The UID of the requested service.
    1.42 +@param aDestination		The data that the service acts on E.g. A phone number, IAP, domain name
    1.43 +@param aOpaqueData		Opaque data structure populated by the system server. Typically, this 
    1.44 +						contains extra information about the requested service.	
    1.45 +@param aSecurityResult	ETrue if client passed system server's security check; otherwise, EFalse.										
    1.46 +
    1.47 +@return					A pointer to the new prompt request object.
    1.48 +*/
    1.49 +	{
    1.50 +	CPromptRequest* self = CPromptRequest::NewLC(
    1.51 +		aClientSid, aClientVid, aClientThreadId, aClientProcessId, 
    1.52 +		aServerSid, aServiceId, aDestination, aOpaqueData, aSecurityResult);
    1.53 +	CleanupStack::Pop(self);
    1.54 +	return self;
    1.55 +	}
    1.56 +
    1.57 +EXPORT_C CPromptRequest* CPromptRequest::NewLC(
    1.58 +		const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId,
    1.59 +		const TSecureId& aServerSid, const TServiceId& aServiceId, RBuf& aDestination, RBuf8& aOpaqueData, 
    1.60 +		TBool aSecurityResult)
    1.61 +/**
    1.62 +Creates a new prompt request object and places the pointer on the cleanup stack.\n
    1.63 +
    1.64 +The ownership of the aDestination and aOpaqueData RBufs is transfered
    1.65 +to this class. The callers RBufs will be empty after this call.
    1.66 +
    1.67 +@param aClientSid		The SID of the client process requesting the service.
    1.68 +@param aClientVid		The VID of the client process requesting the service.
    1.69 +@param aClientThreadId	The id of the thread within the client process requesting the service.
    1.70 +@param aServerSid		The SID of the system server that provides the service.
    1.71 +@param aServiceId		The UID of the requested service.
    1.72 +@param aDestination		The data that the service acts on E.g. A phone number, IAP, domain name
    1.73 +@param aOpaqueData		Opaque data structure populated by the system server. Typically, this 
    1.74 +						contains extra information about the requested service.	
    1.75 +@param aSecurityResult	ETrue if client passed system server's security check; otherwise, EFalse.
    1.76 +
    1.77 +@return					A pointer to the new prompt request object.
    1.78 +*/
    1.79 +	{
    1.80 +	CPromptRequest* self = new(ELeave) 
    1.81 +		CPromptRequest(aClientSid, aClientVid, aClientThreadId, aClientProcessId,
    1.82 +		aServerSid, aServiceId, aDestination, aOpaqueData, aSecurityResult);
    1.83 +	CleanupStack::PushL(self);
    1.84 +	return self;
    1.85 +	}
    1.86 +	
    1.87 +CPromptRequest::CPromptRequest(
    1.88 +	const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId,
    1.89 +	const TSecureId& aServerSid, const TServiceId& aServiceId, 
    1.90 +	RBuf& aDestination, RBuf8& aOpaqueData, 
    1.91 +	TBool aSecurityResult)
    1.92 +/**
    1.93 +Constructor
    1.94 +@param aClientSid			The client's SID
    1.95 +@param aClientVid			The client's VID
    1.96 +@param aClientThreadId		The client's thread id.
    1.97 +@param aServerId			The system server's SID.
    1.98 +@param aServiceId			The id of the service.
    1.99 +@param aDestination			The destination.
   1.100 +@param aOpaqueData			The opaque data.
   1.101 +@param aSecurityResult		Whether the client passed the system server's security check
   1.102 +*/
   1.103 +:	iClientSid(aClientSid), iClientVid(aClientVid), iClientThreadId(aClientThreadId), iClientProcessId(aClientProcessId),
   1.104 +	iServerSid(aServerSid), iServiceId(aServiceId),
   1.105 +	iSecurityResult(aSecurityResult)
   1.106 +	{
   1.107 +	iDestination.Close();
   1.108 +	iDestination.Swap(aDestination);
   1.109 +	iOpaqueData.Close();
   1.110 +	iOpaqueData.Swap(aOpaqueData);	
   1.111 +	}
   1.112 +			
   1.113 +EXPORT_C const TSecureId& CPromptRequest::ClientSid() const
   1.114 +/**
   1.115 +Gets the SID of the client process requesting the service.
   1.116 +@return The client's SID.
   1.117 +*/
   1.118 +	{	
   1.119 +	return iClientSid;
   1.120 +	}
   1.121 +
   1.122 +EXPORT_C TBool CPromptRequest::IsClientSidProtected() const
   1.123 +/**
   1.124 +Determines whether the SID of the client process is in the protected range. 
   1.125 +If the SID is not protected then it is likely that identify of the client process
   1.126 +cannot reliable verified because it may an unsigned application. If so, a warning
   1.127 +should be displayed in the prompt dialog.
   1.128 +
   1.129 +@return ETrue if the SID is in the protected range; otherwise EFalse is returned.
   1.130 +*/
   1.131 +	{
   1.132 +	return ! (iClientSid.iId & 0x80000000);
   1.133 +	}
   1.134 +	
   1.135 +EXPORT_C const TVendorId& CPromptRequest::ClientVid() const
   1.136 +/**
   1.137 +Gets the VID of the client process requesting the service.
   1.138 +@return The client's VID.
   1.139 +*/
   1.140 +	{
   1.141 +	return iClientVid;
   1.142 +	}
   1.143 +	
   1.144 +EXPORT_C const TThreadId& CPromptRequest::ClientThreadId() const
   1.145 +/**
   1.146 +Gets the TThreadId of the client which issued the request to the system server.
   1.147 +This thread ID may be invalid if the thread has exited (we do NOT hold an open RThread to keep around).
   1.148 +@return The client's thread id.
   1.149 +*/
   1.150 +	{
   1.151 +	return iClientThreadId;
   1.152 +	}	
   1.153 +
   1.154 +EXPORT_C const TProcessId& CPromptRequest::ClientProcessId() const
   1.155 +/**
   1.156 +Gets the TProcessId of the client which issued the request to the system server.
   1.157 +This process ID may be invalid if the process has exited (we do NOT hold an open RProcess to keep around).
   1.158 +@return The client's process id.
   1.159 +*/
   1.160 +	{
   1.161 +	return iClientProcessId;
   1.162 +	}	
   1.163 +
   1.164 +EXPORT_C const TSecureId& CPromptRequest::ServerSid() const
   1.165 +/**
   1.166 +Gets the SID of the system server that provides the service.
   1.167 +@return The system server's SID.
   1.168 +*/
   1.169 +	{
   1.170 +	return iServerSid;
   1.171 +	}
   1.172 +	
   1.173 +EXPORT_C const TServiceId& CPromptRequest::ServiceId() const
   1.174 +/**
   1.175 +Gets the UID of the requested service.
   1.176 +@return The service UID.
   1.177 +*/
   1.178 +	{
   1.179 +	return iServiceId;
   1.180 +	}
   1.181 +	
   1.182 +EXPORT_C const TDesC& CPromptRequest::Destination() const
   1.183 +/**
   1.184 +Gets the data that the service acts on e.g. the phone number to dial.
   1.185 +@return A reference to a descriptor containing the destination string.
   1.186 +*/
   1.187 +	{
   1.188 +	return iDestination;
   1.189 +	}
   1.190 +
   1.191 +EXPORT_C const TDesC8& CPromptRequest::OpaqueData() const
   1.192 +/**
   1.193 +Gets the opaque data structure provided by the system server. 
   1.194 +@return A reference to a descriptor containing the opaque data.
   1.195 +*/
   1.196 +	{
   1.197 +	return iOpaqueData;
   1.198 +	}	
   1.199 +
   1.200 +EXPORT_C TBool CPromptRequest::SecurityResult() const
   1.201 +/**
   1.202 +Whether the client processed the system server's security check.
   1.203 +@return ETrue, if the client process passed the system server's 
   1.204 +security check; otherwise, EFalse is returned.
   1.205 +*/
   1.206 +	{
   1.207 +	return iSecurityResult;
   1.208 +	}
   1.209 +	
   1.210 +CPromptRequest::~CPromptRequest()
   1.211 +/**
   1.212 +Destructor
   1.213 +*/
   1.214 +	{
   1.215 +	iDestination.Close();
   1.216 +	iOpaqueData.Close();
   1.217 +	}