TSecurityPolicy Class Reference

class TSecurityPolicy

Class representing a generic security policy

This class can specify a security policy consisting of either:

  1. A check for between 0 and 7 capabilities

  2. A check for a given Secure ID along with 0-3 capabilities

  3. A check for a given Vendor ID along with 0-3 capabilities

If multiple capabilities are specified, all of them must be present for the security check to succeed ('AND' relation).

The envisaged use case for this class is to specify access rights to an object managed either by the kernel or by a server but in principle owned by a client and usable in a limited way by other clients. For example
  • Publish and Subscribe properties

  • DBMS databases

In these cases the owning client would pass one (or more) of these objects to the server to specify which security checks should be done on other clients before allowing access to the object.

To pass a TSecurityPolicy object via IPC, a client should obtain a descriptor for the object using Package() and send this. When a server receives this descriptor it should read the descriptor contents into a TSecurityPolicyBuf and then Set() should be used to create a policy object from this.

Because this class has non-default constructors, compilers will not initialise this object at compile time, instead code will be generated to construct the object at run-time. This is wasteful - and Symbian OS DLLs are not permitted to have such uninitialised data. To overcome these problems a set of macros are provided to construct a const object which behaves like a TSecurityPolicy. These are:

_LIT_SECURITY_POLICY_C1 through _LIT_SECURITY_POLICY_C7, _LIT_SECURITY_POLICY_S0 through _LIT_SECURITY_POLICY_S3 and _LIT_SECURITY_POLICY_V0 through _LIT_SECURITY_POLICY_V3.

Also, the macros _LIT_SECURITY_POLICY_PASS and _LIT_SECURITY_POLICY_FAIL are provided in order to allow easy construction of a const object which can be used as a TSecuityPolicy which always passes or always fails, respectively.

If a security policy object is needed to be embedded in another class then the TStaticSecurityPolicy structure can be used. This behaves in the same way as a TSecurityPolicy object but may be initialised at compile time.

TStaticSecurityPolicy

TSecurityPolicyBuf

_LIT_SECURITY_POLICY_PASS

_LIT_SECURITY_POLICY_FAIL

_LIT_SECURITY_POLICY_C1

_LIT_SECURITY_POLICY_C2

_LIT_SECURITY_POLICY_C3

_LIT_SECURITY_POLICY_C4

_LIT_SECURITY_POLICY_C5

_LIT_SECURITY_POLICY_C6

_LIT_SECURITY_POLICY_C7

_LIT_SECURITY_POLICY_S0

_LIT_SECURITY_POLICY_S1

_LIT_SECURITY_POLICY_S2

_LIT_SECURITY_POLICY_S3

_LIT_SECURITY_POLICY_V0

_LIT_SECURITY_POLICY_V1

_LIT_SECURITY_POLICY_V2

_LIT_SECURITY_POLICY_V3

Public Member Functions
TSecurityPolicy()
TSecurityPolicy(TSecPolicyType)
TSecurityPolicy(TCapability, TCapability, TCapability)
TSecurityPolicy(TCapability, TCapability, TCapability, TCapability, TCapability, TCapability, TCapability)
TSecurityPolicy(TSecureId, TCapability, TCapability, TCapability)
TSecurityPolicy(TVendorId, TCapability, TCapability, TCapability)
TBool CheckPolicy(RProcess, const char *)
TBool CheckPolicy(RThread, const char *)
TBool CheckPolicy(RMessagePtr2, const char *)
TBool CheckPolicy(RMessagePtr2, TSecurityInfo &, const char *)
TInt CheckPolicy(RSessionBase)
TBool CheckPolicyCreator(const char *)
IMPORT_C TPtrC8Package()
IMPORT_C TIntSet(const TDesC8 &)
TBool Validate()
Protected Member Functions
TBool CheckPolicy(const SSecurityInfo &, SSecurityInfo &)
Private Member Functions
voidConstructAndCheck3(TCapability, TCapability, TCapability)
IMPORT_C TBoolDoCheckPolicy(RProcess, const char *)
IMPORT_C TBoolDoCheckPolicy(RProcess)
IMPORT_C TBoolDoCheckPolicy(RThread, const char *)
IMPORT_C TBoolDoCheckPolicy(RThread)
IMPORT_C TBoolDoCheckPolicy(RMessagePtr2, const char *)
IMPORT_C TBoolDoCheckPolicy(RMessagePtr2)
TBool DoCheckPolicy(RMessagePtr2, TSecurityInfo &, const char *)
TBool DoCheckPolicy(RMessagePtr2, TSecurityInfo &)
IMPORT_C TBoolDoCheckPolicyCreator(const char *)
IMPORT_C TBoolDoCheckPolicyCreator()
Public Member Enumerations
enumTSecPolicyType { EAlwaysFail = 0, EAlwaysPass = 1 }
enumTType {
ETypeFail = 0, ETypePass = 1, ETypeC3 = 2, ETypeC7 = 3, ETypeS3 = 4, ETypeV3 = 5, ETypeLimit
}
Public Attributes
TUint8 iExtraCaps
TUint32 iSecureId
TUint32 iVendorId
Private Attributes
union TSecurityPolicy::@18@19
TUint8 iCaps
TUint8 iType

Constructor & Destructor Documentation

TSecurityPolicy()

TSecurityPolicy()[inline]

Constructs a TSecurityPolicy that will always fail, irrespective of the checked object's attributes.

TSecurityPolicy(TSecPolicyType)

IMPORT_CTSecurityPolicy(TSecPolicyTypeaType)

Parameters

TSecPolicyType aType

TSecurityPolicy(TCapability, TCapability, TCapability)

IMPORT_CTSecurityPolicy(TCapabilityaCap1,
TCapabilityaCap2 = ECapability_None,
TCapabilityaCap3 = ECapability_None
)

Parameters

TCapability aCap1
TCapability aCap2 = ECapability_None
TCapability aCap3 = ECapability_None

TSecurityPolicy(TCapability, TCapability, TCapability, TCapability, TCapability, TCapability, TCapability)

IMPORT_CTSecurityPolicy(TCapabilityaCap1,
TCapabilityaCap2,
TCapabilityaCap3,
TCapabilityaCap4,
TCapabilityaCap5 = ECapability_None,
TCapabilityaCap6 = ECapability_None,
TCapabilityaCap7 = ECapability_None
)

Parameters

TCapability aCap1
TCapability aCap2
TCapability aCap3
TCapability aCap4
TCapability aCap5 = ECapability_None
TCapability aCap6 = ECapability_None
TCapability aCap7 = ECapability_None

TSecurityPolicy(TSecureId, TCapability, TCapability, TCapability)

IMPORT_CTSecurityPolicy(TSecureIdaSecureId,
TCapabilityaCap1 = ECapability_None,
TCapabilityaCap2 = ECapability_None,
TCapabilityaCap3 = ECapability_None
)

Parameters

TSecureId aSecureId
TCapability aCap1 = ECapability_None
TCapability aCap2 = ECapability_None
TCapability aCap3 = ECapability_None

TSecurityPolicy(TVendorId, TCapability, TCapability, TCapability)

IMPORT_CTSecurityPolicy(TVendorIdaVendorId,
TCapabilityaCap1 = ECapability_None,
TCapabilityaCap2 = ECapability_None,
TCapabilityaCap3 = ECapability_None
)

Parameters

TVendorId aVendorId
TCapability aCap1 = ECapability_None
TCapability aCap2 = ECapability_None
TCapability aCap3 = ECapability_None

Member Functions Documentation

CheckPolicy(RProcess, const char *)

TBool CheckPolicy(RProcessaProcess,
const char *aDiagnostic = 0
)const [inline]

Checks this policy against the platform security attributes of aProcess.

When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.

ETrue if all the requirements of this TSecurityPolicy are met by the platform security attributes of aProcess, EFalse otherwise.

panic

USER 190 if 'this' is an invalid SSecurityInfo object

Parameters

RProcess aProcessThe RProcess object to check against this TSecurityPolicy.
const char * aDiagnostic = 0A string that will be emitted along with any diagnostic message that may be issued if the policy check fails. This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro which enables it to be easily removed from the system.

CheckPolicy(RThread, const char *)

TBool CheckPolicy(RThreadaThread,
const char *aDiagnostic = 0
)const [inline]

Checks this policy against the platform security attributes of the process owning aThread.

When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.

ETrue if all the requirements of this TSecurityPolicy are met by the platform security parameters of the owning process of aThread, EFalse otherwise.

panic

USER 190 if 'this' is an invalid SSecurityInfo object

Parameters

RThread aThreadThe thread whose owning process' platform security attributes are to be checked against this TSecurityPolicy.
const char * aDiagnostic = 0A string that will be emitted along with any diagnostic message that may be issued if the policy check fails. This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro which enables it to be easily removed from the system.

CheckPolicy(RMessagePtr2, const char *)

TBool CheckPolicy(RMessagePtr2aMsgPtr,
const char *aDiagnostic = 0
)const [inline]

Checks this policy against the platform security attributes of the process which sent the given message.

When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.

ETrue if all the requirements of this TSecurityPolicy are met by the platform security attributes of aMsg, EFalse otherwise.

panic

USER 190 if 'this' is an invalid SSecurityInfo object

Parameters

RMessagePtr2 aMsgPtrThe RMessagePtr2 object to check against this TSecurityPolicy.
const char * aDiagnostic = 0A string that will be emitted along with any diagnostic message that may be issued if the policy check fails. This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro which enables it to be easily removed from the system.

CheckPolicy(RMessagePtr2, TSecurityInfo &, const char *)

TBool CheckPolicy(RMessagePtr2aMsgPtr,
TSecurityInfo &aMissing,
const char *aDiagnostic = 0
)const [inline]

Checks this policy against the platform security attributes of the process which sent the given message.

When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.

ETrue if all the requirements of this TSecurityPolicy are met by the platform security attributes of aMsg, EFalse otherwise.

panic

USER 190 if 'this' is an invalid SSecurityInfo object

Parameters

RMessagePtr2 aMsgPtrThe RMessagePtr2 object to check against this TSecurityPolicy.
TSecurityInfo & aMissingA TSecurityInfo object which this method fills with any capabilities or IDs it finds to be missing.
const char * aDiagnostic = 0A string that will be emitted along with any diagnostic message that may be issued if the policy check fails. This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro which enables it to be easily removed from the system.

CheckPolicy(RSessionBase)

TInt CheckPolicy(RSessionBaseaSession)const

Parameters

RSessionBase aSession

CheckPolicy(const SSecurityInfo &, SSecurityInfo &)

TBool CheckPolicy(const SSecurityInfo &aSecInfo,
SSecurityInfo &aMissing
)const [protected]

Parameters

const SSecurityInfo & aSecInfo
SSecurityInfo & aMissing

CheckPolicyCreator(const char *)

TBool CheckPolicyCreator(const char *aDiagnostic = 0)const [inline]

Checks this policy against the platform security attributes of this process' creator.

When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.

ETrue if all the requirements of this TSecurityPolicy are met by the platform security attributes of this process' creator, EFalse otherwise.

panic

USER 190 if 'this' is an invalid SSecurityInfo object

Parameters

const char * aDiagnostic = 0A string that will be emitted along with any diagnostic message that may be issued if the policy check fails. This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro which enables it to be easily removed from the system.

ConstructAndCheck3(TCapability, TCapability, TCapability)

voidConstructAndCheck3(TCapabilityaCap1,
TCapabilityaCap2,
TCapabilityaCap3
)[private]

Parameters

TCapability aCap1
TCapability aCap2
TCapability aCap3

DoCheckPolicy(RProcess, const char *)

IMPORT_C TBoolDoCheckPolicy(RProcessaProcess,
const char *aDiagnostic
)const [private]

Parameters

RProcess aProcess
const char * aDiagnostic

DoCheckPolicy(RProcess)

IMPORT_C TBoolDoCheckPolicy(RProcessaProcess)const [private]

Parameters

RProcess aProcess

DoCheckPolicy(RThread, const char *)

IMPORT_C TBoolDoCheckPolicy(RThreadaThread,
const char *aDiagnostic
)const [private]

Parameters

RThread aThread
const char * aDiagnostic

DoCheckPolicy(RThread)

IMPORT_C TBoolDoCheckPolicy(RThreadaThread)const [private]

Parameters

RThread aThread

DoCheckPolicy(RMessagePtr2, const char *)

IMPORT_C TBoolDoCheckPolicy(RMessagePtr2aMsgPtr,
const char *aDiagnostic
)const [private]

Parameters

RMessagePtr2 aMsgPtr
const char * aDiagnostic

DoCheckPolicy(RMessagePtr2)

IMPORT_C TBoolDoCheckPolicy(RMessagePtr2aMsgPtr)const [private]

Parameters

RMessagePtr2 aMsgPtr

DoCheckPolicy(RMessagePtr2, TSecurityInfo &, const char *)

TBool DoCheckPolicy(RMessagePtr2aMsgPtr,
TSecurityInfo &aMissing,
const char *aDiagnostic
)const [private]

Parameters

RMessagePtr2 aMsgPtr
TSecurityInfo & aMissing
const char * aDiagnostic

DoCheckPolicy(RMessagePtr2, TSecurityInfo &)

TBool DoCheckPolicy(RMessagePtr2aMsgPtr,
TSecurityInfo &aMissing
)const [private]

Parameters

RMessagePtr2 aMsgPtr
TSecurityInfo & aMissing

DoCheckPolicyCreator(const char *)

IMPORT_C TBoolDoCheckPolicyCreator(const char *aDiagnostic)const [private]

Parameters

const char * aDiagnostic

DoCheckPolicyCreator()

IMPORT_C TBoolDoCheckPolicyCreator()const [private]

Package()

IMPORT_C TPtrC8Package()const

Set(const TDesC8 &)

IMPORT_C TIntSet(const TDesC8 &aDes)

Parameters

const TDesC8 & aDes

Validate()

TBool Validate()const

Member Enumerations Documentation

Enum TSecPolicyType

Enumerators

EAlwaysFail = 0
EAlwaysPass = 1

Enum TType

Constants to specify the type of TSecurityPolicy objects.

Enumerators

ETypeFail = 0

Always fail

ETypePass = 1

Always pass

ETypeC3 = 2

Up to 3 capabilities

ETypeC7 = 3

Up to 7 capabilities

ETypeS3 = 4

Secure ID and up to 3 capabilities

ETypeV3 = 5

Vendor ID and up to 3 capabilities

ETypeLimit

The number of possible TSecurityPolicy types This is intended for internal Symbian use only.

Member Data Documentation

union TSecurityPolicy::@18 @19

union TSecurityPolicy::@18@19[private]

TUint8 iCaps

TUint8 iCaps[private]

TUint8 iExtraCaps

TUint8 iExtraCaps

TUint32 iSecureId

TUint32 iSecureId

TUint8 iType

TUint8 iType[private]

TUint32 iVendorId

TUint32 iVendorId