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