This project has retired. For details please refer to its
Attic page.
UDDI_142_DigitalSignatureIntegrationTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.v3.tck;
17
18 import java.security.cert.CertificateException;
19 import java.util.List;
20 import java.util.concurrent.atomic.AtomicReference;
21 import javax.xml.ws.BindingProvider;
22 import org.apache.commons.configuration.ConfigurationException;
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.juddi.jaxb.PrintUDDI;
26 import org.apache.juddi.v3.client.config.UDDIClient;
27 import org.apache.juddi.v3.client.cryptor.DigSigUtil;
28 import org.apache.juddi.v3.client.transport.Transport;
29 import org.junit.AfterClass;
30 import org.junit.Assert;
31 import org.junit.Assume;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
34 import org.uddi.api_v3.AccessPoint;
35 import org.uddi.api_v3.BindingTemplate;
36 import org.uddi.api_v3.BindingTemplates;
37 import org.uddi.api_v3.BusinessDetail;
38 import org.uddi.api_v3.BusinessEntity;
39 import org.uddi.api_v3.BusinessService;
40 import org.uddi.api_v3.BusinessServices;
41 import org.uddi.api_v3.DeleteBusiness;
42 import org.uddi.api_v3.DeleteTModel;
43 import org.uddi.api_v3.GetBusinessDetail;
44 import org.uddi.api_v3.Name;
45 import org.uddi.api_v3.SaveBinding;
46 import org.uddi.api_v3.SaveBusiness;
47 import org.uddi.api_v3.SaveService;
48 import org.uddi.api_v3.SaveTModel;
49 import org.uddi.api_v3.ServiceDetail;
50 import org.uddi.api_v3.TModel;
51 import org.uddi.v3_service.UDDIInquiryPortType;
52 import org.uddi.v3_service.UDDIPublicationPortType;
53 import org.uddi.v3_service.UDDISecurityPortType;
54 import org.uddi.v3_service.UDDISubscriptionPortType;
55
56
57
58
59
60 public class UDDI_142_DigitalSignatureIntegrationTest {
61
62 private static Log logger = LogFactory.getLog(UDDI_142_DigitalSignatureIntegrationTest.class);
63 static UDDISecurityPortType security = null;
64 static UDDISubscriptionPortType subscriptionJoe = null;
65 static UDDIInquiryPortType inquiryJoe = null;
66 static UDDIPublicationPortType publicationJoe = null;
67 static TckTModel tckTModelJoe = null;
68 static TckBusiness tckBusinessJoe = null;
69 static UDDISubscriptionPortType subscriptionSam = null;
70 static UDDIInquiryPortType inquiryJoeSam = null;
71 static UDDIPublicationPortType publicationSam = null;
72 static TckTModel tckTModelSam = null;
73 static TckBusiness tckBusinessSam = null;
74 protected static String authInfoJoe = null;
75 protected static String authInfoSam = null;
76 private static UDDIClient manager;
77
78 @AfterClass
79 public static void stopManager() throws ConfigurationException {
80 if (!TckPublisher.isEnabled()) {
81 return;
82 }
83 tckTModelJoe.deleteCreatedTModels(authInfoJoe);
84 tckTModelSam.deleteCreatedTModels(authInfoSam);
85 manager.stop();
86 }
87
88 @BeforeClass
89 public static void startManager() throws ConfigurationException {
90 if (!TckPublisher.isEnabled()) {
91 return;
92 }
93 logger.info("UDDI_142_DigitalSignatureIntegrationTests");
94 manager = new UDDIClient();
95 manager.start();
96
97 logger.debug("Getting auth tokens..");
98 try {
99 Transport transport = manager.getTransport("uddiv3");
100 security = transport.getUDDISecurityService();
101
102 publicationJoe = transport.getUDDIPublishService();
103 inquiryJoe = transport.getUDDIInquiryService();
104
105 subscriptionJoe = transport.getUDDISubscriptionService();
106
107 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
108 authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
109
110
111 if (!TckPublisher.isUDDIAuthMode()) {
112 TckSecurity.setCredentials((BindingProvider) publicationJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
113 TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
114 TckSecurity.setCredentials((BindingProvider) subscriptionJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
115
116 }
117 tckTModelJoe = new TckTModel(publicationJoe, inquiryJoe);
118 tckBusinessJoe = new TckBusiness(publicationJoe, inquiryJoe);
119
120 transport = manager.getTransport("uddiv3");
121
122 publicationSam = transport.getUDDIPublishService();
123 inquiryJoeSam = transport.getUDDIInquiryService();
124 if (!TckPublisher.isUDDIAuthMode()) {
125 TckSecurity.setCredentials((BindingProvider) publicationSam, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
126 TckSecurity.setCredentials((BindingProvider) inquiryJoeSam, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
127 TckSecurity.setCredentials((BindingProvider) subscriptionSam, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
128 }
129 subscriptionSam = transport.getUDDISubscriptionService();
130 tckTModelSam = new TckTModel(publicationSam, inquiryJoeSam);
131 tckBusinessSam = new TckBusiness(publicationSam, inquiryJoeSam);
132
133 } catch (Exception e) {
134 logger.error(e.getMessage(), e);
135 Assert.fail("Could not obtain authInfo token.");
136 }
137 JUDDI_300_MultiNodeIntegrationTest.testSetupReplicationConfig();
138 }
139
140 private void DeleteBusinesses(List<String> businesskeysToDelete, String authinfo, UDDIPublicationPortType pub) {
141
142 try {
143 DeleteBusiness db = new DeleteBusiness();
144 db.setAuthInfo(authinfo);
145 db.getBusinessKey().addAll(businesskeysToDelete);
146 pub.deleteBusiness(db);
147 } catch (Exception ex) {
148 ex.printStackTrace();
149 }
150 }
151
152 private void DeleteBusinesses(String businesskeysToDelete, String authinfo, UDDIPublicationPortType pub) {
153
154 try {
155 DeleteBusiness db = new DeleteBusiness();
156 db.setAuthInfo(authinfo);
157 db.getBusinessKey().add(businesskeysToDelete);
158 pub.deleteBusiness(db);
159 } catch (Exception ex) {
160 ex.printStackTrace();
161 }
162 }
163
164 @Test()
165 public void JUDDI_712_SaveBusinessProjectionWithSignature() throws CertificateException {
166 Assume.assumeTrue(TckPublisher.isEnabled());
167 SaveBusiness sb = new SaveBusiness();
168 sb.setAuthInfo(authInfoJoe);
169 BusinessEntity be = new BusinessEntity();
170 Name n = new Name();
171 n.setValue("JUDDI_JUDDI_712_SaveBusinessProjectionWithSignature");
172 be.getName().add(n);
173 DigSigUtil ds = GetDigSig();
174 be = ds.signUddiEntity(be);
175 sb.getBusinessEntity().add(be);
176 try {
177 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
178 Assert.fail("unexpected success");
179 } catch (Exception ex) {
180 logger.info("Expected failure: " + ex.getMessage());
181 }
182 }
183
184 @Test()
185 public void JUDDI_712_SaveBusinessProjectionNoServiceKeyWithSignature() throws CertificateException {
186 Assume.assumeTrue(TckPublisher.isEnabled());
187 SaveBusiness sb = new SaveBusiness();
188 sb.setAuthInfo(authInfoJoe);
189 BusinessEntity be = new BusinessEntity();
190 Name n = new Name();
191 n.setValue("JUDDI_712_SaveBusinessProjectionNoServiceKeyWithSignature");
192 be.getName().add(n);
193 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
194
195
196 BusinessService bs = new BusinessService();
197 bs.getName().add(new Name("Joe's bs", null));
198 be.setBusinessServices(new BusinessServices());
199 be.getBusinessServices().getBusinessService().add(bs);
200
201 DigSigUtil ds = GetDigSig();
202 be = ds.signUddiEntity(be);
203 sb.getBusinessEntity().add(be);
204 try {
205 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
206 Assert.fail("unexpected success");
207 } catch (Exception ex) {
208 logger.info("Expected failure: " + ex.getMessage());
209 }
210 }
211
212 @Test()
213 public void JUDDI_712_SaveBusinessProjectionNoServiceKey2WithSignature() throws CertificateException {
214 Assume.assumeTrue(TckPublisher.isEnabled());
215 SaveBusiness sb = new SaveBusiness();
216 sb.setAuthInfo(authInfoJoe);
217 BusinessEntity be = new BusinessEntity();
218 Name n = new Name();
219 n.setValue("JUDDI_712_SaveBusinessProjectionNoServiceKey2WithSignature");
220 be.getName().add(n);
221 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
222
223
224 BusinessService bs = new BusinessService();
225 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
226 bs.getName().add(new Name("Joe's bs", null));
227 be.setBusinessServices(new BusinessServices());
228 be.getBusinessServices().getBusinessService().add(bs);
229
230 DigSigUtil ds = GetDigSig();
231 be = ds.signUddiEntity(be);
232 sb.getBusinessEntity().add(be);
233 try {
234 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
235 Assert.fail("unexpected success");
236 } catch (Exception ex) {
237 logger.info("Expected failure: " + ex.getMessage());
238 }
239 }
240
241 @Test()
242 public void JUDDI_712_SaveBusinessProjectionNoServiceKey3WithSignature() throws CertificateException {
243 Assume.assumeTrue(TckPublisher.isEnabled());
244 SaveBusiness sb = new SaveBusiness();
245 sb.setAuthInfo(authInfoJoe);
246 BusinessEntity be = new BusinessEntity();
247 Name n = new Name();
248 n.setValue("JUDDI_712_SaveBusinessProjectionNoServiceKey3WithSignature");
249 be.getName().add(n);
250 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
251
252
253 BusinessService bs = new BusinessService();
254
255 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
256 bs.getName().add(new Name("Joe's bs", null));
257 be.setBusinessServices(new BusinessServices());
258 be.getBusinessServices().getBusinessService().add(bs);
259
260 DigSigUtil ds = GetDigSig();
261 be = ds.signUddiEntity(be);
262 sb.getBusinessEntity().add(be);
263 try {
264 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
265 Assert.fail("unexpected success");
266 } catch (Exception ex) {
267 logger.info("Expected failure: " + ex.getMessage());
268 }
269 }
270
271 @Test()
272 public void JUDDI_712_SaveServiceProjectionNoServiceKey3WithSignature() throws CertificateException {
273 Assume.assumeTrue(TckPublisher.isEnabled());
274 SaveBusiness sb = new SaveBusiness();
275 sb.setAuthInfo(authInfoJoe);
276 BusinessEntity be = new BusinessEntity();
277 Name n = new Name();
278 n.setValue("JUDDI_712_SaveServiceProjectionNoServiceKey3WithSignature");
279 be.getName().add(n);
280 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
281
282 BusinessService bs = new BusinessService();
283 bs.setBusinessKey(null);
284 bs.setServiceKey(null);
285 bs.getName().add(new Name("Joe's bs", null));
286 DigSigUtil ds = GetDigSig();
287 bs = ds.signUddiEntity(bs);
288
289 be.setBusinessServices(new BusinessServices());
290 be.getBusinessServices().getBusinessService().add(bs);
291
292 sb.getBusinessEntity().add(be);
293 try {
294 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
295 Assert.fail("unexpected success");
296 } catch (Exception ex) {
297 logger.info("Expected failure: " + ex.getMessage());
298 }
299 }
300
301 @Test()
302 public void JUDDI_712_SaveServiceProjectionNoServiceKey1WithSignature() throws CertificateException {
303 Assume.assumeTrue(TckPublisher.isEnabled());
304 SaveBusiness sb = new SaveBusiness();
305 sb.setAuthInfo(authInfoJoe);
306 BusinessEntity be = new BusinessEntity();
307 Name n = new Name();
308 n.setValue("JUDDI_712_SaveServiceProjectionNoServiceKey1WithSignature");
309 be.getName().add(n);
310 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
311
312 BusinessService bs = new BusinessService();
313 bs.setBusinessKey(null);
314 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
315 bs.getName().add(new Name("Joe's bs", null));
316 DigSigUtil ds = GetDigSig();
317 bs = ds.signUddiEntity(bs);
318
319 be.setBusinessServices(new BusinessServices());
320 be.getBusinessServices().getBusinessService().add(bs);
321
322 sb.getBusinessEntity().add(be);
323 try {
324 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
325 Assert.fail("unexpected success");
326 } catch (Exception ex) {
327 logger.info("Expected failure: " + ex.getMessage());
328 }
329 }
330
331 @Test()
332 public void JUDDI_712_SaveServiceProjectionNoServiceKey2WithSignature() throws CertificateException {
333 Assume.assumeTrue(TckPublisher.isEnabled());
334 SaveBusiness sb = new SaveBusiness();
335 sb.setAuthInfo(authInfoJoe);
336 BusinessEntity be = new BusinessEntity();
337 Name n = new Name();
338 n.setValue("JUDDI_712_SaveServiceProjectionNoServiceKey2WithSignature");
339 be.getName().add(n);
340 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
341
342 BusinessService bs = new BusinessService();
343 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
344 bs.setServiceKey(null);
345 bs.getName().add(new Name("Joe's bs", null));
346 DigSigUtil ds = GetDigSig();
347 bs = ds.signUddiEntity(bs);
348
349 be.setBusinessServices(new BusinessServices());
350 be.getBusinessServices().getBusinessService().add(bs);
351
352 sb.getBusinessEntity().add(be);
353 try {
354 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
355 Assert.fail("unexpected success");
356 } catch (Exception ex) {
357 logger.info("Expected failure: " + ex.getMessage());
358 }
359 }
360
361 public void JUDDI_712_SaveBusinessNoneDefined() throws Exception {
362 Assume.assumeTrue(TckPublisher.isEnabled());
363 SaveBusiness sb = new SaveBusiness();
364 sb.setAuthInfo(authInfoJoe);
365 BusinessEntity be = new BusinessEntity();
366 Name n = new Name();
367 n.setValue("JUDDI_712_SaveServiceWithSignature");
368 be.getName().add(n);
369 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
370
371 try {
372 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
373 Assert.fail("unexpected success");
374 } catch (Exception ex) {
375 logger.info("Expected failure: " + ex.getMessage());
376 throw ex;
377 }
378 }
379
380 @Test()
381 public void JUDDI_712_SaveServiceWithSignature() throws CertificateException {
382 Assume.assumeTrue(TckPublisher.isEnabled());
383 SaveBusiness sb = new SaveBusiness();
384 sb.setAuthInfo(authInfoJoe);
385 BusinessEntity be = new BusinessEntity();
386 Name n = new Name();
387 n.setValue("JUDDI_712_SaveServiceWithSignature");
388 be.getName().add(n);
389 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
390 sb.getBusinessEntity().add(be);
391 try {
392 BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
393 } catch (Exception ex) {
394 logger.info("UnExpected failure: ", ex);
395 Assert.fail();
396 }
397
398 SaveService ss = new SaveService();
399 ss.setAuthInfo(authInfoJoe);
400 BusinessService bs = new BusinessService();
401 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
402 bs.setServiceKey(null);
403 bs.getName().add(new Name("Joe's bs", null));
404 DigSigUtil ds = GetDigSig();
405 bs = ds.signUddiEntity(bs);
406
407 be.setBusinessServices(new BusinessServices());
408 be.getBusinessServices().getBusinessService().add(bs);
409
410 sb.getBusinessEntity().add(be);
411 try {
412 publicationJoe.saveService(ss);
413 Assert.fail("unexpected success");
414 } catch (Exception ex) {
415 logger.info("Expected failure: " + ex.getMessage());
416 }
417 }
418
419 @Test()
420 public void JUDDI_712_SaveService1WithSignature() throws CertificateException {
421 Assume.assumeTrue(TckPublisher.isEnabled());
422 SaveBusiness sb = new SaveBusiness();
423 sb.setAuthInfo(authInfoJoe);
424 BusinessEntity be = new BusinessEntity();
425 Name n = new Name();
426 n.setValue("JUDDI_712_SaveService1WithSignature");
427 be.getName().add(n);
428 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
429 sb.getBusinessEntity().add(be);
430 BusinessDetail saveBusiness = null;
431 try {
432 saveBusiness = publicationJoe.saveBusiness(sb);
433 } catch (Exception ex) {
434 logger.info("UnExpected failure: ", ex);
435 Assert.fail();
436 }
437
438 SaveService ss = new SaveService();
439 ss.setAuthInfo(authInfoJoe);
440 BusinessService bs = new BusinessService();
441 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
442 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
443 bs.setBindingTemplates(new BindingTemplates());
444 BindingTemplate bt = new BindingTemplate();
445 bt.setBindingKey(null);
446 bt.setServiceKey(null);
447 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
448 bs.getBindingTemplates().getBindingTemplate().add(bt);
449 bs.getName().add(new Name("Joe's bs", null));
450 DigSigUtil ds = GetDigSig();
451 bs = ds.signUddiEntity(bs);
452
453 be.setBusinessServices(new BusinessServices());
454 be.getBusinessServices().getBusinessService().add(bs);
455
456 sb.getBusinessEntity().add(be);
457 try {
458 publicationJoe.saveService(ss);
459 Assert.fail("unexpected success");
460 } catch (Exception ex) {
461 logger.info("Expected failure: " + ex.getMessage());
462 } finally {
463 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
464 }
465 }
466
467 @Test()
468 public void JUDDI_712_SaveService2WithSignature() throws CertificateException {
469 Assume.assumeTrue(TckPublisher.isEnabled());
470 SaveBusiness sb = new SaveBusiness();
471 sb.setAuthInfo(authInfoJoe);
472 BusinessEntity be = new BusinessEntity();
473 Name n = new Name();
474 n.setValue("JUDDI_712_SaveService2WithSignature");
475 be.getName().add(n);
476 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
477 sb.getBusinessEntity().add(be);
478 BusinessDetail saveBusiness = null;
479 try {
480
481 saveBusiness = publicationJoe.saveBusiness(sb);
482 } catch (Exception ex) {
483 logger.info("UnExpected failure: ", ex);
484 Assert.fail();
485 }
486
487 SaveService ss = new SaveService();
488 ss.setAuthInfo(authInfoJoe);
489 BusinessService bs = new BusinessService();
490 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
491 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
492 bs.setBindingTemplates(new BindingTemplates());
493 BindingTemplate bt = new BindingTemplate();
494 bt.setBindingKey(null);
495 bt.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
496 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
497 bs.getBindingTemplates().getBindingTemplate().add(bt);
498 bs.getName().add(new Name("Joe's bs", null));
499 DigSigUtil ds = GetDigSig();
500 bs = ds.signUddiEntity(bs);
501
502 be.setBusinessServices(new BusinessServices());
503 be.getBusinessServices().getBusinessService().add(bs);
504
505 sb.getBusinessEntity().add(be);
506 try {
507 publicationJoe.saveService(ss);
508 Assert.fail("unexpected success");
509 } catch (Exception ex) {
510 logger.info("Expected failure: " + ex.getMessage());
511 } finally {
512 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
513 }
514 }
515
516 @Test()
517 public void JUDDI_712_SaveService3WithSignature() throws CertificateException {
518 Assume.assumeTrue(TckPublisher.isEnabled());
519 SaveBusiness sb = new SaveBusiness();
520 sb.setAuthInfo(authInfoJoe);
521 BusinessEntity be = new BusinessEntity();
522 Name n = new Name();
523 n.setValue("JUDDI_712_SaveService3WithSignature");
524 be.getName().add(n);
525 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
526 sb.getBusinessEntity().add(be);
527 BusinessDetail saveBusiness = null;
528 try {
529 saveBusiness = publicationJoe.saveBusiness(sb);
530 } catch (Exception ex) {
531 logger.info("UnExpected failure: ", ex);
532 Assert.fail();
533 }
534
535 SaveService ss = new SaveService();
536 ss.setAuthInfo(authInfoJoe);
537 BusinessService bs = new BusinessService();
538 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
539 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
540 bs.setBindingTemplates(new BindingTemplates());
541 BindingTemplate bt = new BindingTemplate();
542 bt.setBindingKey(TckBusinessService.JOE_BINDING_KEY_1);
543 bt.setServiceKey(null);
544 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
545 bs.getBindingTemplates().getBindingTemplate().add(bt);
546 bs.getName().add(new Name("Joe's bs", null));
547 DigSigUtil ds = GetDigSig();
548 bs = ds.signUddiEntity(bs);
549
550 be.setBusinessServices(new BusinessServices());
551 be.getBusinessServices().getBusinessService().add(bs);
552
553 sb.getBusinessEntity().add(be);
554 try {
555 publicationJoe.saveService(ss);
556 Assert.fail("unexpected success");
557 } catch (Exception ex) {
558 logger.info("Expected failure: " + ex.getMessage());
559 } finally {
560 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
561 }
562 }
563
564 @Test()
565 public void JUDDI_712_SaveTModelWithSignature() throws CertificateException {
566 Assume.assumeTrue(TckPublisher.isEnabled());
567 SaveTModel sb = new SaveTModel();
568 sb.setAuthInfo(authInfoJoe);
569 DigSigUtil ds = GetDigSig();
570 TModel bs = new TModel();
571 bs.setName(new Name("Joe's Tmodel", null));
572 bs = ds.signUddiEntity(bs);
573
574 sb.getTModel().add(bs);
575 try {
576 publicationJoe.saveTModel(sb);
577 Assert.fail("unexpected success");
578 } catch (Exception ex) {
579 logger.info("Expected failure: " + ex.getMessage());
580 }
581 }
582
583 @Test()
584 public void JUDDI_712_SaveService4BTWithSignature() throws CertificateException {
585 Assume.assumeTrue(TckPublisher.isEnabled());
586 SaveBusiness sb = new SaveBusiness();
587 sb.setAuthInfo(authInfoJoe);
588 BusinessEntity be = new BusinessEntity();
589 Name n = new Name();
590 n.setValue("JUDDI_712_SaveService4BTWithSignature");
591 be.getName().add(n);
592 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
593 sb.getBusinessEntity().add(be);
594 BusinessDetail saveBusiness = null;
595 try {
596 saveBusiness = publicationJoe.saveBusiness(sb);
597 } catch (Exception ex) {
598 logger.info("UnExpected failure: ", ex);
599 Assert.fail();
600 }
601
602 SaveService ss = new SaveService();
603 ss.setAuthInfo(authInfoJoe);
604 BusinessService bs = new BusinessService();
605 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
606 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
607 bs.setBindingTemplates(new BindingTemplates());
608 BindingTemplate bt = new BindingTemplate();
609 bt.setBindingKey(TckBusinessService.JOE_BINDING_KEY_1);
610 bt.setServiceKey(null);
611 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
612
613 bs.getName().add(new Name("Joe's bs", null));
614 DigSigUtil ds = GetDigSig();
615 bt = ds.signUddiEntity(bt);
616 bs.getBindingTemplates().getBindingTemplate().add(bt);
617 be.setBusinessServices(new BusinessServices());
618 be.getBusinessServices().getBusinessService().add(bs);
619
620 sb.getBusinessEntity().add(be);
621 try {
622 publicationJoe.saveService(ss);
623 Assert.fail("unexpected success");
624 } catch (Exception ex) {
625 logger.info("Expected failure: " + ex.getMessage());
626 } finally {
627 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
628 }
629 }
630
631 @Test()
632 public void JUDDI_712_SaveService5BTWithSignature() throws CertificateException {
633 Assume.assumeTrue(TckPublisher.isEnabled());
634 SaveBusiness sb = new SaveBusiness();
635 sb.setAuthInfo(authInfoJoe);
636 BusinessEntity be = new BusinessEntity();
637 Name n = new Name();
638 n.setValue("JUDDI_712_SaveService5BTWithSignature");
639 be.getName().add(n);
640 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
641 sb.getBusinessEntity().add(be);
642 BusinessDetail saveBusiness = null;
643 try {
644 saveBusiness = publicationJoe.saveBusiness(sb);
645 } catch (Exception ex) {
646 logger.info("UnExpected failure: ", ex);
647 Assert.fail();
648 }
649
650 SaveService ss = new SaveService();
651 ss.setAuthInfo(authInfoJoe);
652 BusinessService bs = new BusinessService();
653 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
654 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
655 bs.setBindingTemplates(new BindingTemplates());
656 BindingTemplate bt = new BindingTemplate();
657 bt.setBindingKey(null);
658 bt.setServiceKey(null);
659 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
660
661 bs.getName().add(new Name("Joe's bs", null));
662 DigSigUtil ds = GetDigSig();
663 bt = ds.signUddiEntity(bt);
664 bs.getBindingTemplates().getBindingTemplate().add(bt);
665 be.setBusinessServices(new BusinessServices());
666 be.getBusinessServices().getBusinessService().add(bs);
667
668 sb.getBusinessEntity().add(be);
669 try {
670 publicationJoe.saveService(ss);
671 Assert.fail("unexpected success");
672 } catch (Exception ex) {
673 logger.info("Expected failure: " + ex.getMessage());
674 } finally {
675 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
676 }
677 }
678
679 @Test()
680 public void JUDDI_712_SaveService6BTWithSignature() throws CertificateException {
681 Assume.assumeTrue(TckPublisher.isEnabled());
682 SaveBusiness sb = new SaveBusiness();
683 sb.setAuthInfo(authInfoJoe);
684 BusinessEntity be = new BusinessEntity();
685 Name n = new Name();
686 n.setValue("JUDDI_712_SaveService6BTWithSignature");
687 be.getName().add(n);
688 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
689 sb.getBusinessEntity().add(be);
690 BusinessDetail saveBusiness = null;
691 try {
692 saveBusiness = publicationJoe.saveBusiness(sb);
693 } catch (Exception ex) {
694 logger.info("UnExpected failure: ", ex);
695 Assert.fail();
696 }
697
698 SaveService ss = new SaveService();
699 ss.setAuthInfo(authInfoJoe);
700 BusinessService bs = new BusinessService();
701 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
702 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
703 bs.setBindingTemplates(new BindingTemplates());
704 BindingTemplate bt = new BindingTemplate();
705 bt.setBindingKey(null);
706 bt.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
707 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
708
709 bs.getName().add(new Name("Joe's bs", null));
710 DigSigUtil ds = GetDigSig();
711 bt = ds.signUddiEntity(bt);
712 bs.getBindingTemplates().getBindingTemplate().add(bt);
713 be.setBusinessServices(new BusinessServices());
714 be.getBusinessServices().getBusinessService().add(bs);
715
716 sb.getBusinessEntity().add(be);
717 try {
718 publicationJoe.saveService(ss);
719 Assert.fail("unexpected success");
720 } catch (Exception ex) {
721 logger.info("Expected failure: " + ex.getMessage());
722 } finally {
723 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
724 }
725 }
726
727 @Test()
728 public void JUDDI_712_SaveBusinessWithSignature() throws CertificateException {
729 Assume.assumeTrue(TckPublisher.isEnabled());
730 tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
731 SaveBusiness sb = new SaveBusiness();
732 sb.setAuthInfo(authInfoJoe);
733 BusinessEntity be = new BusinessEntity();
734 Name n = new Name();
735 n.setValue("JUDDI_712_SaveBindingWithSignature");
736 be.getName().add(n);
737 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
738 sb.getBusinessEntity().add(be);
739 BusinessDetail saveBusiness = null;
740 try {
741 saveBusiness = publicationJoe.saveBusiness(sb);
742 } catch (Exception ex) {
743 logger.info("UnExpected failure: ", ex);
744 Assert.fail();
745 }
746
747 SaveService ss = new SaveService();
748 ss.setAuthInfo(authInfoJoe);
749 BusinessService bs = new BusinessService();
750 bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
751 bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
752 bs.getName().add(new Name("joe's service", null));
753
754 be.setBusinessServices(new BusinessServices());
755 be.getBusinessServices().getBusinessService().add(bs);
756
757 sb.getBusinessEntity().add(be);
758 ServiceDetail saveService = null;
759 ss.getBusinessService().add(bs);
760 try {
761 saveService = publicationJoe.saveService(ss);
762 } catch (Exception ex) {
763
764 Assert.fail("unexpected failure " + ex.getMessage() + ex.toString());
765 }
766
767 bs = saveService.getBusinessService().get(0);
768 bs.setBindingTemplates(new BindingTemplates());
769 BindingTemplate bt = new BindingTemplate();
770 bt.setBindingKey(null);
771 bt.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
772 bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
773
774 bs.getName().add(new Name("Joe's bs", null));
775 DigSigUtil ds = GetDigSig();
776 bt = ds.signUddiEntity(bt);
777 bs.getBindingTemplates().getBindingTemplate().add(bt);
778
779 try {
780 SaveBinding sb1 = new SaveBinding();
781 sb1.setAuthInfo(authInfoJoe);
782 sb1.getBindingTemplate().add(bt);
783 publicationJoe.saveBinding(sb1);
784 Assert.fail("unexpected success");
785 } catch (Exception ex) {
786 logger.info("Expected failure: " + ex.getMessage());
787 } finally {
788 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
789 }
790 }
791
792
793 @Test()
794 public void JUDDI_716_SaveBusinessWithSignatureX509IssuerSerial() throws CertificateException {
795 Assume.assumeTrue(TckPublisher.isEnabled());
796 SaveBusiness sb = new SaveBusiness();
797 sb.setAuthInfo(authInfoJoe);
798 BusinessEntity be = new BusinessEntity();
799 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
800
801 Name n = new Name();
802 n.setValue("JUDDI_716_SaveBusinessWithSignatureX509IssuerSerial");
803 be.getName().add(n);
804 DigSigUtil ds = GetDigSig();
805 ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SERIAL, "true");
806 be = ds.signUddiEntity(be);
807 sb.getBusinessEntity().add(be);
808 BusinessDetail saveBusiness = null;
809 try {
810 saveBusiness = publicationJoe.saveBusiness(sb);
811 GetBusinessDetail gsb = new GetBusinessDetail();
812 gsb.setAuthInfo(authInfoJoe);
813 gsb.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
814 BusinessDetail businessDetail = inquiryJoe.getBusinessDetail(gsb);
815 PrintUDDI<BusinessEntity> printer = new PrintUDDI<BusinessEntity>();
816 if (TckCommon.isDebug()) {
817 logger.info(printer.print(businessDetail.getBusinessEntity().get(0)));
818 }
819 AtomicReference<String> msg = new AtomicReference<String>();
820 boolean b = ds.verifySignedUddiEntity(businessDetail.getBusinessEntity().get(0), msg);
821 Assert.assertTrue(msg.get(), b);
822 Assert.assertTrue(msg.get() == null || msg.get().length() == 0);
823
824 } catch (Exception ex) {
825 logger.error("unExpected failure: ", ex);
826 Assert.fail("unexpected failure");
827 } finally {
828 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
829 }
830 }
831
832
833 @Test()
834 public void JUDDI_716_SaveBusinessAllOptions() throws CertificateException {
835 Assume.assumeTrue(TckPublisher.isEnabled());
836 SaveBusiness sb = new SaveBusiness();
837 sb.setAuthInfo(authInfoJoe);
838 BusinessEntity be = new BusinessEntity();
839 be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
840
841 Name n = new Name();
842 n.setValue("JUDDI_716_SaveBusinessAllOptions");
843 be.getName().add(n);
844 DigSigUtil ds = GetDigSig();
845 ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SERIAL, "true");
846 ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SUBJECTDN, "true");
847 be = ds.signUddiEntity(be);
848 sb.getBusinessEntity().add(be);
849 BusinessDetail saveBusiness = null;
850 try {
851 saveBusiness = publicationJoe.saveBusiness(sb);
852 GetBusinessDetail gsb = new GetBusinessDetail();
853 gsb.setAuthInfo(authInfoJoe);
854 gsb.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
855 BusinessDetail businessDetail = inquiryJoe.getBusinessDetail(gsb);
856 PrintUDDI<BusinessEntity> printer = new PrintUDDI<BusinessEntity>();
857 if (TckCommon.isDebug()) {
858 logger.info(printer.print(businessDetail.getBusinessEntity().get(0)));
859 }
860 AtomicReference<String> msg = new AtomicReference<String>();
861 boolean b = ds.verifySignedUddiEntity(businessDetail.getBusinessEntity().get(0), msg);
862 Assert.assertTrue(msg.get(), b);
863 Assert.assertTrue(msg.get() == null || msg.get().length() == 0);
864
865 } catch (Exception ex) {
866 logger.error("unExpected failure: ", ex);
867 Assert.fail("unexpected failure");
868 } finally {
869 DeleteBusinesses(saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
870 }
871 }
872
873 org.apache.juddi.v3.client.cryptor.DigSigUtil GetDigSig() throws CertificateException {
874 org.apache.juddi.v3.client.cryptor.DigSigUtil ds = new DigSigUtil(TckPublisher.getProperties());
875
876
877
878
879
880
881
882
883 ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, "true");
884 return ds;
885 }
886 }