|
1 /* |
|
2 * Copyright (c) 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 #include "cstunclientready.h" |
|
22 #include "cstunclientimplementation.h" |
|
23 |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CSTUNClientReady::CSTUNClientReady |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CSTUNClientReady::CSTUNClientReady( |
|
32 const CSTUNClientState& aRenewSharedSecret ) : |
|
33 iRenewSharedSecret( aRenewSharedSecret ) |
|
34 { |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CSTUNClientReady::CSTUNClientReady |
|
39 // Dummy implementation. Default constructor is declared private and not used. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CSTUNClientReady::CSTUNClientReady() : |
|
43 iRenewSharedSecret( *( CSTUNClientState* )0x1 ) |
|
44 { |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CSTUNClientReady::CSTUNClientReady |
|
49 // Dummy implementation, as copy constructor is declared private and not used. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CSTUNClientReady::CSTUNClientReady( const CSTUNClientReady& aReady ) : |
|
53 CSTUNClientState(), |
|
54 iRenewSharedSecret( aReady.iRenewSharedSecret ) |
|
55 { |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CSTUNClientReady::~CSTUNClientReady |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CSTUNClientReady::~CSTUNClientReady() |
|
63 { |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CSTUNClientReady::ObtainSharedSecretL |
|
68 // Username and password are available. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void |
|
72 CSTUNClientReady::ObtainSharedSecretL( CSTUNClientImplementation& aContext, |
|
73 CBinding& aBinding ) const |
|
74 { |
|
75 aContext.PassSharedSecretToBindingL( aBinding ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CSTUNClientReady::SharedSecretRejectedL |
|
80 // If the current shared secret was rejected, get a new one. |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 TBool |
|
84 CSTUNClientReady::SharedSecretRejectedL( CSTUNClientImplementation& aContext, |
|
85 const CBinding& aBinding, |
|
86 const TDesC8& aUsername, |
|
87 const TDesC8& aPassword ) const |
|
88 { |
|
89 if ( aContext.DoesSharedSecretMatch( aUsername, aPassword ) ) |
|
90 { |
|
91 if ( aContext.HasPresetCredentials() ) |
|
92 { |
|
93 aContext.PassCredentialsRejectedL( aBinding ); |
|
94 |
|
95 //TODO: should the preset credentials be cleared, as they've been |
|
96 //rejected? |
|
97 return EFalse; |
|
98 } |
|
99 else |
|
100 { |
|
101 aContext.GetSharedSecretFromServerL(); |
|
102 aContext.ChangeState( &iRenewSharedSecret ); |
|
103 } |
|
104 } |
|
105 return ETrue; |
|
106 } |