1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
12 // |
12 // |
13 // Description: |
13 // Description: |
14 // Secure Sockets |
14 // Secure Sockets |
15 // |
15 // |
16 // |
16 // |
17 |
|
18 |
|
19 |
17 |
20 /** |
18 /** |
21 @file |
19 @file |
22 */ |
20 */ |
23 |
21 |
32 |
30 |
33 #include <sslerr.h> |
31 #include <sslerr.h> |
34 #include <x509cert.h> |
32 #include <x509cert.h> |
35 |
33 |
36 #include <securesocketinterface.h> |
34 #include <securesocketinterface.h> |
37 //Secure Socket specific panic |
35 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
38 _LIT(KSecureSocketPanic,"SecureSocket Panic"); |
36 #include <securesocket_internal.h> |
39 |
37 #endif |
40 /** |
|
41 * Maximum length of the protocol name. |
|
42 * |
|
43 * @internalComponent |
|
44 */ |
|
45 const TInt KMaxProtocolName = 32; |
|
46 |
|
47 class TSecSocketProtocol |
|
48 /** |
|
49 * The secure socket protocol class. |
|
50 * |
|
51 * @internalComponent |
|
52 * |
|
53 * @since v7.0 |
|
54 */ |
|
55 { |
|
56 public: |
|
57 /** Protocol name. */ |
|
58 TBuf<KMaxProtocolName> iName; |
|
59 /** Handle to the DLL. */ |
|
60 RLibrary iLibrary; |
|
61 static inline TInt Offset() |
|
62 /** |
|
63 * Gets the offset to the iSlink member. |
|
64 * |
|
65 * @return The offset to the iSlink member. */ |
|
66 {return _FOFF(TSecSocketProtocol,iSlink);} |
|
67 // Moved the implementation to the cpp file |
|
68 virtual ~TSecSocketProtocol(); |
|
69 private: |
|
70 TSglQueLink iSlink; |
|
71 }; |
|
72 |
|
73 |
|
74 class TSecureSocketGlobals |
|
75 /** |
|
76 * Class to store the Secure Sockets Globals. |
|
77 * |
|
78 * @internalComponent |
|
79 * |
|
80 * @since v7.0 |
|
81 */ |
|
82 { |
|
83 public: |
|
84 inline TSecureSocketGlobals(): |
|
85 iSecureSocketProtocols(TSecSocketProtocol::Offset()), |
|
86 /** Constructor. */ |
|
87 iSecureSocketProtocolsIter(iSecureSocketProtocols), |
|
88 iUseCount(0){}; |
|
89 /** List of supported protocols. */ |
|
90 TSglQue<TSecSocketProtocol> iSecureSocketProtocols; |
|
91 /** A templated class that provides for iterating through the list of supported |
|
92 * protocols. */ |
|
93 TSglQueIter<TSecSocketProtocol> iSecureSocketProtocolsIter; |
|
94 /** Use counter. */ |
|
95 TInt iUseCount; |
|
96 }; |
|
97 |
38 |
98 class MGenericSecureSocket; |
39 class MGenericSecureSocket; |
99 |
|
100 /** |
|
101 * Definition for the entry point function exported by Secure Socket modules. |
|
102 * |
|
103 * @internalComponent |
|
104 */ |
|
105 typedef TInt (*TSecSockDllLibraryFunction)( RSocket& aSocket, const TDesC& aProtocol ); |
|
106 typedef TInt (*TSecSockDllLibraryGenericFunction)(MGenericSecureSocket& aSocket, const TDesC& aProtocol); |
|
107 |
|
108 /** |
|
109 * Definition for the entry point for the cleanup function exported by secureSocket modules |
|
110 * |
|
111 * @internalComponent |
|
112 */ |
|
113 typedef void (*TSecSockDllUnloadFunction)( TAny* ); |
|
114 |
|
115 class CSecureSocketLibraryLoader : public CBase |
|
116 /** |
|
117 * Factory class for creating secure sockets. |
|
118 * |
|
119 * @internalAll |
|
120 * |
|
121 * @since v6.2 */ |
|
122 // Create and reference Secure Sockets |
|
123 { |
|
124 public: |
|
125 static TInt OpenL(const TDesC& aProtocolName,TSecSockDllLibraryFunction& anEntryPoint); |
|
126 static TInt OpenL(const TDesC& aProtocolName, TSecSockDllLibraryGenericFunction& aEntryPoint); |
|
127 static void FindItemInDbL(const TDesC& aProtocolName, TDes& aLibraryName); |
|
128 IMPORT_C static void Unload(); |
|
129 |
|
130 private: |
|
131 static void OpenWithIdL(TInt aId, const TDesC& aProtocolName, TLibraryFunction& aEntryPoint); |
|
132 }; |
|
133 |
|
134 |
40 |
135 class CSecureSocket : public CBase |
41 class CSecureSocket : public CBase |
136 /** |
42 /** |
137 * Secure sockets class. |
43 * Secure sockets class. |
138 * |
44 * |
139 * @publishedAll |
45 * @publishedAll |
140 * @released |
46 * @released |
141 * |
47 * |
142 * @since v6.2 */ |
48 * @since v6.2 */ |
143 // New secure sockets can be created through the static CSecureSocket::NewL method. |
49 // New secure sockets can be created through the static CSecureSocket::NewL method. |
144 // @public |
|
145 { |
50 { |
146 public: |
51 public: |
147 IMPORT_C static CSecureSocket* NewL(RSocket& aSocket,const TDesC& aProtocol); |
52 IMPORT_C static CSecureSocket* NewL(RSocket& aSocket,const TDesC& aProtocol); |
148 IMPORT_C static CSecureSocket* NewL(MGenericSecureSocket& aSocket,const TDesC& aProtocol); |
53 IMPORT_C static CSecureSocket* NewL(MGenericSecureSocket& aSocket,const TDesC& aProtocol); |
149 |
54 |