webservices/wsframework/src/saslmechanism.cpp
changeset 0 62f9d29f7211
child 17 48e9d43c1d7f
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:        
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 // INCLUDE FILES
       
    26 #include "saslmechanism.h" 
       
    27 
       
    28 #include <SenIdentityProvider.h>
       
    29 
       
    30 EXPORT_C CSaslMechanism* CSaslMechanism::NewL()
       
    31     {
       
    32     CSaslMechanism* pNew = NewLC();
       
    33     CleanupStack::Pop();
       
    34     return pNew;
       
    35     }
       
    36 
       
    37 EXPORT_C CSaslMechanism* CSaslMechanism::NewLC()
       
    38     {
       
    39     CSaslMechanism* pNew = new (ELeave) CSaslMechanism();
       
    40     CleanupStack::PushL(pNew);
       
    41     return pNew;
       
    42     }
       
    43 
       
    44 EXPORT_C CSaslMechanism::CSaslMechanism()
       
    45 :   ipAccount(NULL),
       
    46     ipIdentityManager(NULL)
       
    47     {
       
    48     }
       
    49 
       
    50 EXPORT_C CSaslMechanism::~CSaslMechanism()
       
    51     {
       
    52     iTransforms.ResetAndDestroy(); // were owned
       
    53     }
       
    54 
       
    55 EXPORT_C void CSaslMechanism::ClearPasswordL()
       
    56     {
       
    57     //subclasses should implement this.
       
    58     }
       
    59 
       
    60 EXPORT_C HBufC8* CSaslMechanism::Password8L()
       
    61     {
       
    62 	HBufC8* pPassWd = NULL;
       
    63 	TSenAuthentication output;
       
    64 	TPckgBuf<TSenAuthentication> outputPair(output);
       
    65 	if(ipAccount)
       
    66 		{
       
    67 	    TInt error = ipIdentityManager->AuthenticationForL(*ipAccount, outputPair);
       
    68 	    if (error == KErrNone)
       
    69 		    {
       
    70 		    pPassWd = outputPair().iPassword.AllocL();
       
    71 		    }
       
    72 		}
       
    73     return pPassWd;
       
    74     }
       
    75 
       
    76 EXPORT_C void CSaslMechanism::InitFrom(CSaslMechanism aSaslMechanism)
       
    77     {
       
    78     ipIdentityManager = aSaslMechanism.ipIdentityManager;
       
    79     ipAccount = aSaslMechanism.ipAccount;
       
    80     iTransforms = aSaslMechanism.iTransforms;
       
    81     }
       
    82 
       
    83 EXPORT_C HBufC8* CSaslMechanism::TransformL(TPtrC8 aPassphrase) const
       
    84     {
       
    85     HBufC8* pPassword = aPassphrase.AllocL();
       
    86     HBufC8* pTransformed = NULL;
       
    87     for(TInt i=0; i<iTransforms.Count(); i++)
       
    88         {
       
    89         if(pPassword)
       
    90             {
       
    91             CleanupStack::PushL(pPassword);
       
    92             pTransformed = iTransforms[i]->TransformL(*pPassword);
       
    93             CleanupStack::PopAndDestroy(); // pPassword
       
    94             pPassword = pTransformed;
       
    95             pTransformed = NULL;
       
    96             }
       
    97         }
       
    98     return pPassword;
       
    99     }
       
   100 
       
   101 EXPORT_C TInt CSaslMechanism::MaxAttempts()
       
   102     {
       
   103     return 0; // 0 means that the system default can be applied
       
   104     }
       
   105 
       
   106 EXPORT_C void CSaslMechanism::SetIdentity(
       
   107                                       CSenIdentityProvider* aIdentityProvider,
       
   108                                       MSenIdentityManager* aIdentityManager)
       
   109     {
       
   110     ipIdentityManager = aIdentityManager;
       
   111     ipAccount = aIdentityProvider;
       
   112     }
       
   113 
       
   114 EXPORT_C TBool CSaslMechanism::IsPasswordFromUser()
       
   115     {
       
   116     return EFalse;
       
   117     }
       
   118 
       
   119 EXPORT_C CSenIdentityProvider& CSaslMechanism::Account()
       
   120     {
       
   121     return *ipAccount;
       
   122     }
       
   123 
       
   124 EXPORT_C void CSaslMechanism::SetTransforms(
       
   125                         RPointerArray<CSenPasswordTransform> aList)
       
   126     {
       
   127     iTransforms = aList;
       
   128     }
       
   129 
       
   130 // End of File