epoc32/include/cctcertinfo.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/cctcertinfo.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/cctcertinfo.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,394 @@
     1.4 -cctcertinfo.h
     1.5 +/*
     1.6 +* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Eclipse Public License v1.0"
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description: 
    1.19 +* CCTCertInfo.H
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +/**
    1.27 + @file 
    1.28 + @internalTechnology
    1.29 +*/
    1.30 + 
    1.31 +#ifndef __CCTCERTINFO_H__
    1.32 +#define __CCTCERTINFO_H__
    1.33 +
    1.34 +#include <e32base.h>
    1.35 +#include <s32strm.h>
    1.36 +
    1.37 +#include <securitydefs.h>
    1.38 +#include <ct/mcttokentype.h>
    1.39 +#include <ct/mcttoken.h>
    1.40 +#include <ct/mcttokenobject.h>
    1.41 +
    1.42 +/** Mask constants used for serializing iDeletable and iFormat attributes 
    1.43 +*/
    1.44 +const TUint KReadOnlyFlagMask = 128;
    1.45 +const TUint KFormatMask = 127;
    1.46 +
    1.47 +/** The UID of a CertInfo MCTTokenObject. */
    1.48 +const TInt KCTObjectCertInfo = 0x101F50E6;
    1.49 +
    1.50 +/** The maximum length of a certificate label. */
    1.51 +const TUint32 KMaxCertLabelLength = 64;
    1.52 +
    1.53 +/** Defines a modifiable buffer descriptor to contain a human-readable certificate label. 
    1.54 +*
    1.55 +* @publishedAll
    1.56 +* @released */
    1.57 +typedef TBuf<KMaxCertLabelLength> TCertLabel;
    1.58 +
    1.59 +/**
    1.60 + * Mix-in class representnig data about a stored certificate.  Provides
    1.61 + * implementation of serialization.
    1.62 + * 
    1.63 + * Note that for backward compatibility reasons, the issuer hash is not serialised.
    1.64 + *
    1.65 + * @internalTechnology
    1.66 + */
    1.67 +class MCertInfo
    1.68 +	{
    1.69 + public:
    1.70 +	// Internalization/Externalization
    1.71 +	// Externalize. Writes the data out to a stream
    1.72 +	
    1.73 +  /** Externalises an object of this class to a write stream.
    1.74 +	* 
    1.75 +	* The presence of this function means that the standard templated operator<<() 
    1.76 +	* can be used to externalise objects of this class.
    1.77 +	* 
    1.78 +	* @param aStream	Stream to which the object should be externalised. */
    1.79 +	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
    1.80 +
    1.81 +	// Internalize. Reads the data from a stream 
    1.82 +	/** Internalises an object of this class from a read stream.
    1.83 +	* 
    1.84 +	* The presence of this function means that the standard templated operator>>() 
    1.85 +	* can be used to internalise objects of this class.
    1.86 +	* 
    1.87 +	* Note that this function has assignment semantics: it replaces the old value 
    1.88 +	* of the object with a new value read from the read stream.	
    1.89 +	* 
    1.90 +	* @param aStream	Stream from which the object should be internalised. */
    1.91 +	IMPORT_C void InternalizeL(RReadStream& aStream);
    1.92 +	
    1.93 + protected:
    1.94 +	IMPORT_C MCertInfo();
    1.95 +	IMPORT_C MCertInfo(const TDesC& aLabel,
    1.96 +					   TCertificateFormat aFormat,
    1.97 +					   TCertificateOwnerType aCertificateOwnerType, 
    1.98 +					   TInt aSize,
    1.99 +					   const TKeyIdentifier* aSubjectKeyId,
   1.100 +					   const TKeyIdentifier* aIssuerKeyId, 
   1.101 +					   TInt aCertificateId,
   1.102 +					   TBool aDeletable);
   1.103 +	IMPORT_C MCertInfo(const MCertInfo& aOther);
   1.104 +	IMPORT_C ~MCertInfo();
   1.105 +
   1.106 +	IMPORT_C void ConstructL(const TDesC8* aIssuerHash);
   1.107 +
   1.108 +	const TDesC8* IssuerHash() const;
   1.109 +
   1.110 + private:
   1.111 +	TBool Valid() const;
   1.112 +	const MCertInfo& operator=(const MCertInfo& aOther);
   1.113 +
   1.114 + protected:
   1.115 +	TCertLabel iLabel;
   1.116 +	TInt iCertificateId;
   1.117 +	TCertificateFormat iFormat;
   1.118 +	TCertificateOwnerType iCertificateOwnerType;
   1.119 +	TInt iSize;
   1.120 +	TKeyIdentifier iSubjectKeyId;
   1.121 +	TKeyIdentifier iIssuerKeyId;
   1.122 +	TBool iDeletable;
   1.123 +
   1.124 + private:
   1.125 +	HBufC8* iIssuerHash;
   1.126 +	};
   1.127 +
   1.128 +/** Encapsulates information about a stored certificate.
   1.129 + * 
   1.130 + * Objects of this type are usually returned by a certificate store, to allow 
   1.131 + * a client to query the contents of the store.
   1.132 + * 
   1.133 + * Note that these objects are normally constructed by certificate stores, not 
   1.134 + * by clients. 
   1.135 + *
   1.136 + * @publishedAll
   1.137 + * @released
   1.138 + */
   1.139 +class CCTCertInfo : protected CBase, public MCTTokenObject, public MCertInfo
   1.140 +	{
   1.141 +public:
   1.142 +	/** Construction -- Note that these objects are normally constructed by certificate stores, not by clients. */
   1.143 +
   1.144 +	/** 
   1.145 +	* @publishedPartner
   1.146 +	* @released
   1.147 +	*
   1.148 +	* Creates the certificate information object by copying from an existing object.
   1.149 +	* 
   1.150 +	* @param aCertInfo			The source certificate information.
   1.151 +	* @return					A pointer to the new certificate information object.
   1.152 +	* @leave KErrNoMemory	There is no memory to construct it. */
   1.153 +	IMPORT_C static CCTCertInfo* NewL(const CCTCertInfo& aCertInfo);
   1.154 +
   1.155 +	/** 
   1.156 +	* @publishedPartner
   1.157 +	* @released
   1.158 +	*
   1.159 +	* Creates the certificate information object by copying from an existing object, 
   1.160 +	* and puts a pointer to the new object onto the cleanup stack.
   1.161 +	* 
   1.162 +	* @param aCertInfo			The source certificate information.
   1.163 +	* @return					A pointer to the new certificate information object.
   1.164 +	* @leave KErrNoMemory	There is no memory to construct it. */
   1.165 +	IMPORT_C static CCTCertInfo* NewLC(const CCTCertInfo& aCertInfo);
   1.166 +
   1.167 +	/** 
   1.168 +	* @publishedPartner
   1.169 +	* @released
   1.170 +	*
   1.171 +	* Creates the certificate information object from its constituent parts.
   1.172 +	* 
   1.173 +	* @param aLabel					The certificate's label.
   1.174 +	* @param aFormat				The certificate's format.
   1.175 +	* @param aCertificateOwnerType	The owner type.
   1.176 +	* @param aSize					The size of the certificate.
   1.177 +	* @param aSubjectKeyId			The subject key ID.
   1.178 +	* @param aIssuerKeyId			The issuer key ID.
   1.179 +	* @param aToken					The token that the certificate is within.
   1.180 +	* @param aCertificateId			The ID within the object handle.
   1.181 +	* @param aDeletable				The certificate is deletable.
   1.182 +	* @param aIssuerHash			The hash of the DN of the issuer.
   1.183 +	* @return						A pointer to the new certificate information object. 
   1.184 +	* @leave KErrNoMemory		There is no memory to construct it.*/
   1.185 +	IMPORT_C static CCTCertInfo* NewL(const TDesC& aLabel, TCertificateFormat aFormat,
   1.186 +		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
   1.187 +		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
   1.188 +		MCTToken& aToken, TInt aCertificateId, TBool aDeletable, 
   1.189 +									  const TDesC8* aIssuerHash = NULL);
   1.190 +
   1.191 +	/** 
   1.192 +	* @publishedPartner
   1.193 +	* @released
   1.194 +	*
   1.195 +	* Creates the certificate information object from its constituent parts.	
   1.196 +	* 
   1.197 +	* @param aLabel					The certificate's label.
   1.198 +	* @param aFormat 				The certificate's format.
   1.199 +	* @param aCertificateOwnerType	The owner type.
   1.200 +	* @param aSize					The size of the certificate.
   1.201 +	* @param aSubjectKeyId			The subject key ID.
   1.202 +	* @param aIssuerKeyId			The issuer key ID.
   1.203 +	* @param aToken					The token that the certificate is within.
   1.204 +	* @param aCertificateId			The ID within the object handle.
   1.205 +	* @return 						A pointer to the new certificate information object.
   1.206 +	* @leave KErrNoMemory		There is no memory to construct it.*/
   1.207 +	IMPORT_C static CCTCertInfo* NewL(const TDesC& aLabel, TCertificateFormat aFormat,
   1.208 +		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
   1.209 +		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
   1.210 +		MCTToken& aToken, TInt aCertificateId);
   1.211 +
   1.212 +	/** 
   1.213 +	* @publishedPartner
   1.214 +	* @released
   1.215 +	* 
   1.216 +	* Creates the certificate information object from its constituent parts, 
   1.217 +	* and puts a pointer to the new object onto the cleanup stack.
   1.218 +	* 
   1.219 +	* @param aLabel					The certificate's label.
   1.220 +	* @param aFormat				The certificate's format.
   1.221 +	* @param aCertificateOwnerType	The owner type.
   1.222 +	* @param aSize					The size of the certificate.
   1.223 +	* @param aSubjectKeyId			The subject key ID.
   1.224 +	* @param aIssuerKeyId			The issuer key ID.
   1.225 +	* @param aToken					The token that the certificate is within.
   1.226 +	* @param aCertificateId			The ID within the object handle.
   1.227 +	* @param aDeletable				The certificate is deletable.
   1.228 +	* @param aIssuerHash			The hash of the issuer's DN.
   1.229 +	* @return						A pointer to the new certificate information object. 
   1.230 +	* @leave KErrNoMemory		There is no memory to construct it.*/
   1.231 +	IMPORT_C static CCTCertInfo* NewLC(const TDesC& aLabel, TCertificateFormat aFormat,
   1.232 +		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
   1.233 +		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
   1.234 +		MCTToken& aToken, TInt aCertificateId, TBool aDeletable, 
   1.235 +									   const TDesC8* aIssuerHash = NULL);
   1.236 +
   1.237 +	/**
   1.238 +	* @publishedPartner
   1.239 +	* @released
   1.240 +	*
   1.241 +	* Creates the certificate information object from its constituent parts, and puts 
   1.242 +	* a pointer to the new object onto the cleanup stack.
   1.243 +	* 
   1.244 +	* @param aLabel					The certificate's label.
   1.245 +	* @param aFormat				The certificate's format.
   1.246 +	* @param aCertificateOwnerType	The owner type.
   1.247 +	* @param aSize					The size of the certificate.
   1.248 +	* @param aSubjectKeyId			The subject key ID.
   1.249 +	* @param aIssuerKeyId			The issuer key ID.
   1.250 +	* @param aToken					The token that the certificate is within.
   1.251 +	* @param aCertificateId			The ID within the object handle.
   1.252 +	* @return						A pointer to the new certificate information object.
   1.253 +	* @leave KErrNoMemory		There is no memory to construct it.*/
   1.254 +	IMPORT_C static CCTCertInfo* NewLC(const TDesC& aLabel, TCertificateFormat aFormat,
   1.255 +		TCertificateOwnerType aCertificateOwnerType, TInt aSize,
   1.256 +		const TKeyIdentifier* aSubjectKeyId, const TKeyIdentifier* aIssuerKeyId,
   1.257 +		MCTToken& aToken, TInt aCertificateId);
   1.258 +
   1.259 +	/** 
   1.260 +	* @publishedPartner
   1.261 +	* @released
   1.262 +	* 
   1.263 +	* Creates the certificate information object by internalising a previously externalised 
   1.264 +	* one.
   1.265 +	* 
   1.266 +	* @param aStream			The stream from which the object is to be internalised.
   1.267 +	* @param aToken				The token that it is within.
   1.268 +	* @return					A pointer to the new certificate information object. 
   1.269 +	* @leave KErrNoMemory	There is no memory to construct it.
   1.270 +	* @see ExternalizeL
   1.271 +	* @see InternalizeL */
   1.272 +	IMPORT_C static CCTCertInfo* NewL(RReadStream& aStream, MCTToken& aToken);
   1.273 +
   1.274 +	/** 
   1.275 +	* @publishedPartner
   1.276 +	* @released
   1.277 +	* 
   1.278 +	* Creates the certificate information object, by internalising a previously externalised 
   1.279 +	* one, and puts a pointer to the new object onto the cleanup stack.	
   1.280 +	* 
   1.281 +	* @param aStream			The stream from which the object is to be internalised.
   1.282 +	* @param aToken				The token that it is within.
   1.283 +	* @return					A pointer to the new certificate information object. 
   1.284 +	* @leave KErrNoMemory	There is no memory to construct it.
   1.285 +	* @see ExternalizeL
   1.286 +	* @see InternalizeL */
   1.287 +	IMPORT_C static CCTCertInfo* NewLC(RReadStream& aStream, MCTToken& aToken);
   1.288 +
   1.289 +	/** Gets the subject key ID.	
   1.290 +	* 
   1.291 +	* @return A reference to a key identifier object. */
   1.292 +	IMPORT_C const TKeyIdentifier& SubjectKeyId() const;
   1.293 +
   1.294 +	/** Gets the issuer key ID.
   1.295 +	* 
   1.296 +	* @return A reference to a key identifier object. */
   1.297 +	IMPORT_C const TKeyIdentifier& IssuerKeyId() const;
   1.298 +
   1.299 +	/** Gets the certificate format.
   1.300 +	* 
   1.301 +	* @return The certificate format. */
   1.302 +	IMPORT_C TCertificateFormat CertificateFormat() const;
   1.303 +
   1.304 +	/** Gets the owner type.
   1.305 +	* 
   1.306 +	* @return The owner type. */
   1.307 +	IMPORT_C TCertificateOwnerType CertificateOwnerType() const;
   1.308 +
   1.309 +	/** Gets the size of the certificate.
   1.310 +	* 
   1.311 +	* Note that this function must be called so that the correct size of descriptor 
   1.312 +	* can be allocated when retrieving the certificate (with MCertStore::Retrieve()).
   1.313 +	* 
   1.314 +	* @return The size of the certificate. */
   1.315 +	IMPORT_C TInt Size() const;
   1.316 +
   1.317 +	/** Gets a handle for the object.
   1.318 +	* 
   1.319 +	* The primary purpose of the handle is to allow token objects to be 'passed' 
   1.320 +	* between processes.
   1.321 +	* 
   1.322 +	* @return	A handle for the object. 
   1.323 +	* @see TCTTokenObjectHandle */
   1.324 +	IMPORT_C TCTTokenObjectHandle Handle() const;
   1.325 +
   1.326 +	/** Whether the certificate is deletable.
   1.327 +	* 
   1.328 +	* @return	ETrue if it is possible to delete the certificate; EFalse, otherwise. */
   1.329 +	IMPORT_C TBool IsDeletable() const;
   1.330 +
   1.331 +	/** Gets the hash of the issuer's DN.
   1.332 +	* 
   1.333 +	* @return	The hash of the issuer's DN, or NULL if not known. */
   1.334 +	IMPORT_C const TDesC8* IssuerHash() const;
   1.335 +
   1.336 + public:	
   1.337 +  // from MCTTokenObject
   1.338 +	/** Gets the object's human-readable label.
   1.339 +	* 
   1.340 +	* @return	The object's human-readable label.
   1.341 +	* @see MCTTokenObject::Label()*/
   1.342 +	virtual const TDesC& Label() const;
   1.343 +
   1.344 +	/** Gets a reference to the associated token.
   1.345 +	* 
   1.346 +	* @return	A reference to the associated token.
   1.347 +	* @see MCTTokenObject::Token()*/
   1.348 +	virtual MCTToken& Token() const;
   1.349 +
   1.350 +	/** Gets a UID representing the type of the token object.
   1.351 +	* 
   1.352 +	* The function overrides MCTTokenObject::Type().
   1.353 +	* 
   1.354 +	* The meanings of possible UIDs should be documented in the documentation for 
   1.355 +	* the interface that returns them.
   1.356 +	* 
   1.357 +	* @return	A UID representing the type of the token object; this implementation 
   1.358 +	* 			returns KCTObjectCertInfo.
   1.359 +	* @see MCTTokenObject::Type() */
   1.360 +	virtual TUid Type() const;
   1.361 +	
   1.362 +	// Compares 2 cert infos
   1.363 +	/** Compares this certificate information object with a specified Certificate 
   1.364 +	* Information object for equality.
   1.365 +	* 
   1.366 +	* @param aCertInfo	The certificate information object to be compared.
   1.367 +	* @return			ETrue, if they are the same; EFalse, otherwise. */
   1.368 +	IMPORT_C TBool operator ==(const CCTCertInfo& aCertInfo) const;
   1.369 +
   1.370 +	/** Sets the certificate Id.
   1.371 +	* 
   1.372 +	* @param aCertId The certificate Id.*/
   1.373 +	IMPORT_C void SetCertificateId(TInt aCertId);
   1.374 +
   1.375 + protected:
   1.376 +	IMPORT_C virtual ~CCTCertInfo();
   1.377 +	
   1.378 + private:
   1.379 +	CCTCertInfo(MCTToken& aToken);
   1.380 +	CCTCertInfo(const TDesC& aLabel, TCertificateFormat aFormat,
   1.381 +				TCertificateOwnerType aCertificateOwnerType, 
   1.382 +				TInt aSize,
   1.383 +				const TKeyIdentifier* aSubjectKeyId,
   1.384 +				const TKeyIdentifier* aIssuerKeyId,
   1.385 +				MCTToken& aToken, TInt aCertificateId,
   1.386 +				TBool aDeletable);
   1.387 +	CCTCertInfo(const CCTCertInfo& aCertInfo);
   1.388 +	void ConstructL(RReadStream& aStream);
   1.389 +	void ConstructL(const TDesC8* aIssuerHash);
   1.390 +	
   1.391 + private:
   1.392 +	const CCTCertInfo& operator=(const CCTCertInfo& aOther);
   1.393 +	
   1.394 + private:	
   1.395 +	MCTToken& iToken;
   1.396 +	};
   1.397 +
   1.398 +#endif