First public contribution.
1 // Copyright (c) 2004-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 "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\euser\us_secure.cpp
20 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
21 EXPORT_C TInt PlatSec::EmitDiagnostic(TPlatSecDiagnostic& aDiagnostic, const char* aContextText)
23 if(aContextText == KSuppressPlatSecDiagnosticMagicValue)
24 return Exec::PlatSecDiagnostic(NULL);
25 aDiagnostic.iContextText = aContextText;
27 aDiagnostic.iContextTextLength=User::StringLength((const TUint8*)aContextText);
28 return Exec::PlatSecDiagnostic(&aDiagnostic);
30 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
31 EXPORT_C TInt PlatSec::EmitDiagnostic(TPlatSecDiagnostic& /*aDiagnostic*/, const char* /*aContextText*/)
33 return Exec::PlatSecDiagnostic(NULL);
35 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
37 EXPORT_C TInt PlatSec::EmitDiagnostic()
39 return Exec::PlatSecDiagnostic(NULL);
42 EXPORT_C TSecureId RProcess::SecureId() const
45 Exec::ProcessSecurityInfo(iHandle,info);
46 return info.iSecureId;
49 EXPORT_C TVendorId RProcess::VendorId() const
52 Exec::ProcessSecurityInfo(iHandle,info);
53 return info.iVendorId;
56 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
57 EXPORT_C TBool RProcess::DoHasCapability(TCapability aCapability, const char* aDiagnostic) const
60 Exec::ProcessSecurityInfo(iHandle,info);
61 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
62 if(caps.HasCapability(aCapability))
64 return KErrNone==PlatSec::CapabilityCheckFail(iHandle,aCapability,aDiagnostic);
66 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
67 EXPORT_C TBool RProcess::DoHasCapability(TCapability aCapability, const char* /*aDiagnostic*/) const
69 return DoHasCapability(aCapability);
71 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
73 EXPORT_C TBool RProcess::DoHasCapability(TCapability aCapability) const
75 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
76 return DoHasCapability(aCapability, NULL);
77 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
79 Exec::ProcessSecurityInfo(iHandle,info);
80 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
81 if(caps.HasCapability(aCapability))
83 return (PlatSec::EmitDiagnostic() == KErrNone);
84 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
87 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
88 EXPORT_C TBool RProcess::DoHasCapability(TCapability aCapability1, TCapability aCapability2, const char* aDiagnostic) const
91 Exec::ProcessSecurityInfo(iHandle,info);
92 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
93 if(caps.HasCapability(aCapability1) && caps.HasCapability(aCapability2))
95 TCapabilitySet missing(aCapability1,aCapability2);
97 return KErrNone==PlatSec::CapabilityCheckFail(iHandle,missing,aDiagnostic);
99 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
100 EXPORT_C TBool RProcess::DoHasCapability(TCapability aCapability1, TCapability aCapability2, const char* /*aDiagnostic*/) const
102 return DoHasCapability(aCapability1, aCapability2);
104 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
106 EXPORT_C TBool RProcess::DoHasCapability(TCapability aCapability1, TCapability aCapability2) const
108 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
109 return DoHasCapability(aCapability1, aCapability2, NULL);
110 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
112 Exec::ProcessSecurityInfo(iHandle, info);
113 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
114 if(caps.HasCapability(aCapability1) && caps.HasCapability(aCapability2))
116 return (PlatSec::EmitDiagnostic() == KErrNone);
117 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
120 EXPORT_C TSecureId RThread::SecureId() const
123 Exec::ThreadSecurityInfo(iHandle,info);
124 return info.iSecureId;
127 EXPORT_C TVendorId RThread::VendorId() const
130 Exec::ThreadSecurityInfo(iHandle,info);
131 return info.iVendorId;
134 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
135 EXPORT_C TBool RThread::DoHasCapability(TCapability aCapability, const char* aDiagnostic) const
138 Exec::ThreadSecurityInfo(iHandle,info);
139 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
140 if(caps.HasCapability(aCapability))
142 return KErrNone==PlatSec::CapabilityCheckFail(iHandle,aCapability,aDiagnostic);
144 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
145 EXPORT_C TBool RThread::DoHasCapability(TCapability aCapability, const char* /*aDiagnostic*/) const
147 return DoHasCapability(aCapability);
149 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
151 EXPORT_C TBool RThread::DoHasCapability(TCapability aCapability) const
153 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
154 return DoHasCapability(aCapability, NULL);
155 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
157 Exec::ThreadSecurityInfo(iHandle, info);
158 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
159 if(caps.HasCapability(aCapability))
161 return (PlatSec::EmitDiagnostic() == KErrNone);
162 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
165 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
166 EXPORT_C TBool RThread::DoHasCapability(TCapability aCapability1, TCapability aCapability2, const char* aDiagnostic) const
169 Exec::ThreadSecurityInfo(iHandle,info);
170 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
171 if(caps.HasCapability(aCapability1) && caps.HasCapability(aCapability2))
173 TCapabilitySet missing(aCapability1,aCapability2);
174 missing.Remove(caps);
175 return KErrNone==PlatSec::CapabilityCheckFail(iHandle,missing,aDiagnostic);
177 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
178 EXPORT_C TBool RThread::DoHasCapability(TCapability aCapability1, TCapability aCapability2, const char* /*aDiagnostic*/) const
180 return DoHasCapability(aCapability1, aCapability2);
182 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
184 EXPORT_C TBool RThread::DoHasCapability(TCapability aCapability1, TCapability aCapability2) const
186 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
187 return DoHasCapability(aCapability1, aCapability2, NULL);
188 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
190 Exec::ThreadSecurityInfo(iHandle, info);
191 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
192 if(caps.HasCapability(aCapability1) && caps.HasCapability(aCapability2))
194 return (PlatSec::EmitDiagnostic() == KErrNone);
195 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
199 EXPORT_C TSecureId RMessagePtr2::SecureId() const
202 Exec::MessageSecurityInfo(iHandle,info);
203 return info.iSecureId;
206 EXPORT_C TVendorId RMessagePtr2::VendorId() const
209 Exec::MessageSecurityInfo(iHandle,info);
210 return info.iVendorId;
213 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
214 EXPORT_C TBool RMessagePtr2::DoHasCapability(TCapability aCapability, const char* aDiagnostic) const
217 Exec::MessageSecurityInfo(iHandle,info);
218 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
219 if(caps.HasCapability(aCapability))
221 return KErrNone==PlatSec::CapabilityCheckFail(*this,aCapability,aDiagnostic);
223 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
224 EXPORT_C TBool RMessagePtr2::DoHasCapability(TCapability aCapability, const char* /*aDiagnostic*/) const
226 return DoHasCapability(aCapability);
228 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
230 EXPORT_C TBool RMessagePtr2::DoHasCapability(TCapability aCapability) const
232 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
233 return DoHasCapability(aCapability, NULL);
234 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
236 Exec::MessageSecurityInfo(iHandle,info);
237 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
238 if (caps.HasCapability(aCapability))
240 return (PlatSec::EmitDiagnostic() == KErrNone);
241 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
244 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
245 EXPORT_C TBool RMessagePtr2::DoHasCapability(TCapability aCapability1, TCapability aCapability2, const char* aDiagnostic) const
248 Exec::MessageSecurityInfo(iHandle,info);
249 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
250 if(caps.HasCapability(aCapability1) && caps.HasCapability(aCapability2))
252 TCapabilitySet missing(aCapability1,aCapability2);
253 missing.Remove(caps);
254 return KErrNone==PlatSec::CapabilityCheckFail(*this,missing,aDiagnostic);
256 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
257 EXPORT_C TBool RMessagePtr2::DoHasCapability(TCapability aCapability1, TCapability aCapability2, const char* /*aDiagnostic*/) const
259 return DoHasCapability(aCapability1, aCapability2);
261 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
263 EXPORT_C TBool RMessagePtr2::DoHasCapability(TCapability aCapability1, TCapability aCapability2) const
265 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
266 return DoHasCapability(aCapability1, aCapability2, NULL);
267 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
269 Exec::MessageSecurityInfo(iHandle,info);
270 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
271 if(caps.HasCapability(aCapability1) && caps.HasCapability(aCapability2))
273 return (PlatSec::EmitDiagnostic() == KErrNone);
274 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
277 EXPORT_C TSecureId User::CreatorSecureId()
280 Exec::CreatorSecurityInfo(info);
281 return info.iSecureId;
284 EXPORT_C TVendorId User::CreatorVendorId()
287 Exec::CreatorSecurityInfo(info);
288 return info.iVendorId;
291 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
292 EXPORT_C TBool User::DoCreatorHasCapability(TCapability aCapability, const char* aDiagnostic)
295 Exec::CreatorSecurityInfo(info);
296 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
297 if(caps.HasCapability(aCapability))
299 return KErrNone==PlatSec::CreatorCapabilityCheckFail(aCapability,aDiagnostic);
301 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
302 EXPORT_C TBool User::DoCreatorHasCapability(TCapability aCapability, const char* /*aDiagnostic*/)
304 return DoCreatorHasCapability(aCapability);
306 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
308 EXPORT_C TBool User::DoCreatorHasCapability(TCapability aCapability)
310 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
311 return DoCreatorHasCapability(aCapability, NULL);
312 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
314 Exec::CreatorSecurityInfo(info);
315 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
316 if(caps.HasCapability(aCapability))
318 return (PlatSec::EmitDiagnostic() == KErrNone);
319 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
322 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
323 EXPORT_C TBool User::DoCreatorHasCapability(TCapability aCapability1, TCapability aCapability2, const char* aDiagnostic)
326 Exec::CreatorSecurityInfo(info);
327 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
328 if(caps.HasCapability(aCapability1) && caps.HasCapability(aCapability2))
330 TCapabilitySet missing(aCapability1,aCapability2);
331 missing.Remove(caps);
332 return KErrNone==PlatSec::CreatorCapabilityCheckFail(missing,aDiagnostic);
334 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
335 EXPORT_C TBool User::DoCreatorHasCapability(TCapability aCapability1, TCapability aCapability2, const char* /*aDiagnostic*/)
337 return DoCreatorHasCapability(aCapability1, aCapability2);
339 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__
341 EXPORT_C TBool User::DoCreatorHasCapability(TCapability aCapability1, TCapability aCapability2)
343 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
344 return DoCreatorHasCapability(aCapability1, aCapability2, NULL);
345 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
347 Exec::CreatorSecurityInfo(info);
348 TCapabilitySet& caps = (TCapabilitySet&)info.iCaps;
349 if(caps.HasCapability(aCapability1) && caps.HasCapability(aCapability2))
351 return (PlatSec::EmitDiagnostic() == KErrNone);
352 #endif //!__REMOVE_PLATSEC_DIAGNOSTICS__