wim/WimPlugin/inc/WimToken.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  A token represents one instance of a particular kind of 
       
    15 *                cryptographic module
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CWIMTOKEN_H
       
    22 #define CWIMTOKEN_H
       
    23 
       
    24 //  INCLUDES
       
    25 
       
    26 #include "WimSecModule.h"
       
    27 #include <e32base.h>
       
    28 #include <ct.h>
       
    29 
       
    30 // FORWARD DECLARATION
       
    31 
       
    32 class CWimTokenListener;
       
    33 class MCTCertStore;
       
    34 class MCTWritableCertStore;
       
    35 class MCTKeyStore;
       
    36 class MCTAuthenticationObjectList;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 *  CWimToken is a class which implements one cryptographic interface
       
    42 *
       
    43 *
       
    44 *  @lib   WimPlugin
       
    45 *  @since Series60 2.1
       
    46 */
       
    47 class CWimToken : public CBase, public MCTToken
       
    48     {
       
    49 	public:  // Constructors and destructor
       
    50         
       
    51         /**
       
    52         * Two-phased constructor.
       
    53         * @param aWimSecModule (IN) Current security module
       
    54         * @param aTokenType (IN) Created token's token type
       
    55         * @return  An instance of this class
       
    56         */
       
    57         static CWimToken* NewL( CWimSecModule* aWimSecModule, 
       
    58 										 MCTTokenType& aTokenType );
       
    59         
       
    60         /**
       
    61         * Destructor.
       
    62         */
       
    63         virtual ~CWimToken();
       
    64 
       
    65     public: // Functions from base class MCTToken
       
    66         
       
    67 		/**
       
    68         * Returns a reference to this token's label.
       
    69         * @return  A Reference to this token's label.
       
    70         */
       
    71 		const TDesC& Label();
       
    72         
       
    73 		/**
       
    74         * Returns the associated token type.
       
    75         * @return A reference to token's token type
       
    76         */
       
    77 		MCTTokenType& TokenType();
       
    78         
       
    79 		/**
       
    80         * Returns the token's handle which is TCTTokenHandle class.
       
    81         * @return tokens handle
       
    82         */
       
    83 		TCTTokenHandle Handle();
       
    84         
       
    85         /** 
       
    86         * Returns the specified information string about the token.
       
    87         * @param aRequiredInformation (IN) Specifies the required information
       
    88         *        needed from the token. See value from TTokenInformation.
       
    89         * @return TDesC&  (OUT) Information string of the token, or KNullDesC,
       
    90         *         if token information cannot be given
       
    91         */
       
    92         const TDesC& Information( 
       
    93                                 TTokenInformation aRequiredInformation );
       
    94 
       
    95 		/**
       
    96 		* Notifies the client when the token has been removed. Notify is 
       
    97         * given by changing the status code of given TRequestStatus.
       
    98         * The caller should give listener's TRequestStatus in pending state 
       
    99         * to this function.
       
   100         * Note: this is not an asynchronous call, it only stores the
       
   101         * address of given TRequestStatus for later notifications.
       
   102 		* @param  aStatus (IN/OUT) Async. request status.
       
   103         *         KErrPending, token is on it's place
       
   104         *         KErrCancel, caller has cancelled to notify token removal
       
   105         *         KErrHardwareNotAvailable, token is removed
       
   106 		*		  Any other system error code
       
   107 		* @return void
       
   108 		*/
       
   109 		void NotifyOnRemoval( TRequestStatus& aStatus );
       
   110 
       
   111 		/**
       
   112 		* Cancels the NotifyOnRemoval request.
       
   113 		* @return void
       
   114 		*/
       
   115 		void CancelNotify();
       
   116 
       
   117 	protected: // Functions from base class MCTToken
       
   118 
       
   119         /**
       
   120         * Returns a reference to pointer of an interface object.
       
   121 		* The caller owns all the parameters.
       
   122         * @param  aRequiredInterface (IN) The UID of the interface that 
       
   123 		*		  should be returned
       
   124 		* @param  aReturnedInterface (OUT). This will be set to a pointer to 
       
   125 		*		  the returned interface on success and
       
   126 		*		  to NULL if it isn't supported by this token
       
   127         * @param  aStatus (IN/OUT) Async. request status.
       
   128 		*		  KErrNone, if all ok and interface returned
       
   129 		*		  KErrCancel, if call canceled
       
   130 		*		  KErrNotSupported, if interface not supported
       
   131         *         KErrHardwareNotAvailable, if Wim card suddenly removed
       
   132         *         Any other system wide error code (e.g. KErrNoMemory)
       
   133 		* @return void
       
   134         */
       
   135         void DoGetInterface( TUid aRequiredInterface,
       
   136 						              MCTTokenInterface*& aReturnedInterface, 
       
   137 						              TRequestStatus& aStatus );
       
   138 		
       
   139 		/**
       
   140         * Cancels DoGetInterface operation.
       
   141         * @return Boolean value: true, if cancel is appropriate, false if
       
   142         *         cancel is not appropriate
       
   143         */
       
   144 		TBool DoCancelGetInterface();
       
   145 
       
   146 	public: // New functions
       
   147 
       
   148 		/**
       
   149 		* Returns a pointer to current security module.
       
   150 		* @return A pointer to current security module
       
   151 		*/
       
   152 		CWimSecModule* WimSecModule();
       
   153 
       
   154 		/**
       
   155 		* Returns a pointer to token listener
       
   156 		* @return A pointer to token listener
       
   157 		*/
       
   158 		CWimTokenListener* TokenListener();
       
   159 
       
   160 		/**
       
   161 		* Returns a boolean indicating if token is removed
       
   162 		* @return True, if token removed, false if not
       
   163 		*/
       
   164 		TBool TokenRemoved();
       
   165 
       
   166     protected:  // New functions
       
   167         
       
   168         /**
       
   169         * Returns a reference to a variable to be used as a reference counter
       
   170         * @return  A reference to reference counter
       
   171         */
       
   172         TInt& ReferenceCount();
       
   173 
       
   174 	private: // Constructors
       
   175     
       
   176         /**
       
   177         * Default constructor.
       
   178         * @param aWimSecModule (IN) Current security module
       
   179         * @param aTokenType (IN) Created token's token type
       
   180         */
       
   181         CWimToken( CWimSecModule* aWimSecModule, 
       
   182 				   MCTTokenType& aTokenType );
       
   183 
       
   184         void ConstructL();
       
   185 
       
   186 	private: // Own function
       
   187 
       
   188         /**
       
   189         * Returns as a parameter a reference to pointer of an interface object.
       
   190         * @param  aRequiredInterface (IN) The UID of the interface that 
       
   191 		*		  should be returned
       
   192 		* @param  aReturnedInterface (OUT). This will be set to a pointer to 
       
   193 		*		  the returned interface on success and
       
   194 		*		  to NULL if it isn't supported by this token
       
   195         * @param  aStatus (IN/OUT) Async. request status.
       
   196 		*		  KErrNone, if all ok and interface returned
       
   197         *         KErrHardwareNotAvailable, if Wim card suddenly removed
       
   198         *         Any other system wide error code (e.g. KErrNoMemory)
       
   199 		* @return void
       
   200         */
       
   201         void MakeInterfaceL( TUid aRequiredInterface,
       
   202                              MCTTokenInterface*& aReturnedInterface );
       
   203     private:    
       
   204 		
       
   205 		// A pointer to current security module.
       
   206 		// This class don't own the pointed object.
       
   207 		CWimSecModule* iWimSecModule;
       
   208 
       
   209 		// Reference to the token type of this token. 
       
   210 		// This class don't own the referenced object.
       
   211 		MCTTokenType& iTokenType;
       
   212 
       
   213 		// A pointer to label buffer that contains the name of this token.
       
   214 		// This class owns the pointed object.
       
   215 		HBufC* iLabel;
       
   216 
       
   217 		// A variable needed for reference counting
       
   218 		TInt iCount;
       
   219 
       
   220 		// Used in token notify on removal
       
   221 		CWimTokenListener* iWimTokenListener;
       
   222 
       
   223   		// A pointer to certificate store
       
   224 		// Ownership of pointed object is transferred to caller
       
   225 		MCTCertStore* iCertStoreIf;
       
   226 
       
   227 		// A pointer to writable certificate
       
   228 		// Ownership of pointed object is transferred to caller
       
   229 		MCTWritableCertStore* iCertStoreWritableIf;
       
   230 
       
   231 		// A pointer to Wim key store
       
   232 		// Ownership of pointed object is transferred to caller
       
   233 		MCTKeyStore* iKeyStoreIf;
       
   234 
       
   235 		// A pointer to Wim authentication object list
       
   236 		// Ownership of pointed object is transferred to caller
       
   237 		MCTAuthenticationObjectList* iAuthObjectListIf;
       
   238 
       
   239     };
       
   240 
       
   241         /**
       
   242         * Helper class to filter token types
       
   243         */
       
   244 
       
   245 class TCurrentTokenType : public MCTTokenTypeFilter
       
   246     {
       
   247 
       
   248     public: // From base class MCTTokenTypeFilter
       
   249     
       
   250         /**
       
   251         * Sets value to given token type info.
       
   252         * @param  aTokenType  (IN) Info class for token type
       
   253         * @return ETrue if current token type is same as given token type
       
   254         *         EFalse, if not
       
   255         */
       
   256         virtual TBool Accept( const CCTTokenTypeInfo& aTokenType ) const;
       
   257 
       
   258     };
       
   259 
       
   260 
       
   261 #endif      // CWIMTOKEN_H   
       
   262             
       
   263 // End of File