policymanagement/policyengine/policyengineserver/inc/TrustedSession.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Implementation of policymanagement components
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef TRUSTED_SESSION_HEADER_
       
    21 #define TRUSTED_SESSION_HEADER_
       
    22 
       
    23 // INCLUDES
       
    24 
       
    25 #include "ElementBase.h"
       
    26 
       
    27 
       
    28 #include <PolicyEngineClientServer.h>
       
    29 #include <e32base.h>
       
    30 #include <ssl.h>
       
    31 #include <e32cmn.h>
       
    32 
       
    33 class CX509Certificate;
       
    34 class CX500DistinguishedName;
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 const TInt KSerialNoLength = 20;
       
    39 const TInt KCertNameLength = 100;
       
    40 
       
    41 // MACROS
       
    42 // DATA TYPES
       
    43 // FUNCTION PROTOTYPES
       
    44 // FORWARD DECLARATIONS
       
    45 
       
    46 class CPolicyStorage;
       
    47 class CCertificateMaps;
       
    48 class CElementBase;
       
    49 class CSubjectInfo;
       
    50 
       
    51 // CLASS DECLARATION
       
    52 
       
    53 
       
    54 class CTrustedSession : public CBase
       
    55 {
       
    56 	public:
       
    57 		/**
       
    58 		* CTrustedSession Constructor for CTrustedSession class
       
    59         */
       
    60 		CTrustedSession();
       
    61 
       
    62 		/**
       
    63 		* ~CTrustedSession Destructor for CTrustedSession class
       
    64         */
       
    65 		~CTrustedSession();
       
    66 	
       
    67 		/**
       
    68 		* NewL() Symbian specific two phase constructor
       
    69 		* @return Pointer to created CTrustedSession object
       
    70         */
       
    71 		static CTrustedSession * NewL();
       
    72 	
       
    73 		void ConstructL();
       
    74 	
       
    75 		void MakeSessionTrustL( const RMessage2& aMessage);
       
    76 		TCertInfo& SessionCertificate();
       
    77 		void AddSessionSIDL( TUid aSecirityUID);
       
    78 		void RemoveSessionTrust();
       
    79 	
       
    80 		TBool CertificatedSession() const;
       
    81 		const TDesC8& CASNForSessionL(); 
       
    82 		const TDesC8& SIDForSession(); 
       
    83 		
       
    84 		TBool CertMatchL( const TDesC8& aTrustedSubject1, const TDesC8& aTrustedSubject2, TBool aUseEditedItems );
       
    85 		TBool RoleMatchL( const TDesC8& aTrustedSubject, const TDesC8& aRole, TBool aUseEditedItems );
       
    86 		
       
    87 		const TDesC8& CommonNameForSubjectL( const TDesC8& aTrustedSubject, TBool aUseEditedItems ); 
       
    88 		const TDesC8& FingerPrintForSubjectL( const TDesC8& aTrustedSubject, TBool aUseEditedItems ); 
       
    89  		
       
    90   		TBool IsCertificateMappingValidL( CElementBase * aElement);
       
    91   		void GetMappedTargetTrustedSubjectL( RPointerArray<HBufC8>& aTargetTrustedMappedSubjectArray, CElementBase * aElement, TBool aUseEditedItems );
       
    92   		HBufC8* GetTargetTrustedSubjectL( CElementBase * aElement, TBool aUseEditedItems );
       
    93   		CElementBase* CreateCertificateMappingL( const TDesC8& aAlias );
       
    94 		 
       
    95 		void ReplaceIllegalCharacters( TPtr8& aData );
       
    96  		
       
    97 	private:
       
    98 		TBool iSessionTrust;
       
    99 		TCertInfo iSessionCertInfo;	
       
   100 		TBuf8<40> iFingerPrint;
       
   101 		TBuf8<40> iSessionSID;
       
   102 		
       
   103 		HBufC8* iCASN;
       
   104 };
       
   105 
       
   106 class CCertificateMaps : public CBase
       
   107 {
       
   108 	public:
       
   109 		class CRolesInfo : public CBase
       
   110 		{
       
   111 			public:
       
   112 				CRolesInfo();
       
   113 				~CRolesInfo();
       
   114 				static CRolesInfo* NewL( const TDesC8& aRole, TElementState aState);
       
   115 			public:
       
   116 				HBufC8 * iRole;
       
   117 				TElementState iState;
       
   118 		};
       
   119 	
       
   120 		typedef RPointerArray<CRolesInfo> RRoles;
       
   121 		typedef RPointerArray<CSubjectInfo> RInfos;
       
   122 		class CSubjectInfo : public CBase
       
   123 		{
       
   124 			public:
       
   125 				CSubjectInfo();
       
   126 				~CSubjectInfo();
       
   127 				
       
   128 				TBool Match( const TDesC8& aTrustedSubject, TBool aCheckMappedCertificates);
       
   129 				TBool RoleMatchL( const TDesC8& aRole);
       
   130 				TRole CertificateRoleL( TBool aUseEditedItems );
       
   131 
       
   132 			public:
       
   133 				HBufC8* iCASN;					//CA+SerialNumber+FP
       
   134 				HBufC8* iMappedToCert;			//CA+SerialNumber+FP
       
   135 				CSubjectInfo* iMappedToInfo;	//pointer to subject info
       
   136 				HBufC8* iAlias;					//Alias for certificate
       
   137 				HBufC8* iSubject;				//Issued to information
       
   138 				HBufC8* iFingerPrint;			//fingerprint
       
   139 				RRoles iRoles;					//list of roles which are valid for subject 
       
   140 				TElementState iState;			//indicates corresponding rule element state
       
   141 		};
       
   142 
       
   143 	public:
       
   144 		CCertificateMaps();
       
   145 		~CCertificateMaps();
       
   146 		static CCertificateMaps* NewL();
       
   147 
       
   148 		void NewMappingsAvailable();
       
   149 		TRole CertificateRoleL( const TCertInfo& aCertInfo, TBool aUseEditedItems);
       
   150  		static void CreateSubjectInfoL( CSubjectInfo * aInfo, const TDesC8& aCertificate);
       
   151  		static void CreateSubjectInfoL( CSubjectInfo * aInfo, const TCertInfo& aCertInfo);
       
   152  		static void CreateFingerPrint( TDes8& iFingerPrint, const TCertInfo& aCertInfo);
       
   153  		static HBufC8* CasnForCertInfoL( const TCertInfo& aInfo);
       
   154  		
       
   155  		static CX509Certificate* ParseCertificateL( const TDesC8& aCertificate);
       
   156 		static TBool EvaluateElementValidity( const TBool aUseEditedElements, const TElementState aState);
       
   157 		
       
   158 	
       
   159 	private:
       
   160 		void BringUpToDateL();
       
   161 		void LoadCertificateMapsL();
       
   162 		void AddRolesToCertL( const TDesC8& aRole, const TDesC8& aSubject, TElementState aElementState);
       
   163 		static void ParseSubjectInfoL( CSubjectInfo* aInfo, CX509Certificate* aCertificate);
       
   164 		static HBufC8* ParseDNL( const CX500DistinguishedName * aDN, TBool aOnlyCommonName);
       
   165 		
       
   166 		CSubjectInfo* FindSubjectL( const TDesC8& aTrustedSubject, TBool aUseEditedItems);
       
   167 		
       
   168 		TBool IsAliasExistL( const TDesC8& aAlias);
       
   169 	private:
       
   170 		RPointerArray<CSubjectInfo> iCerts;
       
   171 		CPolicyStorage* iPolicyStorage;
       
   172 		TBool iMapsUpToDate;
       
   173 		
       
   174 		friend class CTrustedSession;
       
   175 };
       
   176 
       
   177 #endif