00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00037 #ifndef __SECURESERVER_H__
00038 #define __SECURESERVER_H__
00039
00040 #include <e32svr.h>
00041 #include <e32uid.h>
00042 #include <e32math.h>
00043 #include <f32file.h>
00044
00049 const TUint KDefaultHeapSize=0x10000;
00050
00056 enum TSecureServerPanic
00057 {
00061 EBadRequest = 1,
00065 EDescriptorNonNumeric,
00069 EMainSchedulerError,
00073 EServerCreateServer,
00077 EServerStartServer,
00081 ECreateTrapCleanup,
00085 EBadSubsessionHandle,
00089 ESecureServerSecurityPolicy
00090 };
00091
00096 const TInt KSecureServerRangeCount = 5;
00097
00102 const TInt KSecureServerRanges[KSecureServerRangeCount] =
00103 {
00107 0,
00111 5,
00115 6,
00119 11,
00123 13
00124 };
00125
00130 const CPolicyServer::TPolicyElement KSecureServerElements[] =
00131 {
00135 _INIT_SECURITY_POLICY_S0(0x70fffff0),
00139 {_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData | ECapabilityWriteDeviceData), CPolicyServer::EFailClient}
00140 };
00141
00146 const TUint8 KSecureServerElementsIndex[KSecureServerRangeCount] =
00147 {
00152 CPolicyServer::EAlwaysPass,
00157 0,
00162 CPolicyServer::ECustomCheck,
00167 1,
00172 CPolicyServer::ENotSupported
00173 };
00174
00180 const CPolicyServer::TPolicy KSecureServerPolicy =
00181 {
00185 CPolicyServer::EAlwaysPass,
00186 KSecureServerRangeCount,
00187 KSecureServerRanges,
00188 KSecureServerElementsIndex,
00189 KSecureServerElements
00190 };
00191
00203 class CSecureServer : public CPolicyServer
00204 {
00205 public:
00206 CSession2* NewSessionL(const TVersion &aVersion,const RMessage2& aMessage) const;
00207 static CSecureServer* NewL(CActive::TPriority aActiveObjectPriority);
00208 static TInt ThreadFunction(TAny* aStarted);
00209 static void PanicServer(TSecureServerPanic aPanic);
00210 CPolicyServer::TCustomResult CustomSecurityCheckL(const RMessage2 &aMsg, TInt &aAction, TSecurityInfo &aMissing);
00211 CObjectCon* NewContainerL();
00212 void RemoveContainer(CObjectCon *aCon);
00213 ~CSecureServer();
00214 private :
00215 CSecureServer(CActive::TPriority aActiveObjectPriority);
00216 void ConstructL();
00217
00218 private:
00222 CObjectConIx* iContainerIndex;
00223 };
00224
00225 class CSecureServerSubSession;
00226
00233 class CSecureServerSession : public CSession2
00234 {
00235 public:
00236 static CSecureServerSession* NewL();
00237 void CreateL();
00238 void ServiceL(const RMessage2& aMessage);
00239 void NewCounterL(const RMessage2& aMessage);
00240 void CloseSession();
00241 void NumResourcesL(const RMessage2& aMessage);
00242 CSecureServerSubSession* CounterFromHandle(const RMessage2& aMessage,TInt aHandle);
00243 void DeleteCounter(TInt aHandle);
00244 TInt CountResources();
00245 void PanicClient(const RMessage2& aMessage,TInt aPanic) const;
00246 CSecureServerSession();
00247 private:
00251 CObjectCon* iContainer;
00255 CObjectIx* iCountersObjectIndex;
00260 TInt iResourceCount;
00261 };
00262
00269 class CSecureServerSubSession : public CObject
00270 {
00271 public:
00272 static CSecureServerSubSession* NewL(CSecureServerSession* aSession);
00273 CSecureServerSubSession(CSecureServerSession* aSession);
00274 void ConstructL(CSecureServerSession* aSession);
00275 void SetFromStringL(const RMessage2& aMessage);
00276 void Increase();
00277 void IncreaseBy(const RMessage2& aMessage);
00278 void Decrease();
00279 void DecreaseBy(const RMessage2& aMessage);
00280 void Reset();
00281 void CounterValueL(const RMessage2& aMessage);
00282 void SaveCounterValueL();
00283 void SetCounterValueFromFileL();
00284
00285 protected:
00289 CSecureServerSession* iSession;
00290
00291 private:
00295 TInt iCount;
00296 };
00297
00298 #endif