os/security/authorisation/userpromptservice/server/inc/upsclient.h
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
* Client-side API via which the system server uses the user prompt service.
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file
sl@0
    22
 @publishedAll
sl@0
    23
 @released
sl@0
    24
*/
sl@0
    25
sl@0
    26
#ifndef UPSCLIENT_H
sl@0
    27
#define UPSCLIENT_H
sl@0
    28
sl@0
    29
sl@0
    30
#include <scs/scsclient.h>
sl@0
    31
#include <ups/upstypes.h>
sl@0
    32
sl@0
    33
namespace UserPromptService
sl@0
    34
	{
sl@0
    35
sl@0
    36
class CUpsClientConfig;
sl@0
    37
class CPolicyChangeWatcher;
sl@0
    38
class RUpsSession : public RScsClientBase
sl@0
    39
/**
sl@0
    40
	The system server uses this class to establish a connection with
sl@0
    41
	the UPS server.
sl@0
    42
sl@0
    43
	Internally it retrieves and caches authorisation policy information for all the
sl@0
    44
	services supported by the current server SID. This information is used to allow
sl@0
    45
	the RUpsSubsession to avoid creating a subsession and/or querying the UPS 
sl@0
    46
	if the request does not require UPS interaction. 
sl@0
    47
sl@0
    48
 */
sl@0
    49
	{
sl@0
    50
public:
sl@0
    51
	IMPORT_C RUpsSession();
sl@0
    52
	IMPORT_C TInt Connect();
sl@0
    53
	IMPORT_C void Close();
sl@0
    54
sl@0
    55
public:
sl@0
    56
	void NotifyPolicyFileChangedL();
sl@0
    57
sl@0
    58
private:
sl@0
    59
	friend class RUpsSubsession;
sl@0
    60
	CPolicyChangeWatcher *iPolicyChangeWatcher;
sl@0
    61
	void RetrieveClientConfigL();
sl@0
    62
	CUpsClientConfig* iClientConfig;
sl@0
    63
	};
sl@0
    64
sl@0
    65
class RUpsManagement : public RScsClientBase
sl@0
    66
/**
sl@0
    67
	This class supports the management API for the UPS.
sl@0
    68
 */
sl@0
    69
	{
sl@0
    70
public:
sl@0
    71
	IMPORT_C RUpsManagement();
sl@0
    72
	IMPORT_C TInt Connect();
sl@0
    73
	IMPORT_C void Close();
sl@0
    74
sl@0
    75
	// Needs ReadDeviceData	
sl@0
    76
	IMPORT_C void CreateView(const CDecisionFilter& aFilter, TRequestStatus &aStatus);
sl@0
    77
	IMPORT_C CDecisionRecord *NextMatchL();
sl@0
    78
	IMPORT_C void CancelAndCloseView();
sl@0
    79
sl@0
    80
	// Needs WriteDeviceData	
sl@0
    81
	IMPORT_C void RemoveDecisionsL(const CDecisionFilter& aFilter);
sl@0
    82
	IMPORT_C void DeleteDatabaseL();
sl@0
    83
sl@0
    84
	// Needs AllFiles
sl@0
    85
	IMPORT_C void UpdateDecision(TUint32 aRecordId, TBool aAllow, TRequestStatus &aStatus);
sl@0
    86
	IMPORT_C void CancelUpdateDecision();
sl@0
    87
sl@0
    88
	/**
sl@0
    89
		The following three APIs are only for use by the UPS swi observer plugin and are discouraged for general use
sl@0
    90
	*/
sl@0
    91
	IMPORT_C void DeleteDecisionsForExeL(const TSecureId& aExeSid);
sl@0
    92
	IMPORT_C void NotifyPluginsMayHaveChangedL();
sl@0
    93
	IMPORT_C void NotifyPolicyFilesChanged(TRequestStatus &aStatus);
sl@0
    94
	IMPORT_C void CancelNotifyPolicyFilesChanged();
sl@0
    95
sl@0
    96
private:
sl@0
    97
	RBuf8 iCreateViewFilterBuf;
sl@0
    98
	TPckgBuf<TUint32> iMatchLengthBuf;
sl@0
    99
	};
sl@0
   100
sl@0
   101
class RUpsSubsession : public RScsClientSubsessionBase
sl@0
   102
/**
sl@0
   103
System servers use this class to establish a connection to the UPS for a specific 
sl@0
   104
client.\n
sl@0
   105
Before checking a request with the User Prompt Service the Authorise method 
sl@0
   106
first checks whether authorisation from the User Prompt Service is required. If
sl@0
   107
authorisation is not required e.g. the client has the correct capabilities for the
sl@0
   108
service then Authorise completes immediately.
sl@0
   109
*/
sl@0
   110
	{
sl@0
   111
public:
sl@0
   112
	IMPORT_C RUpsSubsession();
sl@0
   113
	IMPORT_C TInt Initialise(RUpsSession& aSession, const RThread& aClient);
sl@0
   114
sl@0
   115
	IMPORT_C void Authorise(TBool aServerCheckOk, 
sl@0
   116
							const TServiceId& aServiceId, const TDesC& aDestination,
sl@0
   117
							TUpsDecision& aDecision, TRequestStatus& aStatus);
sl@0
   118
	IMPORT_C void Authorise(TBool aServerCheckOk, 
sl@0
   119
							const TServiceId& aServiceId, const TDesC& aDestination,
sl@0
   120
							const TDesC8& aOpaqueData, 
sl@0
   121
							TUpsDecision& aDecision, TRequestStatus& aStatus);						 
sl@0
   122
	IMPORT_C void CancelPrompt();
sl@0
   123
sl@0
   124
	IMPORT_C void Close();
sl@0
   125
sl@0
   126
private:
sl@0
   127
	TInt CreateSubsession();
sl@0
   128
	void AuthoriseInternal(TBool aServerCheckOk,
sl@0
   129
		const TServiceId& aServiceId, const TDesC& aDestination, const TDesC8& aOpaqueData,
sl@0
   130
		TUpsDecision& aDecision, TRequestStatus& aStatus);
sl@0
   131
	TInt PreparePrompt(const TServiceId& aServiceId, const TDesC& aDestination, const TDesC8& aOpaqueData);
sl@0
   132
	void ExecutePrompt(TBool aServerCheckOk, TUpsDecision& aDecision, TRequestStatus& aStatus);
sl@0
   133
	
sl@0
   134
private:
sl@0
   135
	/** Describes the TUpsDecision reference passed into Authorise. */
sl@0
   136
	TPtr8 iDecPtr;
sl@0
   137
sl@0
   138
	TBool iSubsessionCreated;
sl@0
   139
	TThreadId iClientTid;
sl@0
   140
	TSecureId iClientSid;
sl@0
   141
	TProcessId iClientPid;
sl@0
   142
	RUpsSession* iUpsSession;
sl@0
   143
	};
sl@0
   144
sl@0
   145
} // End of namespace UserPromptService
sl@0
   146
sl@0
   147
#endif	// #ifndef UPSCLIENT_H
sl@0
   148