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