datacommsserver/esockserver/ssock/ss_platsec_apiext.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2006-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #define SYMBIAN_NETWORKING_UPS
       
    22 
       
    23 #include <comms-infras/ss_platsec_apiext.h>
       
    24 #include <ss_glob.h>
       
    25 #include <comms-infras/ss_roles.h>
       
    26 #include "SS_conn.H"
       
    27 
       
    28 using namespace ESock;
       
    29 
       
    30 
       
    31 // ======== MPlatsecExtensionApi Implementation ========
       
    32 
       
    33 EXPORT_C ASubSessionPlatsecApiExt::ASubSessionPlatsecApiExt(const TSubSessionUniqueId aSubSessionUniqueId)
       
    34     : iSubSessionUniqueId(aSubSessionUniqueId)
       
    35     {
       
    36     }
       
    37 
       
    38 EXPORT_C TInt ASubSessionPlatsecApiExt::SecureId(TSecureId& aResult) const
       
    39     {
       
    40 	return AIPCClientPlatsecInfo::SecureId(iSubSessionUniqueId, aResult);
       
    41     }
       
    42 
       
    43 
       
    44 EXPORT_C TInt ASubSessionPlatsecApiExt::VendorId(TVendorId& aResult) const
       
    45     {
       
    46 	return AIPCClientPlatsecInfo::VendorId(iSubSessionUniqueId, aResult);
       
    47     }
       
    48 
       
    49 EXPORT_C TBool ASubSessionPlatsecApiExt::HasCapability(const TCapability aCapability) const
       
    50    {
       
    51    return AIPCClientPlatsecInfo::HasCapability(iSubSessionUniqueId, aCapability);
       
    52    }
       
    53 
       
    54 
       
    55 EXPORT_C TInt ASubSessionPlatsecApiExt::CheckPolicy(const TSecurityPolicy& aPolicy) const
       
    56     {
       
    57     return AIPCClientPlatsecInfo::CheckPolicy(iSubSessionUniqueId, aPolicy);
       
    58     }
       
    59 
       
    60 #ifdef SYMBIAN_NETWORKING_UPS
       
    61 
       
    62 //
       
    63 // UPS support
       
    64 //
       
    65 
       
    66 EXPORT_C TInt ASubSessionPlatsecApiExt::GetProcessAndThreadId(TProcessId& aProcessId, TThreadId& aThreadId) const
       
    67     {
       
    68     return AIPCClientPlatsecInfo::GetProcessAndThreadId(iSubSessionUniqueId, aProcessId, aThreadId);
       
    69     }
       
    70     
       
    71 ASockSubSessionPlatsecApiExt::ASockSubSessionPlatsecApiExt()
       
    72   	{
       
    73   	}
       
    74 
       
    75 ASockSubSessionPlatsecApiExt::~ASockSubSessionPlatsecApiExt()
       
    76   	{
       
    77   	}
       
    78 
       
    79 TInt ASockSubSessionPlatsecApiExt::SecureId(TSecureId& /*aResult*/) const
       
    80 	{
       
    81 	Fault(ENotImplementedYet);
       
    82 	return KErrNotSupported;
       
    83 	}
       
    84 
       
    85 TInt ASockSubSessionPlatsecApiExt::VendorId(TVendorId& /*aResult*/) const
       
    86 	{
       
    87 	Fault(ENotImplementedYet);
       
    88 	return KErrNotSupported;
       
    89 	}
       
    90 
       
    91 TBool ASockSubSessionPlatsecApiExt::HasCapability(const TCapability /*aCapability*/) const
       
    92 	{
       
    93 	Fault(ENotImplementedYet);
       
    94 	return EFalse;
       
    95 	}
       
    96 
       
    97 TInt ASockSubSessionPlatsecApiExt::CheckPolicy(const TSecurityPolicy& /*aPolicy*/) const
       
    98 	{
       
    99 	Fault(ENotImplementedYet);
       
   100 	return KErrNotSupported;
       
   101 	}
       
   102 
       
   103 TInt ASockSubSessionPlatsecApiExt::GetProcessAndThreadIdFromRMessage(const RMessage2& aMessage, TProcessId& aProcessId, TThreadId& aThreadId)
       
   104 /**
       
   105 Retrieve the process and thread id associated with the current IPC.
       
   106 
       
   107 @param aMessage RMessage2 associated with current IPC
       
   108 @return KErrNone or a system wide error code .
       
   109 */
       
   110 	{
       
   111 	// Retrieve thread and process id, if message is not null.
       
   112 	TInt err = KErrNone;
       
   113 	if (!aMessage.IsNull())
       
   114 		{
       
   115 		RThread thread;
       
   116 		err = aMessage.Client(thread);
       
   117 		if (err == KErrNone)
       
   118 			{
       
   119 			RProcess process;
       
   120 			err = thread.Process(process);
       
   121 			if (err == KErrNone)
       
   122 				{
       
   123 				aProcessId = process.Id();
       
   124 				aThreadId = thread.Id();
       
   125 				process.Close();
       
   126 				}
       
   127 			thread.Close();
       
   128 			}
       
   129 		}
       
   130 	else
       
   131 		{
       
   132 		err = KErrArgument;
       
   133 		}
       
   134 	return err;
       
   135 	}
       
   136 
       
   137 #endif //SYMBIAN_NETWORKING_UPS
       
   138 
       
   139 EXPORT_C TInt TCFSigRMessage2PlatsecExt::SecureId(TSecureId& aResult) const
       
   140     {
       
   141     aResult = iMessage.SecureId();
       
   142 
       
   143     return KErrNone;
       
   144     }
       
   145 
       
   146 
       
   147 EXPORT_C TInt TCFSigRMessage2PlatsecExt::VendorId(TVendorId& aResult) const
       
   148     {
       
   149     aResult = iMessage.VendorId();
       
   150 
       
   151     return KErrNone;
       
   152     }
       
   153 
       
   154 EXPORT_C TBool TCFSigRMessage2PlatsecExt::HasCapability(const TCapability aCapability) const
       
   155     {
       
   156     return iMessage.HasCapability(aCapability);
       
   157     }
       
   158 
       
   159 
       
   160 EXPORT_C TInt TCFSigRMessage2PlatsecExt::CheckPolicy(const TSecurityPolicy& aPolicy) const
       
   161     {
       
   162     TBool platsecResult;
       
   163     platsecResult = aPolicy.CheckPolicy(iMessage);
       
   164     if (!platsecResult)
       
   165         {
       
   166         return KErrPermissionDenied;
       
   167         }
       
   168     return KErrNone;
       
   169     }
       
   170