appfw/apparchitecture/apgrfx/apsecutils.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Security issues related methods used across apparc
       
    15 // 
       
    16 // apsecutils.cpp
       
    17 //
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32cmn.h> //for TSecureId
       
    21 #include "apsecutils.h"
       
    22 
       
    23 
       
    24 /**
       
    25  * Check if application has a WriteDeviceData capability
       
    26  * and if it's SID is in the protected range
       
    27  * 
       
    28  * @param aAppFilename path to application exe file
       
    29  * @param aHasWriteDeviceDataCap returns ETrue if app has WriteDeviceData cap
       
    30  * @param aIsSidProtected returns ETrue if application SID is in the protected range
       
    31  * @return KErrNone if succesful, error code otherwise
       
    32  */
       
    33 EXPORT_C TInt CApaSecurityUtils::CheckAppSecurity( const TPtrC& aAppFilename, 
       
    34                                               TBool& aHasWriteDeviceDataCap, 
       
    35                                               TBool& aIsSidProtected )
       
    36     { 
       
    37     aHasWriteDeviceDataCap = EFalse;
       
    38     aIsSidProtected = EFalse;
       
    39     
       
    40     RLibrary::TInfoBuf infoBuf;
       
    41     TInt ret = RLibrary::GetInfo( aAppFilename, infoBuf );
       
    42     if ( KErrNone == ret )
       
    43         {
       
    44         if ( infoBuf().iSecurityInfo.iCaps.HasCapability(
       
    45                                                 ECapabilityWriteDeviceData ) )
       
    46             {
       
    47             aHasWriteDeviceDataCap = ETrue;
       
    48             }
       
    49 
       
    50         const TSecureId appSid = infoBuf().iSecurityInfo.iSecureId;
       
    51 
       
    52         if( IsSidProtected( TUint32( appSid ) ) )
       
    53             {
       
    54             aIsSidProtected = ETrue;
       
    55             }
       
    56 
       
    57         }
       
    58     return ret;
       
    59     }
       
    60 
       
    61 //End of file