KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > systest > securebasic > Matrix


1 package org.objectweb.celtix.systest.securebasic;
2
3
4 import org.objectweb.hello_world_soap_http_secure.types.Result;
5
6
7 public class Matrix {
8  
9     protected static final boolean SUCCEED = true;
10     protected static final boolean FAIL = false;
11  
12     
13     protected static final ThreeTierTestItem[] THREE_TIER_TESTS = {
14         //0 Inter and Target want and require pier authenticaion,
15
//all provided so all succeed
16
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
17                                             "SoapPortAllDataSet",
18                                             "InterSecureSOAPService",
19                                             SUCCEED,
20                                             null),
21                               new InterData("hello_world_secure.wsdl",
22                                             "SoapPortAllDataSet",
23                                             "TargetSecureSOAPService",
24                                             SUCCEED,
25                                             null),
26                               new TargetData(SUCCEED,
27                                              null)),
28         //1 Inter and Target want and require pier authenticaion,
29
//all provided by client but inter doesn't have anything set
30
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
31                                              "SoapPortAllDataSet",
32                                              "InterSecureSOAPService",
33                                              SUCCEED,
34                                              null),
35                               new InterData("hello_world_secure.wsdl",
36                                             "SoapPortNoDataSet",
37                                             "TargetSecureSOAPService",
38                                             FAIL,
39                                             null),
40                               new TargetData(FAIL,
41                                              null)),
42                                
43         //2 Wrong Keystore and server wants and needs client auth so should fail
44
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
45                                             "SoapPortAllDataSet",
46                                             "InterSecureSOAPService",
47                                             SUCCEED,
48                                             null),
49                               new InterData("hello_world_secure.wsdl",
50                                             "SoapPortAllDataSetWrongKeystore",
51                                             "TargetSecureSOAPService",
52                                             FAIL,
53                                             null),
54                                new TargetData(FAIL,
55                                               null)),
56         //3 Wrong Keystore server wants but doesn't need client auth so
57
// should pass
58
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
59                                              "SoapPortAllDataSet",
60                                              "InterSecureSOAPService",
61                                              SUCCEED,
62                                              null),
63                                new InterData("hello_world_secure.wsdl",
64                                              "SoapPortAllDataSetWrongKeystore",
65                                              "TargetSecureDontRequireClientAuthSOAPService",
66                                              SUCCEED,
67                                              null),
68                                new TargetData(SUCCEED,
69                                               null)),
70                                
71         //4 Wrong KeystoreType and server wants and needs client auth so should fail
72
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
73                                              "SoapPortAllDataSet",
74                                              "InterSecureSOAPService",
75                                              SUCCEED,
76                                              null),
77                               new InterData("hello_world_secure.wsdl",
78                                             "SoapPortAllDataSetWrongKeystoreType",
79                                             "TargetSecureSOAPService",
80                                             FAIL,
81                                             null),
82                              new TargetData(FAIL,
83                                             null)),
84         
85         //5 Wrong Keystore Password and server wants and needs client auth so should fail
86
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
87                                              "SoapPortAllDataSet",
88                                              "InterSecureSOAPService",
89                                              SUCCEED,
90                                              null),
91                               new InterData("hello_world_secure.wsdl",
92                                             "SoapPortAllDataSetWrongKeystorePassword",
93                                             "TargetSecureSOAPService",
94                                              FAIL,
95                                              null),
96                               new TargetData(FAIL,
97                                              null)),
98                                
99         //6 Wrong Keystore Password and server wants but does not need client auth so should SUCCEED
100
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
101                                              "SoapPortAllDataSet",
102                                              "InterSecureSOAPService",
103                                              SUCCEED,
104                                              null),
105                               new InterData("hello_world_secure.wsdl",
106                                             "SoapPortAllDataSetWrongKeystorePassword",
107                                             "TargetSecureDontRequireClientAuthSOAPService",
108                                             SUCCEED,
109                                             null),
110                               new TargetData(SUCCEED,
111                                              null)),
112                               
113         //7 Wrong Client Password and server wants and needs client auth which
114
//would at first impl it would fail but due to limitation in JSSE the client password
115
//and keystore need to be the same, so all that haapens is that the correct keystore
116
//password is used and a warning is logged to say that the client password is not being
117
//used and the invocation succeeds
118
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
119                                              "SoapPortAllDataSet",
120                                              "InterSecureSOAPService",
121                                              SUCCEED,
122                                              null),
123                               new InterData("hello_world_secure.wsdl",
124                                             "SoapPortAllDataSetWrongClientPassword",
125                                             "TargetSecureSOAPService",
126                                             SUCCEED,
127                                             null),
128                               new TargetData(SUCCEED,
129                                              null)),
130                               
131         //8 Wrong Truststore and client auth wants and needs server authentication so the invocation fails
132
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
133                                              "SoapPortAllDataSet",
134                                              "InterSecureSOAPService",
135                                              SUCCEED,
136                                              null),
137                               new InterData("hello_world_secure.wsdl",
138                                             "SoapPortAllDataSetWrongTrustStore",
139                                             "TargetSecureSOAPService",
140                                             FAIL,
141                                             null),
142                               new TargetData(FAIL,
143                                              null)),
144         //9 Wrong Truststore Type and client auth wants and needs server
145
//authentication so the invocation fails
146
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
147                                              "SoapPortAllDataSet",
148                                              "InterSecureSOAPService",
149                                              SUCCEED,
150                                              null),
151                               new InterData("hello_world_secure.wsdl",
152                                             "SoapPortAllDataSetWrongTrustStoreType",
153                                             "TargetSecureSOAPService",
154                                             FAIL,
155                                             null),
156                               new TargetData(FAIL,
157                                              null)),
158                               
159         //10 Invalid Secure socket protocol used so will fail
160
new ThreeTierTestItem(new ClientData("hello_world_secure.wsdl",
161                                              "SoapPortAllDataSet",
162                                              "InterSecureSOAPService",
163                                              SUCCEED,
164                                              null),
165                               new InterData("hello_world_secure.wsdl",
166                                             "SoapPortAllDataSetWrongSecureSocketProtocol",
167                                             "TargetSecureSOAPService",
168                                             FAIL,
169                                             null),
170                               new TargetData(FAIL,
171                                              null))
172                                                            
173     };
174     
175     protected static final TwoTierTestItem[] TWO_TIER_TESTS = {
176         //0 Server wants and need client auth so must
177
//provide all data to succeed
178
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
179                                            "SoapPortAllDataSet",
180                                            "SecureSOAPService",
181                                            SUCCEED,
182                                            null),
183                             new TargetData(SUCCEED,
184                                            null)) ,
185         //1 Server wants and need client auth but client auth data
186
//not provided so it will fail
187
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
188                                             "SoapPortNoDataSet",
189                                             "SecureSOAPService",
190                                             FAIL,
191                                             null),
192                              new TargetData(FAIL,
193                                             null)),
194                              
195         //2 Wrong Keystore and server wants and needs client auth so should fail
196
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
197                                             "SoapPortAllDataSetWrongKeystore",
198                                             "SecureSOAPService",
199                                             FAIL,
200                                             null),
201                              new TargetData(FAIL,
202                                             null)),
203         //3 Wrong Keystore server wants but doesn't need client auth so
204
// should pass
205
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
206                                            "SoapPortAllDataSetWrongKeystore",
207                                            "SecureDontRequireClientAuthSOAPService",
208                                            SUCCEED,
209                                            null),
210                              new TargetData(SUCCEED,
211                                             null)),
212                              
213         //4 Wrong KeystoreType and server wants and needs client auth so should fail
214
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
215                                            "SoapPortAllDataSetWrongKeystoreType",
216                                            "SecureSOAPService",
217                                            FAIL,
218                                            null),
219                              new TargetData(FAIL,
220                                             null)),
221
222         //5 Wrong Keystore Password and server wants and needs client auth so should fail
223
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
224                                            "SoapPortAllDataSetWrongKeystorePassword",
225                                            "SecureSOAPService",
226                                            FAIL,
227                                            null),
228                             new TargetData(FAIL,
229                                            null)),
230                              
231         //6 Wrong Keystore Password and server wants but does not need client auth so should SUCCEED
232
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
233                                            "SoapPortAllDataSetWrongKeystorePassword",
234                                            "SecureDontRequireClientAuthSOAPService",
235                                            SUCCEED,
236                                            null),
237                             new TargetData(SUCCEED,
238                                            null)),
239                             
240         //7 Wrong Client Password and server wants and needs client auth which
241
//would at first impl it would fail but due to limitation in JSSE the client password
242
//and keystore need to be the same, so all that haapens is that the correct keystore
243
//password is used and a warning is logged to say that the client password is not being
244
//used and the invocation succeeds
245
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
246                                            "SoapPortAllDataSetWrongClientPassword",
247                                            "SecureSOAPService",
248                                            SUCCEED,
249                                            null),
250                             new TargetData(SUCCEED,
251                                            null)),
252                             
253         //8 Wrong Truststore and client auth wants and needs server authentication so the invocation fails
254
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
255                                            "SoapPortAllDataSetWrongTrustStore",
256                                            "SecureSOAPService",
257                                            FAIL,
258                                            null),
259                             new TargetData(FAIL,
260                                            null)),
261         //9 Wrong Truststore Type and client auth wants and needs server
262
//authentication so the invocation fails
263
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
264                                            "SoapPortAllDataSetWrongTrustStoreType",
265                                            "SecureSOAPService",
266                                            FAIL,
267                                            null),
268                             new TargetData(FAIL,
269                                            null)),
270                             
271         //10 Invalid Secure socket protocol used so will fail
272
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
273                                            "SoapPortAllDataSetWrongSecureSocketProtocol",
274                                            "SecureSOAPService",
275                                            FAIL,
276                                            null),
277                             new TargetData(FAIL,
278                                            null)),
279         //11 No data set in client configuration file, all client data retrieved from data provider
280
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
281                                            "SoapPortNoDataSetProviderSetsAllData",
282                                            "SecureSOAPService",
283                                            SUCCEED,
284                                            "org.objectweb.celtix.systest.securebasic."
285                                                + "SetAllDataSecurityDataProvider"),
286                             new TargetData(SUCCEED,
287                                            null)),
288         //12 All wrong data set in client configuration file, all good client data
289
//retrieved from data provider, will succeed cause provider has precedence over config
290
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
291                                            "SoapPortAllWrongDataSetProviderSetsGoodData",
292                                            "SecureSOAPService",
293                                            SUCCEED,
294                                            "org.objectweb.celtix.systest.securebasic."
295                                                + "SetAllDataSecurityDataProvider"),
296                             new TargetData(SUCCEED,
297                                            null)),
298         //13 All good data set in client configuration file, but bad client data
299
//retrieved from data provider
300
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
301                                            "SoapPortAllDataSetProviderSetsBadData",
302                                            "SecureSOAPService",
303                                            FAIL,
304                                            "org.objectweb.celtix.systest.securebasic."
305                                                + "SetBadDataSecurityDataProvider"),
306                             new TargetData(FAIL,
307                                            null)),
308         //14 All client data set in configuration file, all server data retrieved from data provider
309
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
310                                            "SoapPortAllDataSet",
311                                            "SecureSOAPServiceServerConfiguredByGoodProvider",
312                                            SUCCEED,
313                                            null),
314                             new TargetData(SUCCEED,
315                                            "org.objectweb.celtix.systest.securebasic."
316                                                + "SetAllDataSecurityDataProvider")),
317         //15 All client data set in configuration file, all server data retrieved from configuration but
318
//data provider changes truststore so the invocation will be rejected
319
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
320                                            "SoapPortAllDataSet",
321                                            "SecureSOAPServiceServerConfiguredByBadProvider",
322                                            FAIL,
323                                            null),
324                             new TargetData(FAIL,
325                                            "org.objectweb.celtix.systest.securebasic."
326                                                + "SetBadDataSecurityDataProvider")),
327         //16 All client data set in configuration file, all server data retrieved from configuration
328
// testing pkcs12 cerst specifically
329
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
330                                            "SoapPortAllDataSetP12Certs",
331                                            "SecureSOAPServiceP12",
332                                            SUCCEED,
333                                            null),
334                             new TargetData(SUCCEED,
335                                            null)),
336                                            
337         //17 All client data set in configuration file, all server data retrieved from configuration but
338
// but server has non default ciphersuite so handshake will fail
339
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
340                                            "SoapPortAllDataSet",
341                                            "SecureSOAPServiceDifferentCipherSuites",
342                                            FAIL,
343                                            null),
344                             new TargetData(FAIL,
345                                            null)),
346         //18 All client data set in configuration file, all server data retrieved from configuration
347
//server and client have non default ciphersuite so handshake will pass
348
new TwoTierTestItem(new ClientData("hello_world_secure.wsdl",
349                                            "SoapPortAllDataSetDifferentCipherSuites",
350                                            "SecureSOAPServiceDifferentCipherSuites",
351                                            SUCCEED,
352                                            null),
353                             new TargetData(SUCCEED,
354                                            null))
355     };
356     
357     public Matrix() {
358         t();
359     }
360     
361     
362     protected static Result fail(String JavaDoc reason) {
363         Result ret = new Result();
364         ret.setDidPass(Matrix.FAIL);
365         ret.setReturnString("");
366         ret.setFailureReason(reason);
367         return ret;
368     }
369
370     protected static Result dealWithResponse(String JavaDoc expectedResult,
371                                              Result res) {
372         if (!res.isDidPass()) {
373             return fail("The invocation from the server reported a failure = "
374                         + res.getFailureReason());
375         }
376         if (!res.getReturnString().equals(expectedResult)) {
377             return fail("The expected return string and the actual return string didn't match");
378         }
379         
380         return null;
381     }
382     
383     private void t() {
384         //For compilation reasons we have to have a non static method, must check why
385
}
386     
387 }
388
389
390 class ClientData {
391     String JavaDoc clientWsdl;
392     String JavaDoc clientPortName;
393     String JavaDoc clientServiceName;
394     boolean clientExpectSuccess;
395     String JavaDoc securityConfigurer;
396     public ClientData(String JavaDoc clientWsdlParam,
397                       String JavaDoc clientPortNameParam,
398                       String JavaDoc clientServiceNameParam,
399                       boolean clientExpectSuccessParam,
400                       String JavaDoc securityConfigurerParam) {
401         clientWsdl = clientWsdlParam;
402         clientPortName = clientPortNameParam;
403         clientServiceName = clientServiceNameParam;
404         clientExpectSuccess = clientExpectSuccessParam;
405         securityConfigurer = securityConfigurerParam;
406         
407     }
408 }
409
410 class InterData {
411     String JavaDoc interWsdl;
412     String JavaDoc interPortName;
413     String JavaDoc interServiceName;
414     boolean interExpectSuccess;
415     String JavaDoc securityConfigurer;
416     public InterData(String JavaDoc interWsdlParam,
417                      String JavaDoc interPortNameParam,
418                      String JavaDoc interServiceNameParam,
419                      boolean interExpectSuccessParam,
420                      String JavaDoc securityConfigurerParam) {
421         interWsdl = interWsdlParam;
422         interPortName = interPortNameParam;
423         interServiceName = interServiceNameParam;
424         interExpectSuccess = interExpectSuccessParam;
425         securityConfigurer = securityConfigurerParam;
426         
427     }
428 }
429
430 class TargetData {
431     boolean targetExpectSuccess;
432     String JavaDoc securityConfigurer;
433     public TargetData(boolean targetExpectSuccessParam,
434                       String JavaDoc securityConfigurerParam) {
435         targetExpectSuccess = targetExpectSuccessParam;
436         securityConfigurer = securityConfigurerParam;
437         
438     }
439 }
440
441 class ThreeTierTestItem {
442
443     ClientData clientData;
444     InterData interData;
445     TargetData targetData;
446
447
448     
449     public ThreeTierTestItem(ClientData clientDataParam,
450                              InterData interDataParam,
451                              TargetData targetDataParam) {
452         clientData = clientDataParam;
453         interData = interDataParam;
454         targetData = targetDataParam;
455
456         
457     }
458 }
459
460 class TwoTierTestItem {
461     ClientData clientData;
462     TargetData targetData;
463     
464     public TwoTierTestItem(ClientData clientDataParam,
465                              TargetData targetDataParam) {
466         clientData = clientDataParam;
467         targetData = targetDataParam;
468
469         
470     }
471 }
472
473
Popular Tags