os/security/authorisation/userpromptservice/policies/source/promptrequest.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include <ups/promptrequest.h>
    20 
    21 using namespace UserPromptService;
    22 
    23 EXPORT_C CPromptRequest* CPromptRequest::NewL(
    24 		const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId,
    25 		const TSecureId& aServerSid, const TServiceId& aServiceId, RBuf& aDestination, RBuf8& aOpaqueData, 
    26 		TBool aSecurityResult)
    27 /**
    28 Creates a new prompt request object.\n
    29 
    30 The ownership of the aDestination and aOpaqueData RBufs is transfered
    31 to this class. The callers RBufs will be empty after this call.
    32 
    33 
    34 @param aClientSid		The SID of the client process requesting the service.
    35 @param aClientVid		The VID of the client process requesting the service.
    36 @param aClientThreadId	The id of the thread within the client process requesting the service.
    37 @param aServerSid		The SID of the system server that provides the service.
    38 @param aServiceId		The UID of the requested service.
    39 @param aDestination		The data that the service acts on E.g. A phone number, IAP, domain name
    40 @param aOpaqueData		Opaque data structure populated by the system server. Typically, this 
    41 						contains extra information about the requested service.	
    42 @param aSecurityResult	ETrue if client passed system server's security check; otherwise, EFalse.										
    43 
    44 @return					A pointer to the new prompt request object.
    45 */
    46 	{
    47 	CPromptRequest* self = CPromptRequest::NewLC(
    48 		aClientSid, aClientVid, aClientThreadId, aClientProcessId, 
    49 		aServerSid, aServiceId, aDestination, aOpaqueData, aSecurityResult);
    50 	CleanupStack::Pop(self);
    51 	return self;
    52 	}
    53 
    54 EXPORT_C CPromptRequest* CPromptRequest::NewLC(
    55 		const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId,
    56 		const TSecureId& aServerSid, const TServiceId& aServiceId, RBuf& aDestination, RBuf8& aOpaqueData, 
    57 		TBool aSecurityResult)
    58 /**
    59 Creates a new prompt request object and places the pointer on the cleanup stack.\n
    60 
    61 The ownership of the aDestination and aOpaqueData RBufs is transfered
    62 to this class. The callers RBufs will be empty after this call.
    63 
    64 @param aClientSid		The SID of the client process requesting the service.
    65 @param aClientVid		The VID of the client process requesting the service.
    66 @param aClientThreadId	The id of the thread within the client process requesting the service.
    67 @param aServerSid		The SID of the system server that provides the service.
    68 @param aServiceId		The UID of the requested service.
    69 @param aDestination		The data that the service acts on E.g. A phone number, IAP, domain name
    70 @param aOpaqueData		Opaque data structure populated by the system server. Typically, this 
    71 						contains extra information about the requested service.	
    72 @param aSecurityResult	ETrue if client passed system server's security check; otherwise, EFalse.
    73 
    74 @return					A pointer to the new prompt request object.
    75 */
    76 	{
    77 	CPromptRequest* self = new(ELeave) 
    78 		CPromptRequest(aClientSid, aClientVid, aClientThreadId, aClientProcessId,
    79 		aServerSid, aServiceId, aDestination, aOpaqueData, aSecurityResult);
    80 	CleanupStack::PushL(self);
    81 	return self;
    82 	}
    83 	
    84 CPromptRequest::CPromptRequest(
    85 	const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId,
    86 	const TSecureId& aServerSid, const TServiceId& aServiceId, 
    87 	RBuf& aDestination, RBuf8& aOpaqueData, 
    88 	TBool aSecurityResult)
    89 /**
    90 Constructor
    91 @param aClientSid			The client's SID
    92 @param aClientVid			The client's VID
    93 @param aClientThreadId		The client's thread id.
    94 @param aServerId			The system server's SID.
    95 @param aServiceId			The id of the service.
    96 @param aDestination			The destination.
    97 @param aOpaqueData			The opaque data.
    98 @param aSecurityResult		Whether the client passed the system server's security check
    99 */
   100 :	iClientSid(aClientSid), iClientVid(aClientVid), iClientThreadId(aClientThreadId), iClientProcessId(aClientProcessId),
   101 	iServerSid(aServerSid), iServiceId(aServiceId),
   102 	iSecurityResult(aSecurityResult)
   103 	{
   104 	iDestination.Close();
   105 	iDestination.Swap(aDestination);
   106 	iOpaqueData.Close();
   107 	iOpaqueData.Swap(aOpaqueData);	
   108 	}
   109 			
   110 EXPORT_C const TSecureId& CPromptRequest::ClientSid() const
   111 /**
   112 Gets the SID of the client process requesting the service.
   113 @return The client's SID.
   114 */
   115 	{	
   116 	return iClientSid;
   117 	}
   118 
   119 EXPORT_C TBool CPromptRequest::IsClientSidProtected() const
   120 /**
   121 Determines whether the SID of the client process is in the protected range. 
   122 If the SID is not protected then it is likely that identify of the client process
   123 cannot reliable verified because it may an unsigned application. If so, a warning
   124 should be displayed in the prompt dialog.
   125 
   126 @return ETrue if the SID is in the protected range; otherwise EFalse is returned.
   127 */
   128 	{
   129 	return ! (iClientSid.iId & 0x80000000);
   130 	}
   131 	
   132 EXPORT_C const TVendorId& CPromptRequest::ClientVid() const
   133 /**
   134 Gets the VID of the client process requesting the service.
   135 @return The client's VID.
   136 */
   137 	{
   138 	return iClientVid;
   139 	}
   140 	
   141 EXPORT_C const TThreadId& CPromptRequest::ClientThreadId() const
   142 /**
   143 Gets the TThreadId of the client which issued the request to the system server.
   144 This thread ID may be invalid if the thread has exited (we do NOT hold an open RThread to keep around).
   145 @return The client's thread id.
   146 */
   147 	{
   148 	return iClientThreadId;
   149 	}	
   150 
   151 EXPORT_C const TProcessId& CPromptRequest::ClientProcessId() const
   152 /**
   153 Gets the TProcessId of the client which issued the request to the system server.
   154 This process ID may be invalid if the process has exited (we do NOT hold an open RProcess to keep around).
   155 @return The client's process id.
   156 */
   157 	{
   158 	return iClientProcessId;
   159 	}	
   160 
   161 EXPORT_C const TSecureId& CPromptRequest::ServerSid() const
   162 /**
   163 Gets the SID of the system server that provides the service.
   164 @return The system server's SID.
   165 */
   166 	{
   167 	return iServerSid;
   168 	}
   169 	
   170 EXPORT_C const TServiceId& CPromptRequest::ServiceId() const
   171 /**
   172 Gets the UID of the requested service.
   173 @return The service UID.
   174 */
   175 	{
   176 	return iServiceId;
   177 	}
   178 	
   179 EXPORT_C const TDesC& CPromptRequest::Destination() const
   180 /**
   181 Gets the data that the service acts on e.g. the phone number to dial.
   182 @return A reference to a descriptor containing the destination string.
   183 */
   184 	{
   185 	return iDestination;
   186 	}
   187 
   188 EXPORT_C const TDesC8& CPromptRequest::OpaqueData() const
   189 /**
   190 Gets the opaque data structure provided by the system server. 
   191 @return A reference to a descriptor containing the opaque data.
   192 */
   193 	{
   194 	return iOpaqueData;
   195 	}	
   196 
   197 EXPORT_C TBool CPromptRequest::SecurityResult() const
   198 /**
   199 Whether the client processed the system server's security check.
   200 @return ETrue, if the client process passed the system server's 
   201 security check; otherwise, EFalse is returned.
   202 */
   203 	{
   204 	return iSecurityResult;
   205 	}
   206 	
   207 CPromptRequest::~CPromptRequest()
   208 /**
   209 Destructor
   210 */
   211 	{
   212 	iDestination.Close();
   213 	iOpaqueData.Close();
   214 	}