localisation/apparchitecture/apgrfx/apsecutils.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-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 //
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32cmn.h> //for TSecureId
       
    20 #include "apsecutils.h"
       
    21 
       
    22 
       
    23 /**
       
    24  * Check if application has a WriteDeviceData capability
       
    25  * and if it's SID is in the protected range
       
    26  * 
       
    27  * @param aAppFilename path to application exe file
       
    28  * @param aHasWriteDeviceDataCap returns ETrue if app has WriteDeviceData cap
       
    29  * @param aIsSidProtected returns ETrue if application SID is in the protected range
       
    30  * @return KErrNone if succesful, error code otherwise
       
    31  */
       
    32 EXPORT_C TInt CApaSecurityUtils::CheckAppSecurity( const TPtrC& aAppFilename, 
       
    33                                               TBool& aHasWriteDeviceDataCap, 
       
    34                                               TBool& aIsSidProtected )
       
    35     { 
       
    36     aHasWriteDeviceDataCap = EFalse;
       
    37     aIsSidProtected = EFalse;
       
    38     
       
    39     RLibrary::TInfoBuf infoBuf;
       
    40     TInt ret = RLibrary::GetInfo( aAppFilename, infoBuf );
       
    41     if ( KErrNone == ret )
       
    42         {
       
    43         if ( infoBuf().iSecurityInfo.iCaps.HasCapability(
       
    44                                                 ECapabilityWriteDeviceData ) )
       
    45             {
       
    46             aHasWriteDeviceDataCap = ETrue;
       
    47             }
       
    48 
       
    49         const TSecureId appSid = infoBuf().iSecurityInfo.iSecureId;
       
    50 
       
    51         if( IsSidProtected( TUint32( appSid ) ) )
       
    52             {
       
    53             aIsSidProtected = ETrue;
       
    54             }
       
    55 
       
    56         }
       
    57     return ret;
       
    58     }
       
    59 
       
    60 //End of file