os/security/cryptomgmtlibs/cryptotokenfw/inc_interfaces/MCTAuthObject.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2001-2009 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 the License "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: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @publishedPartner
    22  @released
    23 */
    24 
    25 #ifndef __MCTAOSTORE_H__
    26 #define __MCTAOSTORE_H__
    27 
    28 #include <ct.h>
    29 
    30 /** The UID for the authentication object interface. */
    31 const TInt KCTInterfaceAuthenticationObject = 0x101F51AE;
    32 
    33 /**
    34  * A timeout value for an auth object indicating that it stays open until
    35  * explicity closed.
    36  */
    37 const TInt KTimeoutNever = -1;
    38 
    39 /**
    40  * A timeout value for an auth object indicating that the authentication data
    41  * must be entered every time the protected objects are used.
    42  */
    43 const TInt KTimeoutImmediate = 0;
    44 
    45 /**
    46  * The status of an authentication object.
    47  */
    48 enum TCTAuthenticationStatus
    49 	{
    50 	/** The authentication object is enabled. If it is not enabled, the objects protected 
    51 	* by this authentication object can be accessed without authentication. */
    52 	EEnabled		= 0x80,
    53 	/** The reference data cannot be changed. */
    54 	EChangeDisabled	= 0x40,
    55 	/** The authentication cannot be unblocked. */
    56 	EUnblockDisabled	= 0x20,
    57 	/** The authentication object can be disabled. */
    58 	EDisableAllowed	= 0x10,
    59 	/** The authentication object is blocked, meaning that the
    60 	* unblocking PIN must be entered to re-enable the authentication object. */
    61 	EAuthObjectBlocked= 0x08,
    62 	};	
    63 
    64 /** 
    65  * This class allows authentication objects to be queried and manipulated.
    66  * 
    67  * Authentication objects are obtained from the MCTAuthenticationObjectList class, 
    68  * which is the class returned as the token interface. 
    69  */
    70 class MCTAuthenticationObject: public MCTTokenObject
    71 	{
    72 public:
    73 	/** Constructor */
    74 	inline MCTAuthenticationObject(MCTToken& aToken);
    75 
    76 	// Listing Protected Objects
    77 	/** 
    78 	 * Gets a list of all the objects that this authentication object protects.
    79 	 * 
    80 	 * @param aObjects	The returned objects will be appended to this array.
    81 	 * @param aStatus	Completed with the return code when the operation completes. 
    82 	 */
    83 	virtual void ListProtectedObjects(RMPointerArray<MCTTokenObject>& aObjects, TRequestStatus& aStatus) = 0;
    84 
    85 	/** Cancels an asynchronous ListProtectedObjects() operation. */
    86 	virtual void CancelListProtectedObjects() = 0;
    87 	
    88 	// Changing the reference data
    89 	/** 
    90 	 * Changes the reference data (e.g. PIN value).
    91 	 * 
    92 	 * The security dialog component will prompt for the old and new reference data.
    93 	 *
    94 	 * The authentication object may not allow its reference data to be changed -
    95 	 * this is indicated by the EChangeDisabled bit of Status() being set.
    96 	 * 
    97 	 * @param aStatus	Completed with the return code when the operation completes.
    98 	 *
    99 	 * @leave KErrNotFound If no reference data was originally set.
   100 	 */
   101 	virtual void ChangeReferenceData(TRequestStatus &aStatus) = 0;
   102 
   103 	/** Cancels an asynchronous ChangeReferenceData() operation. */
   104 	virtual void CancelChangeReferenceData() = 0;
   105 	
   106 	/** 
   107 	 * Unblocks the authentication object.
   108 	 * 
   109 	 * The security dialog component will prompt for the unblocking
   110 	 * authentication object.
   111 	 *
   112 	 * It is only valid to call this method when the authentication object is
   113 	 * blocked, ie when the EAuthObjectBlocked bit of Status() is set.
   114 	 * 
   115 	 * The object may not allow unblocking (either because of failed unblock
   116 	 * attempts or because it doesn't support the concept) - this is indicated by
   117 	 * the EUnblockDisabled bit of Status() being set.
   118 	 * 
   119 	 * @param aStatus	Completed with the return code when the operation completes. 
   120 	 */
   121 	virtual void Unblock(TRequestStatus &aStatus) = 0;
   122 
   123 	/** Cancels an asynchronous Unblock() operation. */
   124 	virtual void CancelUnblock() = 0;
   125 	
   126 	/** 
   127 	 * Gets the status of the authentication object.
   128 	 * 
   129 	 * @return	See TCTAuthenticationStatus() for the format of the return value. 
   130 	 */
   131 	virtual TUint32 Status() const = 0;
   132 
   133 	// Enabling and Disabling
   134 	/** 
   135 	 * Disables the authentication object.
   136 	 *
   137 	 *  It is only valid to call this method if the object is enabled, indicated
   138 	 *  by the EEnabled bit of Status() being set.
   139 	 *
   140 	 *  Also, the authentication object may not support being enabled/disabled -
   141 	 *  the EDisableAllowed bit of Status() must be set for this to work.
   142 	 *  
   143 	 * @param aStatus	Completed with the return code when the operation completes. 
   144 	 */
   145 	virtual void Disable(TRequestStatus &aStatus) = 0;
   146 
   147 	/** Cancels an asynchronous Disable() operation. */
   148 	virtual void CancelDisable() = 0;
   149 
   150 	/** 
   151 	 * Enables the authentication object.
   152 	 *
   153 	 *  It is only valid to call this method if the object is disabled, indicated
   154 	 *  by the EEnabled bit of Status() being clear.
   155 	 *
   156 	 *  Also, the authentication object may not support being enabled/disabled -
   157 	 *  the EDisableAllowed bit of Status() must be set for this to work.
   158 	 *  
   159 	 * @param aStatus	Completed with the return code when the operation completes. 
   160 	 */
   161 	virtual void Enable(TRequestStatus &aStatus) = 0;
   162 
   163 	// Cancel an ongoing Enable operation
   164 	/** Cancels an asynchronous Enable() operation. */
   165 	virtual void CancelEnable() = 0;
   166 	
   167 	/** 
   168 	 * Opens the authentication object.
   169 	 * 
   170 	 * This means that the protected objects can be accessed without provoking
   171 	 * the authentication mechanism for the duration of the timeout period.
   172 	 * 	
   173 	 * Note that it is not strictly necessary to call this function, as the
   174 	 * authentication object will be opened when any operation that needs it to
   175 	 * be opened is called, but it is sometimes useful to control the timing of
   176 	 * authentication dialogs. Note also that this function will do nothing if
   177 	 * the authentication object is open, or if the authentication object
   178 	 * requires the authentication data to be entered every time.
   179 	 * 
   180 	 * @param aStatus	Completed with the return code when the operation completes.
   181 	 */
   182 	virtual void Open(TRequestStatus& aStatus) = 0;
   183 
   184 	/** 
   185 	 * Closes an authentication object. 
   186 	 * 
   187 	 * @param aStatus	Completed with the return code when the operation completes.
   188 	 */
   189 	virtual void Close(TRequestStatus& aStatus) = 0;
   190 
   191 	/** 
   192 	 * Gets the amount of time in seconds that the authentication object
   193 	 * will remain open for, or 0 if it is closed.
   194 	 * 
   195 	 * @param aStime		Time in seconds when the operation completes.
   196 	 * @param aStatus	Completed with the return code when the operation completes.
   197 	 */
   198 	virtual void TimeRemaining(TInt& aStime, TRequestStatus& aStatus) = 0;
   199 		
   200 	/** 
   201 	 * Sets the time in seconds for this authentication object. 
   202 	 * 
   203 	 * Permitted values include 0, meaning always ask, and -1,
   204 	 * meaning until it's explicitly closed. Particular authentication
   205 	 * objects might restrict the range of values permitted.
   206 	 * 
   207 	 * @param aTime		Time in seconds
   208 	 * @param aStatus	Completed with the return code when the operation completes
   209 	 *
   210 	 * @leave KErrArgument If the timeout specified is invalid.
   211 	 */
   212 	virtual void SetTimeout(TInt aTime, TRequestStatus& aStatus) = 0;
   213 
   214 	/** 
   215 	 * Gets the current timeout value, in seconds. 
   216 	 * 
   217 	 * For an explanation of the values, see SetTimeout().
   218 	 * 
   219 	 * @param aTime		Time in seconds.
   220 	 * @param aStatus	Completed with the return code when the operation completes.
   221 	 */
   222 	virtual void Timeout(TInt& aTime, TRequestStatus& aStatus) = 0;
   223 		
   224 	/** Cancels an asynchronous Open() operation. */
   225 	virtual void CancelOpen() {};
   226 
   227 	/** Cancels an asynchronous Close() operation. */
   228   	virtual void CancelClose() {};
   229 
   230 	/** Cancels an asynchronous TimeRemaining() operation. */
   231 	virtual void CancelTimeRemaining() {};
   232 	
   233 	/** Cancels an asynchronous SetTimeout() operation. */
   234 	virtual void CancelSetTimeout() {};
   235 
   236 	/** Cancels an asynchronous Timeout() operation. */
   237 	virtual void CancelTimeout() {};
   238 
   239 	};
   240 
   241 /** 
   242  * An interface that enables clients to list all the authentication objects on 
   243  * a token, find out which objects they protect, and change/unblock/enable/disable them.
   244  * 
   245  * It may be used to implement a 'PIN manager' control panel item. This could 
   246  * list the PINs (by label), allow one to be selected, list what it is used for 
   247  * (including information such as what operations on that object are protected 
   248  * by that PIN), and then allow the user to change, enable, disable, and unblock 
   249  * the PIN.
   250  * 
   251  * Note that no PINs appear anywhere in this API. The code implementing this 
   252  * API will display a PIN dialog via the secure dialog interface when a PIN is 
   253  * required. The main advantage of this is that if some hostile code were to 
   254  * capture a PIN, it couldn't do anything with it as none of the APIs take a 
   255  * PIN. A secondary benefit is that the same API can work with biometrics or 
   256  * other methods of authentication. 
   257  */
   258 class MAuthenticationObjectList
   259 	{
   260 public:	
   261 	/** 
   262 	 * Gets a list of all the authenticaiton objects in the token.
   263 	 * 
   264 	 * This is an asynchronous request.
   265 	 * 
   266 	 * @param aAuthObjects	On return, a list of all the authentication objects.
   267 	 * @param aStatus		The request status object; contains the result of the List() request 
   268 	 * 						when complete. Set to KErrCancel if an outstanding request is cancelled. 
   269 	 */
   270 	// @param aAuthObjects	The returned authentication objects will be appended to this array
   271 	// @param aStatus		This will be completed with the final status code
   272 	virtual void List(RMPointerArray<MCTAuthenticationObject>& aAuthObjects,	TRequestStatus& aStatus) = 0;
   273 
   274 	/** 
   275 	 * Cancels an asynchronous List() operation.
   276 	 * 
   277 	 * The operation completes with KErrCancel. 
   278 	 */
   279 	virtual void CancelList() = 0;
   280 	};
   281 
   282 
   283 /**
   284  * The class returned as the token interface.
   285  * 
   286  * The class does not define any extra member functions or data. 
   287  */
   288 class MCTAuthenticationObjectList : public MCTTokenInterface, 
   289 									public MAuthenticationObjectList
   290 	{
   291 	};
   292 
   293 inline MCTAuthenticationObject::MCTAuthenticationObject(MCTToken& aToken)
   294 		: MCTTokenObject(aToken)
   295 	{
   296 	}
   297 
   298 #endif //__MCTAOSTORE_H__