examples/Base/IPC/secureserver/secureserver.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description: Defines CSecureServer, CSecureServerSession and CSecureServerSubSession classes.
00028 It also defines the constants that form the security policy for the server.  
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

Generated by  doxygen 1.6.2