20 #include <e32std.h> |
20 #include <e32std.h> |
21 #include <e32uid.h> |
21 #include <e32uid.h> |
22 #include "clientutils.h" |
22 #include "clientutils.h" |
23 #include "fstokenservername.h" |
23 #include "fstokenservername.h" |
24 |
24 |
|
25 #ifdef SYMBIAN_AUTH_SERVER |
|
26 |
|
27 #ifdef __WINS__ |
|
28 #include <u32hal.h> |
|
29 #endif //__WINS__ |
|
30 |
|
31 #include <e32svr.h> |
|
32 #endif // SYMBIAN_AUTH_SERVER |
25 |
33 |
26 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ |
34 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ |
27 // Tokentype session class for file based certificate store |
35 // Tokentype session class for file based certificate store |
28 // Connects and passes messages to the file store tokentype server |
36 // Connects and passes messages to the file store tokentype server |
29 // Coded specifically for file store token type |
37 // Coded specifically for file store token type |
30 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ |
38 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ |
31 |
39 |
32 _LIT(KFSTokenServerImg,"fstokenserver"); |
40 _LIT(KFSTokenServerImg,"fstokenserver"); |
|
41 #ifdef SYMBIAN_AUTH_SERVER |
|
42 #ifdef __WINS__ |
|
43 _LIT(KFSNewTokenServerImg,"fstokenserver_useauth"); |
|
44 #endif // __WINS__ |
|
45 #endif // SYMBIAN_AUTH_SERVER |
33 |
46 |
34 RFileStoreClientSession::RFileStoreClientSession() |
47 RFileStoreClientSession::RFileStoreClientSession() |
35 {} |
48 {} |
36 |
49 |
37 TInt RFileStoreClientSession::SendRequest(TFSTokenMessages aRequest, const TIpcArgs& aArgs) const |
50 TInt RFileStoreClientSession::SendRequest(TFSTokenMessages aRequest, const TIpcArgs& aArgs) const |
57 |
70 |
58 static TInt StartServer(); // Forward declaration |
71 static TInt StartServer(); // Forward declaration |
59 // |
72 // |
60 // Connect to the server, attempting to start it if necessary |
73 // Connect to the server, attempting to start it if necessary |
61 // |
74 // |
|
75 |
|
76 #ifdef SYMBIAN_AUTH_SERVER |
|
77 #ifdef __WINS__ |
|
78 |
|
79 static bool UseAuthServer(void); |
|
80 |
|
81 #endif // SYMBIAN_AUTH_SERVER |
|
82 #endif // __WINS__ |
|
83 |
62 TInt RFileStoreClientSession::Connect(ETokenEnum aToken) |
84 TInt RFileStoreClientSession::Connect(ETokenEnum aToken) |
63 { |
85 { |
64 // The version is made up of three pieces of information: |
86 // The version is made up of three pieces of information: |
65 // 1. iMajor - The token we want to talk to |
87 // 1. iMajor - The token we want to talk to |
66 // 2. iMinor - The protocol version number |
88 // 2. iMinor - The protocol version number |
68 TVersion version(aToken, KFSProtolVersion, 0); |
90 TVersion version(aToken, KFSProtolVersion, 0); |
69 |
91 |
70 TInt retry=2; |
92 TInt retry=2; |
71 for (;;) |
93 for (;;) |
72 { |
94 { |
73 TInt r=CreateSession(KFSTokenServerName, version, 1); |
95 TInt err = KErrNone; |
74 if (r!=KErrNotFound && r!=KErrServerTerminated) |
96 #ifdef SYMBIAN_AUTH_SERVER |
75 return r; |
97 #ifdef __WINS__ |
|
98 if(UseAuthServer()) |
|
99 { |
|
100 err = CreateSession(KFSNewTokenServerName, version, 1); |
|
101 } |
|
102 else |
|
103 #endif // __WINS__ |
|
104 #endif // SYMBIAN_AUTH_SERVER |
|
105 { |
|
106 err = CreateSession(KFSTokenServerName, version, 1); |
|
107 } |
|
108 |
|
109 if (err!=KErrNotFound && err!=KErrServerTerminated) |
|
110 return err; |
76 if (--retry==0) |
111 if (--retry==0) |
77 return r; |
112 return err; |
78 r=StartServer(); |
113 err=StartServer(); |
79 if (r!=KErrNone && r!=KErrAlreadyExists) |
114 if (err!=KErrNone && err!=KErrAlreadyExists) |
80 return r; |
115 return err; |
81 } |
116 } |
82 } |
117 } |
|
118 |
|
119 #ifdef SYMBIAN_AUTH_SERVER |
|
120 #ifdef __WINS__ |
|
121 |
|
122 /*static*/ bool UseAuthServer(void) |
|
123 { |
|
124 bool useAuthServer = false; |
|
125 |
|
126 TUint32 useAuth = 0; |
|
127 // For the emulator allow the constant to be patched via epoc.ini |
|
128 UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalIntProperty, |
|
129 (TAny*)"KKeyStoreUseAuthServer", &useAuth); // read emulator property (if present) |
|
130 if(useAuth) |
|
131 { |
|
132 useAuthServer = true; |
|
133 } |
|
134 return useAuthServer; |
|
135 } |
|
136 #endif // __WINS__ |
|
137 #endif // SYMBIAN_AUTH_SERVER |
83 |
138 |
84 TInt StartServer() |
139 TInt StartServer() |
85 { |
140 { |
86 // Server startup is different for WINS in EKA1 mode ONLY (lack of process |
141 // Server startup is different for WINS in EKA1 mode ONLY (lack of process |
87 // emulation - we load the library in this instance |
142 // emulation - we load the library in this instance |
88 const TUidType serverUid(KNullUid, KNullUid, KUidFSTokenServer); |
143 const TUidType serverUid(KNullUid, KNullUid, KUidFSTokenServer); |
89 |
144 |
90 RProcess server; |
145 RProcess server; |
91 TInt r = server.Create(KFSTokenServerImg, KNullDesC, serverUid); |
146 TInt error = KErrNone; |
92 |
147 |
93 if (r != KErrNone) |
148 #ifdef SYMBIAN_AUTH_SERVER |
|
149 #ifdef __WINS__ |
|
150 if(UseAuthServer()) |
94 { |
151 { |
95 return r; |
152 error = server.Create(KFSNewTokenServerImg, KNullDesC, serverUid); |
|
153 } |
|
154 else |
|
155 #endif // __WINS__ |
|
156 #endif // SYMBIAN_AUTH_SERVER |
|
157 { |
|
158 error = server.Create(KFSTokenServerImg, KNullDesC, serverUid); |
|
159 } |
|
160 |
|
161 if (error != KErrNone) |
|
162 { |
|
163 return error; |
96 } |
164 } |
97 |
165 |
98 // Synchronise with the process to make sure it hasn't died straight away |
166 // Synchronise with the process to make sure it hasn't died straight away |
99 TRequestStatus stat; |
167 TRequestStatus stat; |
100 server.Rendezvous(stat); |
168 server.Rendezvous(stat); |