ssl/libcrypto/inc/include/certretriever/certretriever.h
changeset 31 ce057bb09d0b
parent 0 e4d67989cc36
child 52 bf6a71c50e42
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     1 /*
       
     2 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
       
     3 
       
     4 Redistribution and use in source and binary forms, with or without 
       
     5 modification, are permitted provided that the following conditions are met:
       
     6 
       
     7 * Redistributions of source code must retain the above copyright notice, this 
       
     8   list of conditions and the following disclaimer.
       
     9 * Redistributions in binary form must reproduce the above copyright notice, 
       
    10   this list of conditions and the following disclaimer in the documentation 
       
    11   and/or other materials provided with the distribution.
       
    12 * Neither the name of Nokia Corporation nor the names of its contributors 
       
    13   may be used to endorse or promote products derived from this software 
       
    14   without specific prior written permission.
       
    15 
       
    16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
       
    17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
       
    18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
       
    19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
       
    20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
       
    21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
       
    22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
       
    23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
       
    24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
       
    25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    26 
       
    27 Description:
       
    28 */
       
    29 
       
    30  
       
    31 #ifndef CERT_RETRIEVER_H
       
    32 #define CERT_RETRIEVER_H
       
    33 
       
    34 #ifdef __cplusplus
       
    35 
       
    36 #include <unifiedcertstore.h>
       
    37 #include <mctwritablecertstore.h>
       
    38 #include <x509cert.h>
       
    39 #include <signed.h>
       
    40 #include <openssl/x509.h>
       
    41 
       
    42 #endif
       
    43 
       
    44 #define ISSUER_NAME 0
       
    45 #define SUBJECT_NAME 1
       
    46 
       
    47 // CONSTANT
       
    48 const TInt KCertMaxBuffer = 32;
       
    49 const TInt KMaxNameLength = 256;
       
    50 const TInt KMaxCertLength = 5120;
       
    51 
       
    52 #ifdef __cplusplus
       
    53 extern "C" 
       
    54 {
       
    55 #endif
       
    56 int X509_add_symbian_certs(X509_STORE * store);
       
    57 #ifdef __cplusplus
       
    58 }
       
    59 #endif
       
    60 
       
    61 
       
    62 #ifdef __cplusplus
       
    63 
       
    64 NONSHARABLE_CLASS (CCertRetriever) : public CActive
       
    65 	{
       
    66 public:
       
    67 	static CCertRetriever* NewLC(
       
    68 				X509_STORE* aStore,
       
    69 				TRequestStatus& aStatus, 
       
    70 				const CActiveScheduler* aActiveScheduler);
       
    71 	static CCertRetriever* NewL(
       
    72 				X509_STORE* aStore,
       
    73 				TRequestStatus& aStatus, 
       
    74 				const CActiveScheduler* aActiveScheduler);
       
    75 	~CCertRetriever();
       
    76 	void RunL();
       
    77 	void DoCancel();
       
    78 	TInt RunError(TInt aError);
       
    79 	void RetriveCertificateL();
       
    80 	CActiveSchedulerWait* activeSchedulerwait; //For nested wait loop;
       
    81 	TBool OwnScheduler;
       
    82 		
       
    83 private:
       
    84 	CCertRetriever(X509_STORE* aStore,
       
    85 				TRequestStatus& aStatus, 
       
    86 				const CActiveScheduler* aActiveScheduler);
       
    87 	void ConstructL();
       
    88 	
       
    89 	void OpenUnifiedCertStoreL();
       
    90     void ListCertsL();
       
    91     void AppendCerts();
       
    92     void ProcessCerts();
       
    93     
       
    94 private:
       
    95 	X509_STORE* iStore;
       
    96 	TRequestStatus& iFinStatus;
       
    97 	const CActiveScheduler* iActiveScheduler;
       
    98 	
       
    99 	RFs iFs;
       
   100 	CUnifiedCertStore * iCertStore;
       
   101  	CCertAttributeFilter * iCertFilter;
       
   102  	RMPointerArray< CCTCertInfo > iCerts;
       
   103  	
       
   104 	enum TStateLists
       
   105 	{		
       
   106 		EInitializeCertStore,
       
   107 		EListCerts,
       
   108 		EAppendCerts,
       
   109 		ENoCerts,
       
   110 		EDone
       
   111 	};  
       
   112 						
       
   113 	TStateLists iState;
       
   114 	
       
   115 	TInt iCertCount;	
       
   116 	TPtr8 iCertPtr ;
       
   117 	HBufC8 *iBuf;
       
   118 	};
       
   119 
       
   120 
       
   121 #endif
       
   122 
       
   123 #endif //CERT_RETRIEVER_H