webservices/wsidentitymanager/inc/senbaseidentitymanager.h
changeset 0 62f9d29f7211
child 7 7bc6ab9b5bcd
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef SEN_BASE_IDENTITY_MANAGER_H
       
    26 #define SEN_BASE_IDENTITY_MANAGER_H
       
    27 
       
    28 // INCLUDES
       
    29 #include <e32std.h>
       
    30 #include <ecom.h>
       
    31 #include <flogger.h>    // RFileLogger
       
    32 #include <badesca.h>    // CDesC8Array
       
    33 
       
    34 #include <SenIdentityProvider.h>
       
    35 #include <SenBaseFragment.h>
       
    36 
       
    37 #include "senbaseidentity.h"
       
    38 #include "msenidentitymanager.h" 
       
    39 
       
    40 
       
    41 
       
    42 
       
    43 // CONSTANTS
       
    44 #ifndef RD_SEN_COMPILE_SIS_PACKAGE_FILES
       
    45 const TUid KUidSechMech = {0x101F96FC};
       
    46 #else
       
    47 const TUid KUidSechMech = {0x101F9733};
       
    48 #endif
       
    49 // FORWARD DECLARATIONS
       
    50 class CSenSenSecurityMechanismObserver;
       
    51 class MSenCoreServiceManager;
       
    52 
       
    53 // CLASS DECLARATION
       
    54 class CSenBaseIdentityManager : public CSenBaseFragment,
       
    55                                 public MSenIdentityManager
       
    56     {
       
    57     public: // Constructors and destructor
       
    58     
       
    59         /**
       
    60         * Two-phased constructor.
       
    61         */
       
    62         IMPORT_C static CSenBaseIdentityManager* NewL(
       
    63                                             MSenCoreServiceManager& aManager);
       
    64         IMPORT_C static CSenBaseIdentityManager* NewLC(
       
    65                                             MSenCoreServiceManager& aManager);
       
    66 
       
    67         IMPORT_C virtual ~CSenBaseIdentityManager();
       
    68         
       
    69         // New functions
       
    70         
       
    71         void ReloadSenSecurityMechanismsL();
       
    72 
       
    73         // Functions from base classes
       
    74         
       
    75         // from MSenIdentityManager
       
    76         TPtrC8 SenSecurityMechanismNames8L();
       
    77         CSenSecurityMechanism* MechanismNamedL(const TDesC8& aName);
       
    78 
       
    79         /**
       
    80         * Initialize this SenBaseIdentityManager by parsing
       
    81         * the given file with the given XMLReader.
       
    82         * The file is expected to contain valid XML that
       
    83         * follows the example given above.
       
    84         * @param file
       
    85         * @param reader
       
    86         */
       
    87         void LoadFromL(TDesC& aFile, CSenXmlReader& aReader);
       
    88 
       
    89 
       
    90         /**
       
    91         * Save the current state of the SenBaseIdentityManager as an XML
       
    92         * document into a file.
       
    93         * Statuscodes:
       
    94         *   KErrNone                Ok
       
    95         *  Other codes are system error codes.
       
    96         * @return status code.
       
    97         */
       
    98         IMPORT_C TInt WriteDatabase();
       
    99 
       
   100         /**
       
   101         * Creates the element. Overrides CSenBaseFragment
       
   102         * StartElementL-function
       
   103         * @param aNsUri name space URI
       
   104         * @param aLocalName local name
       
   105         * @param aQName cue name
       
   106         * @param apAttrs XML attributes
       
   107         */
       
   108         virtual void StartElementL( const TDesC8& aNsUri,
       
   109                                     const TDesC8& aLocalName,
       
   110                                     const TDesC8& aQName,
       
   111                                     const RAttributeArray& aAttributes);
       
   112 
       
   113         /**
       
   114         * Implements MSenIdentityManager
       
   115         * @return the currently active default identity.
       
   116         */
       
   117         virtual MSenIdentity& IdentityL();
       
   118 
       
   119         /**
       
   120         * Implements MSenIdentityManager
       
   121         * @param On the return, contains the (System) userName of the
       
   122         *        currently active user.
       
   123         * @return KErrNone if no error, or some of the system wide error codes
       
   124         */
       
   125         virtual TInt UserNameL(HBufC8*& aUserName);
       
   126 
       
   127         /**
       
   128         * Implements MSenIdentityManager
       
   129         * @return the default IdentityProvider of the currently active
       
   130         *         Identity.
       
   131         */
       
   132         virtual CSenIdentityProvider* IdentityProviderL();
       
   133 
       
   134         /**
       
   135         * Implements MSenIdentityManager
       
   136         * @param aServiceDescription
       
   137         * @return the IdentityProvider of the currently active Identity.
       
   138         */
       
   139         virtual CSenIdentityProvider* IdentityProviderL(
       
   140                                 MSenServiceDescription& aServiceDescription );
       
   141 
       
   142         /**
       
   143         * Implements MSenIdentityManager
       
   144         * @param aURI
       
   145         * @return the IdentityProvider of the currently active Identity.
       
   146         */
       
   147         virtual CSenIdentityProvider* IdentityProviderL(const TDesC8& aURI );
       
   148 
       
   149         /**
       
   150         * Implements MSenIdentityManager
       
   151         * @param aIdpList an array of ProviderIDs
       
   152         * @param aStrict if set to true only an IdentityProvider from the List
       
   153         * will be returned, and null if none of the list entries is known to
       
   154         * the current active Identity.
       
   155         * @return the currently preferred IdentityProvider.
       
   156         */
       
   157         virtual CSenIdentityProvider* IdentityProviderL(
       
   158                                 const CDesC8Array& aIdpList, TBool aStrict);
       
   159 
       
   160         /**
       
   161         * Implements MSenIdentityManager
       
   162         * @param aServiceDescription
       
   163         * @param aIdpList an array of ProviderIDs
       
   164         * @param aStrict if set to true only an IdentityProvider from the List
       
   165         * will be returned, and null if none of the list entries is known to
       
   166         * the current active Identity.
       
   167         * @return the currently preferred IdentityProvider.
       
   168         */
       
   169         virtual CSenIdentityProvider* IdentityProviderL(
       
   170                                 MSenServiceDescription& aServiceDescription,
       
   171                                 const CDesC8Array& aIdpList,
       
   172                                 TBool aStrict);
       
   173 
       
   174         /**
       
   175         * Checks if there already is an identity provider with given data.
       
   176         * Existing identity provider can still have more data than the pattern.
       
   177         * @param    aContains   will contain the boolean value on return. ETrue if
       
   178         *           contains, EFalse otherwise.
       
   179         * @param    aIDP    the pattern identity provider.
       
   180         * @return KErrNone or system-wide error code.
       
   181         */
       
   182         virtual TInt ContainsIdentityProviderL(
       
   183                                        TBool& aContains,
       
   184                                        CSenIdentityProvider& aIDP);
       
   185 
       
   186         /**
       
   187         * Implements MSenIdentityManager
       
   188         * Ownerships is transferred
       
   189         * @param aIdp a registered IdentityProvider
       
   190         * @return KErrNone if successful.
       
   191         */
       
   192         virtual TInt RegisterIdentityProviderL(CSenIdentityProvider* apIdp );
       
   193 
       
   194         /**
       
   195         * Implements MSenIdentityManager
       
   196         * @param aIdp an unregistered IdentityProvider
       
   197         * @return KErrNone if successful.
       
   198         *         KErrNotFound if IdentityProvider was not found.
       
   199         *         Other return values are symbian system-wide error codes.
       
   200         */
       
   201         virtual TInt UnregisterIdentityProviderL(CSenIdentityProvider& aIdp );
       
   202 
       
   203         /**
       
   204         * Implements MSenIdentityManager
       
   205         * @param aServiceID the contract or endpoint of a service
       
   206         * @param aProviderID the id of an IdentityProvider
       
   207         * @return true if successful. Failure may be caused by non-existence
       
   208         * of the IdentityProvider for the current user.
       
   209         */
       
   210         virtual TBool AssociateServiceL(const TDesC8& aServiceID,
       
   211                                         const TDesC8& aProviderID );
       
   212 
       
   213         /**
       
   214         * Implements MSenIdentityManager
       
   215         * @param aServiceID the contract or endpoint of a service
       
   216         * @param aProviderID the id of an IdentityProvider
       
   217         * @return true if successful. Failure may be caused by non-existence
       
   218         * of the IdentityProvider for the current user.
       
   219         */
       
   220         virtual TBool DissociateServiceL(const TDesC8& aServiceID,
       
   221                                          const TDesC8& aProviderID );
       
   222 
       
   223         /**
       
   224         * Implements MSenIdentityManager
       
   225         * Status codes:
       
   226         *   KErrNone                        ok
       
   227         *   KErrNotFound                    no identities
       
   228         *   Other codes are system error codes
       
   229         * @param aIdentitiesList an array where the identities can be inserted
       
   230         * @return status/error code.
       
   231         */
       
   232         virtual TInt IdentitiesL( CDesC8Array& aIdentitiesList );
       
   233 
       
   234         /**
       
   235         * NOTE! This code does not do as documentation states.
       
   236         * Only second line text is shown and
       
   237         * "Ok" button on the left side.
       
   238         * @return the value of button pressed (OK or CANCEL)
       
   239         */
       
   240         virtual TInt YesNoQueryL(const TDesC& aLine1,
       
   241                                  const TDesC& aLine2,
       
   242                                  const TDesC& aButton1,
       
   243                                  const TDesC& aButton2);
       
   244 
       
   245         virtual TInt AuthenticationForL(CSenIdentityProvider& aAccount, TPckgBuf<TSenAuthentication>& aResponse);
       
   246 
       
   247         /**
       
   248         * For encoding and decoding base 64:
       
   249         */
       
   250         virtual HBufC8* EncodeToBase64LC(const TDesC8& aSource);
       
   251         virtual HBufC8* DecodeFromBase64LC(const TDesC8& aSource);
       
   252         
       
   253         virtual TInt FindMatchingIdentityProviderL(CSenIdentityProvider &aIdp,
       
   254                                                    CSenIdentityProvider*& apMatch);
       
   255         
       
   256         virtual TInt UpdateIdentityProviderL(CSenIdentityProvider& aIdp);
       
   257 
       
   258         /**
       
   259         * "Enables/disables" -flag which determines if UI interaction with end-user is allowed or not
       
   260         */
       
   261         virtual void SetShowPasswordDialog(const TBool aState);
       
   262 
       
   263         RFileLogger* Log();
       
   264         /** Improved heuristics from Identity DB removal / cleanups
       
   265 		*
       
   266 		* It finds the matching IdentityProvider child elements of current Identity 
       
   267 		* element using the service description and add the touch attribute to all 
       
   268 		* matched IdentityProvider elements with current tick count value.
       
   269 		* If touch attribute already there it will be replaced with new current 
       
   270 		* tick count value.
       
   271 		*
       
   272 		* @param asd     is the new established session service description.
       
   273 		* Leave codes: Symbian system-wide error codes.  
       
   274 		*/
       
   275         IMPORT_C void UpdateTouchIdentityDBL(MSenServiceDescription& asd);
       
   276         
       
   277         
       
   278         /**
       
   279         * Implements MSenIdentityManager
       
   280         * @return the default IdentityProvider of the currently active
       
   281         *         Identity.
       
   282         */
       
   283         const virtual RPointerArray<CSenIdentityProvider>& IdentityProvidersL();
       
   284 
       
   285     protected: 
       
   286     
       
   287         /**
       
   288         * C++ default constructor.
       
   289         */
       
   290         CSenBaseIdentityManager(MSenCoreServiceManager& aManager);
       
   291         
       
   292         /**
       
   293         * By default Symbian 2nd phase constructor is private.
       
   294         */
       
   295         void ConstructL();
       
   296     
       
   297         // New functions
       
   298         
       
   299         /**
       
   300         * Save the current state of the SenBaseIdentityManager as an XML
       
   301         * document into a file.
       
   302         * Status codes:
       
   303         *   KErrNone                Ok
       
   304         *   Other codes are system error codes.
       
   305         * @return status code.
       
   306         */
       
   307         virtual TInt WriteConfigurationToL( const TDesC& aFile );
       
   308         TBool AllowSavePasswordL();
       
   309         /** Improved heuristics from Identity DB removal / cleanups : Naga
       
   310 	    *
       
   311 	    * Checks touch attribute value for all IdentityProvider child elements of 
       
   312 	    * current Identity element if that exceeds the the tick counts for two weeks 
       
   313 	    * (Max tick count) or if it is greater than current tick count value it removes 
       
   314 	    * the corresponding IdentityProvider child element from the Identity element 
       
   315 	    * child list.    
       
   316 	    * 
       
   317 	    * 1 millisec = 1 tick
       
   318 		* 86400 sec = 1 day
       
   319 		* 86400*1000 millisec = 1 day
       
   320 		* 86400*14*1000 = 1209600000 millisec = 2 weeks
       
   321 		* So if attr val >= 1209600000 or > current tick count.
       
   322 		* Note: always attr val should be <= current tick count.
       
   323 		*
       
   324 	    * eg;
       
   325 	    * Before call to CleanupUnusedIdentityDBL()
       
   326 	    * <Users>
       
   327 		* <User>
       
   328 		* <Identity>
       
   329 		* <IdentityProvider>
       
   330   		* <Endpoint>http://10.21.32.20/WSStar/CredMan/STS.aspx</Endpoint> 
       
   331   		* .........
       
   332   		* ..........
       
   333   		* </IdentityProvider>
       
   334 		* <IdentityProvider touch="1000">
       
   335   		* <Endpoint>http://10.21.32.20/WSStar/CredMan/STS_001.aspx</Endpoint> 
       
   336   		* ..........
       
   337   		* ..........
       
   338   		* </IdentityProvider>
       
   339   		* <IdentityProvider touch="1309600000">
       
   340   		* <Endpoint>http://10.21.32.20/WSStar/CredMan/Webservises.aspx</Endpoint> 
       
   341   		* ..........
       
   342   		* ............
       
   343   		* </IdentityProvider>
       
   344 		* </Identity>
       
   345   		* </User>
       
   346   		* </Users>
       
   347 		* 
       
   348 		* After call to CleanupUnusedIdentityDBL()
       
   349 	    * <Users>
       
   350 		* <User>
       
   351 		* <Identity>
       
   352 		* <IdentityProvider>
       
   353   		* <Endpoint>http://10.21.32.20/WSStar/CredMan/STS.aspx</Endpoint> 
       
   354   		* .........
       
   355   		* ..........
       
   356   		* </IdentityProvider>
       
   357 		* <IdentityProvider touch="1000">
       
   358   		* <Endpoint>http://10.21.32.20/WSStar/CredMan/STS_001.aspx</Endpoint> 
       
   359   		* ..........
       
   360   		* ..........
       
   361   		* </IdentityProvider>
       
   362   		* </Identity>
       
   363   		* </User>
       
   364   		* </Users>
       
   365   		* 
       
   366 		* Leave codes: Symbian system-wide error codes.
       
   367 	    */
       
   368         void CleanupUnusedIdentityDBL();
       
   369 
       
   370     protected: // Data
       
   371         CSenBaseIdentity* iIdentity;
       
   372         CSenIdentityProvider* iProvider;
       
   373         MSenCoreServiceManager& iManager;
       
   374         TBool iConfigReadonly;
       
   375         RFileLogger* iLog;   // not owned (no create/close)
       
   376         CSenSenSecurityMechanismObserver* iObserver;
       
   377         CBufFlat* ipMechanicsNames;
       
   378         HBufC8* ipDeviceID;     // Owned
       
   379         RImplInfoPtrArray       iEcomInfoArray;
       
   380         RPointerArray<HBufC8>   iSechMechNames;
       
   381         RPointerArray<HBufC8>   iSechMechCues;
       
   382         TBool iShowPasswordDialog;
       
   383     };
       
   384 
       
   385 #endif // SEN_BASE_IDENTITY_MANAGER_H
       
   386 
       
   387 // End of File