This project has retired. For details please refer to its
Attic page.
API_060_PublisherAssertionTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.juddi.api.impl;
16
17
18
19
20
21
22 import java.rmi.RemoteException;
23 import java.security.cert.CertificateException;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.concurrent.atomic.AtomicReference;
27 import javax.xml.bind.JAXB;
28 import javax.xml.ws.Holder;
29
30 import org.apache.commons.configuration.ConfigurationException;
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33 import org.apache.juddi.Registry;
34 import org.apache.juddi.jaxb.EntityCreator;
35 import org.apache.juddi.v3.client.UDDIConstants;
36 import org.apache.juddi.v3.client.cryptor.DigSigUtil;
37 import org.apache.juddi.v3.tck.TckBusiness;
38 import org.apache.juddi.v3.tck.TckCommon;
39 import org.apache.juddi.v3.tck.TckFindEntity;
40 import org.apache.juddi.v3.tck.TckPublisher;
41 import org.apache.juddi.v3.tck.TckPublisherAssertion;
42 import org.apache.juddi.v3.tck.TckSecurity;
43 import org.apache.juddi.v3.tck.TckTModel;
44 import org.junit.AfterClass;
45 import org.junit.Assert;
46 import org.junit.BeforeClass;
47 import org.junit.Test;
48 import org.uddi.api_v3.AddPublisherAssertions;
49 import org.uddi.api_v3.AssertionStatusItem;
50 import org.uddi.api_v3.CompletionStatus;
51 import org.uddi.api_v3.DeletePublisherAssertions;
52 import org.uddi.api_v3.KeyedReference;
53 import org.uddi.api_v3.PublisherAssertion;
54 import org.uddi.v3_service.DispositionReportFaultMessage;
55 import org.uddi.v3_service.UDDISecurityPortType;
56
57 public class API_060_PublisherAssertionTest {
58
59 private static Log logger = LogFactory.getLog(API_060_PublisherAssertionTest.class);
60
61 private static API_010_PublisherTest api010 = new API_010_PublisherTest();
62 private static TckTModel tckTModel = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
63 private static TckBusiness tckBusiness = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl());
64 private static TckPublisherAssertion tckAssertion = new TckPublisherAssertion(new UDDIPublicationImpl());
65 private static TckFindEntity tckFindEntity = new TckFindEntity(new UDDIInquiryImpl());
66 private static String authInfoJoe = null;
67 private static String authInfoSam = null;
68 private static String authInfoMary = null;
69 private static UDDIPublicationImpl pub = new UDDIPublicationImpl();
70
71 @BeforeClass
72 public static void setup() throws Exception {
73 Registry.start();
74 logger.debug("Getting auth token..");
75 try {
76 api010.saveJoePublisher();
77 api010.saveSamSyndicator();
78 UDDISecurityPortType security = new UDDISecurityImpl();
79 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
80 authInfoSam = TckSecurity.getAuthToken(security, TckPublisher.getSamPublisherId(), TckPublisher.getSamPassword());
81 authInfoMary = TckSecurity.getAuthToken(security, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
82 TckCommon.DumpAllTModelsOpInfo(authInfoJoe, new UDDIInquiryImpl());
83 String root = TckSecurity.getAuthToken(security, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
84 tckTModel.saveUDDIPublisherTmodel(root);
85 tckTModel.saveTmodels(root);
86 } catch (RemoteException e) {
87 System.out.println("the test failed, dumping ownership information for all tmodels....");
88
89 logger.error(e.getMessage(), e);
90 Assert.fail("Could not obtain authInfo token." + e.getMessage());
91 }
92 }
93
94 @AfterClass
95 public static void stopRegistry() throws ConfigurationException {
96 Registry.stop();
97 }
98
99 @Test
100 public void testJoepublisherToSamSyndicator() {
101 try {
102 tckTModel.saveJoePublisherTmodel(authInfoJoe);
103 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
104 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
105 tckBusiness.saveSamSyndicatorBusiness(authInfoSam);
106 tckAssertion.saveJoePublisherPublisherAssertion(authInfoJoe);
107 tckAssertion.deleteJoePublisherPublisherAssertion(authInfoJoe);
108 } finally {
109 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
110 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
111 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
112 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
113 }
114 }
115
116
117
118
119
120 @Test
121 public void testFindNoAssertions() {
122 try {
123 tckTModel.saveJoePublisherTmodel(authInfoJoe);
124 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
125 tckTModel.saveMaryPublisherTmodel(authInfoMary);
126 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
127 tckBusiness.saveSamSyndicatorBusiness(authInfoSam);
128 tckBusiness.saveMaryPublisherBusiness(authInfoMary);
129 tckAssertion.saveJoePublisherPublisherAssertion(authInfoJoe);
130 tckAssertion.saveJoePublisherPublisherAssertion2(authInfoJoe);
131
132 tckFindEntity.findRelatedBusiness_sortByName(true);
133 tckFindEntity.findRelatedBusinessToKey(true);
134 tckFindEntity.findRelatedBusinessFromKey(true);
135
136 tckAssertion.deleteJoePublisherPublisherAssertion(authInfoJoe);
137 tckAssertion.deleteJoePublisherPublisherAssertion2(authInfoJoe);
138 } finally {
139 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
140 tckBusiness.deleteMaryPublisherBusiness(authInfoMary);
141 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
142 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
143 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
144 tckTModel.deleteMaryPublisherTmodel(authInfoMary);
145 }
146 }
147
148
149
150
151 @Test
152 public void testFindAssertions() {
153 try {
154 tckTModel.saveJoePublisherTmodel(authInfoJoe);
155 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
156 tckTModel.saveMaryPublisherTmodel(authInfoMary);
157 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
158 tckBusiness.saveSamSyndicatorBusiness(authInfoSam);
159 tckBusiness.saveMaryPublisherBusiness(authInfoMary);
160 tckAssertion.saveJoePublisherPublisherAssertion(authInfoJoe);
161 tckAssertion.saveJoePublisherPublisherAssertion2(authInfoJoe);
162 tckAssertion.saveSamPublisherPublisherAssertion(authInfoSam);
163 tckAssertion.saveMaryPublisherPublisherAssertion(authInfoMary);
164
165 tckFindEntity.findRelatedBusiness_sortByName(false);
166 tckFindEntity.findRelatedBusinessToKey(false);
167 tckFindEntity.findRelatedBusinessFromKey(false);
168
169 tckAssertion.deleteJoePublisherPublisherAssertion(authInfoJoe);
170 tckAssertion.deleteJoePublisherPublisherAssertion2(authInfoJoe);
171
172 } finally {
173 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
174 tckBusiness.deleteMaryPublisherBusiness(authInfoMary);
175 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
176 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
177 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
178 tckTModel.deleteMaryPublisherTmodel(authInfoMary);
179 }
180 }
181
182
183
184
185
186
187
188 @Test(expected = DispositionReportFaultMessage.class)
189 public void deleteAssertionNonowner() throws Exception {
190 try {
191 tckTModel.saveJoePublisherTmodel(authInfoJoe);
192 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
193 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
194 tckBusiness.saveSamSyndicatorBusiness(authInfoSam);
195 tckAssertion.saveJoePublisherPublisherAssertion(authInfoJoe);
196
197 DeletePublisherAssertions dp = new DeletePublisherAssertions();
198 dp.setAuthInfo(authInfoMary);
199
200 PublisherAssertion paIn = (PublisherAssertion) EntityCreator.buildFromDoc(TckPublisherAssertion.JOE_ASSERT_XML, "org.uddi.api_v3");
201 dp.getPublisherAssertion().add(paIn);
202
203 new UDDIPublicationImpl().deletePublisherAssertions(dp);
204
205 } finally {
206 tckAssertion.deleteJoePublisherPublisherAssertion(authInfoJoe);
207 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
208 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
209 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
210 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
211 }
212 }
213
214 @Test
215 public void testSetPublisherAssertions() throws Exception {
216
217
218
219
220 try {
221
222 tckTModel.saveJoePublisherTmodel(authInfoJoe);
223 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
224 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
225 tckBusiness.saveSamSyndicatorBusiness(authInfoSam);
226 Holder<List<PublisherAssertion>> x = new Holder<List<PublisherAssertion>>();
227 x.value = new ArrayList<PublisherAssertion>();
228 logger.info("Clearing all Joe's publisher assertions....");
229 pub.setPublisherAssertions(authInfoJoe, x);
230
231 logger.info("Clearing all Sam's publisher assertions....");
232 pub.setPublisherAssertions(authInfoSam, x);
233
234 logger.info("Confirming we're clear");
235 List<PublisherAssertion> before = pub.getPublisherAssertions(authInfoJoe);
236 Assert.assertNotNull(before);
237 Assert.assertTrue(before.isEmpty());
238 System.out.println(before.size());
239 for (int i = 0; i < before.size(); i++) {
240 JAXB.marshal(before.get(i), System.out);
241 }
242
243 before = pub.getPublisherAssertions(authInfoSam);
244 Assert.assertNotNull(before);
245 Assert.assertTrue(before.isEmpty());
246 System.out.println(before.size());
247 for (int i = 0; i < before.size(); i++) {
248 JAXB.marshal(before.get(i), System.out);
249 }
250
251 List<AssertionStatusItem> assertionStatusReport = pub.getAssertionStatusReport(authInfoJoe, null);
252 Assert.assertTrue(assertionStatusReport.isEmpty());
253
254 assertionStatusReport = pub.getAssertionStatusReport(authInfoSam, null);
255 Assert.assertTrue(assertionStatusReport.isEmpty());
256
257 logger.info("Saving 1/2 publisher assertion....");
258 List<PublisherAssertion> onehalfPA = tckAssertion.saveJoePublisherPublisherAssertion(authInfoJoe);
259
260 before = pub.getPublisherAssertions(authInfoJoe);
261 Assert.assertNotNull(before);
262 Assert.assertFalse(before.isEmpty());
263 System.out.println(before.size());
264 for (int i = 0; i < before.size(); i++) {
265 JAXB.marshal(before.get(i), System.out);
266 }
267
268
269 x = new Holder<List<PublisherAssertion>>();
270 x.value = new ArrayList<PublisherAssertion>();
271 logger.info("Clearing all publisher assertions....");
272 pub.setPublisherAssertions(authInfoJoe, x);
273 System.out.println(x.value.size());
274 for (int i = 0; i < x.value.size(); i++) {
275 JAXB.marshal(x.value.get(i), System.out);
276 }
277
278 logger.info("Fetch all publisher assertions....there should be none");
279 List<PublisherAssertion> publisherAssertions = pub.getPublisherAssertions(authInfoJoe);
280 System.out.println(publisherAssertions.size());
281 for (int i = 0; i < publisherAssertions.size(); i++) {
282 JAXB.marshal(publisherAssertions.get(i), System.out);
283 }
284 Assert.assertNotNull(publisherAssertions);
285 Assert.assertTrue(publisherAssertions.isEmpty());
286
287 } finally {
288
289 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
290 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
291 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
292 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
293 }
294 }
295
296 @Test
297 public void testSetPublisherAssertions2() throws Exception {
298
299
300
301
302 try {
303 tckTModel.saveJoePublisherTmodel(authInfoJoe);
304 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
305 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
306 tckBusiness.saveSamSyndicatorBusiness(authInfoSam);
307 List<PublisherAssertion> onehalfPA = tckAssertion.saveJoePublisherPublisherAssertion(authInfoJoe);
308
309 List<PublisherAssertion> before = pub.getPublisherAssertions(authInfoJoe);
310 Assert.assertNotNull(before);
311 Assert.assertFalse(before.isEmpty());
312
313 pub.setPublisherAssertions(authInfoJoe, new Holder<List<PublisherAssertion>>(onehalfPA));
314 List<PublisherAssertion> publisherAssertions = pub.getPublisherAssertions(authInfoJoe);
315 Assert.assertNotNull(publisherAssertions);
316 Assert.assertFalse(publisherAssertions.isEmpty());
317
318 } finally {
319
320 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
321 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
322 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
323 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
324 }
325 }
326
327 @Test
328 public void testSetPublisherAssertions3() throws Exception {
329
330
331
332 try {
333
334 tckTModel.saveJoePublisherTmodel(authInfoJoe);
335 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
336 tckTModel.saveMaryPublisherTmodel(authInfoMary);
337 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
338 tckBusiness.saveSamSyndicatorBusiness(authInfoSam);
339 tckBusiness.saveMaryPublisherBusiness(authInfoMary);
340 Holder<List<PublisherAssertion>> x = new Holder<List<PublisherAssertion>>();
341 x.value = new ArrayList<PublisherAssertion>();
342 logger.info("Clearing all Joe's publisher assertions....");
343 pub.setPublisherAssertions(authInfoJoe, x);
344
345 logger.info("Clearing all Sam's publisher assertions....");
346 pub.setPublisherAssertions(authInfoSam, x);
347
348 logger.info("Clearing all Mary's publisher assertions....");
349 pub.setPublisherAssertions(authInfoMary, x);
350
351 logger.info("Confirming we're clear");
352 List<PublisherAssertion> before = pub.getPublisherAssertions(authInfoJoe);
353 Assert.assertNotNull(before);
354
355 System.out.println(before.size());
356 for (int i = 0; i < before.size(); i++) {
357 JAXB.marshal(before.get(i), System.out);
358 }
359 Assert.assertTrue(before.isEmpty());
360
361 before = pub.getPublisherAssertions(authInfoSam);
362 Assert.assertNotNull(before);
363
364 System.out.println(before.size());
365 for (int i = 0; i < before.size(); i++) {
366 JAXB.marshal(before.get(i), System.out);
367 }
368 Assert.assertTrue(before.isEmpty());
369
370 before = pub.getPublisherAssertions(authInfoMary);
371 Assert.assertNotNull(before);
372
373 System.out.println(before.size());
374 for (int i = 0; i < before.size(); i++) {
375 JAXB.marshal(before.get(i), System.out);
376 }
377 Assert.assertTrue(before.isEmpty());
378
379 List<AssertionStatusItem> assertionStatusReport = pub.getAssertionStatusReport(authInfoJoe, null);
380 Assert.assertTrue(assertionStatusReport.isEmpty());
381
382 assertionStatusReport = pub.getAssertionStatusReport(authInfoSam, null);
383 Assert.assertTrue(assertionStatusReport.isEmpty());
384
385 assertionStatusReport = pub.getAssertionStatusReport(authInfoMary, null);
386 Assert.assertTrue(assertionStatusReport.isEmpty());
387
388 logger.info("Saving 1/2 publisher assertion....");
389 List<PublisherAssertion> onehalfPA = tckAssertion.saveJoePublisherPublisherAssertion(authInfoJoe);
390
391 before = pub.getPublisherAssertions(authInfoJoe);
392 Assert.assertNotNull(before);
393 Assert.assertFalse(before.isEmpty());
394 System.out.println(before.size());
395 for (int i = 0; i < before.size(); i++) {
396 JAXB.marshal(before.get(i), System.out);
397 }
398
399
400 x = new Holder<List<PublisherAssertion>>();
401 x.value = new ArrayList<PublisherAssertion>();
402 PublisherAssertion pa = new PublisherAssertion();
403
404 pa.setFromKey(TckBusiness.JOE_BUSINESS_KEY);
405 pa.setToKey(TckBusiness.MARY_BUSINESS_KEY);
406 pa.setKeyedReference(new KeyedReference(UDDIConstants.RELATIONSHIPS, "parent-child", "child"));
407
408 x.value.add(pa);
409 logger.info("Using set to clear existing and add a new publisher assertion....");
410 pub.setPublisherAssertions(authInfoJoe, x);
411 System.out.println(x.value.size());
412 for (int i = 0; i < x.value.size(); i++) {
413 JAXB.marshal(x.value.get(i), System.out);
414 }
415
416 logger.info("Fetch all publisher assertions....there should be 1");
417 List<PublisherAssertion> publisherAssertions = pub.getPublisherAssertions(authInfoJoe);
418 System.out.println(publisherAssertions.size());
419 for (int i = 0; i < publisherAssertions.size(); i++) {
420 JAXB.marshal(publisherAssertions.get(i), System.out);
421 }
422 Assert.assertEquals(publisherAssertions.get(0).getFromKey(), pa.getFromKey());
423 Assert.assertEquals(publisherAssertions.get(0).getToKey(), pa.getToKey());
424 Assert.assertEquals(publisherAssertions.get(0).getKeyedReference().getKeyName(), pa.getKeyedReference().getKeyName());
425 Assert.assertEquals(publisherAssertions.get(0).getKeyedReference().getKeyValue(), pa.getKeyedReference().getKeyValue());
426 Assert.assertEquals(publisherAssertions.get(0).getKeyedReference().getTModelKey(), pa.getKeyedReference().getTModelKey());
427
428
429 } finally {
430
431 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
432 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
433 tckBusiness.deleteMaryPublisherBusiness(authInfoMary);
434 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
435 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
436 tckTModel.deleteMaryPublisherTmodel(authInfoMary);
437 }
438
439 }
440 DigSigUtil ds;
441
442 void SetCertStoreSettigns() {
443 ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILE, "./src/test/resources/keystore.jks");
444 ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILETYPE, "JKS");
445 ds.put(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, "Test");
446 ds.put(DigSigUtil.SIGNATURE_KEYSTORE_KEY_ALIAS, "Test");
447 ds.put(DigSigUtil.TRUSTSTORE_FILE, "./src/test/resources/truststore.jks");
448 ds.put(DigSigUtil.TRUSTSTORE_FILETYPE, "JKS");
449 ds.put(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, "Test");
450 }
451
452 void Default() throws CertificateException {
453 ds = new DigSigUtil();
454 SetCertStoreSettigns();
455 ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, "true");
456 }
457
458 @Test
459 public void testPublisherAssertionSignatures() throws Exception {
460 try {
461 Default();
462 tckTModel.saveJoePublisherTmodel(authInfoJoe);
463 tckTModel.saveSamSyndicatorTmodel(authInfoSam);
464 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
465 tckBusiness.saveSamSyndicatorBusiness(authInfoSam);
466 AddPublisherAssertions ap = new AddPublisherAssertions();
467 ap.setAuthInfo(authInfoJoe);
468
469 PublisherAssertion paIn = (PublisherAssertion) EntityCreator.buildFromDoc(TckPublisherAssertion.JOE_ASSERT_XML, "org.uddi.api_v3");
470 paIn = ds.signUddiEntity(paIn);
471
472 ap.getPublisherAssertion().add(paIn);
473 Assert.assertFalse(paIn.getSignature().isEmpty());
474 pub.addPublisherAssertions(ap);
475
476 List<PublisherAssertion> onehalfPA = tckAssertion.saveJoePublisherPublisherAssertion(authInfoJoe);
477
478
479 Assert.assertNotNull(onehalfPA);
480 Assert.assertFalse(onehalfPA.get(0).getSignature().isEmpty());
481 Assert.assertFalse(onehalfPA.isEmpty());
482
483 Assert.assertNotNull(onehalfPA);
484 Assert.assertFalse(onehalfPA.get(0).getSignature().isEmpty());
485 Assert.assertFalse(onehalfPA.isEmpty());
486 Assert.assertEquals(paIn.getSignature().size(),onehalfPA.get(0).getSignature().size());
487 Assert.assertEquals(paIn.getSignature().get(0).getId(),onehalfPA.get(0).getSignature().get(0).getId());
488 Assert.assertEquals(paIn.getSignature().get(0).getKeyInfo().getId(),onehalfPA.get(0).getSignature().get(0).getKeyInfo().getId());
489 Assert.assertEquals(paIn.getSignature().get(0).getKeyInfo().getContent().size(),onehalfPA.get(0).getSignature().get(0).getKeyInfo().getContent().size());
490
491 Assert.assertEquals(paIn.getSignature().get(0).getSignedInfo().getCanonicalizationMethod().getAlgorithm(),onehalfPA.get(0).getSignature().get(0).getSignedInfo().getCanonicalizationMethod().getAlgorithm());
492 Assert.assertEquals(paIn.getSignature().get(0).getSignedInfo().getId(),onehalfPA.get(0).getSignature().get(0).getSignedInfo().getId());
493 Assert.assertEquals(paIn.getSignature().get(0).getSignedInfo().getReference().size(),onehalfPA.get(0).getSignature().get(0).getSignedInfo().getReference().size());
494 AtomicReference<String> outmsg=new AtomicReference<String>();
495 boolean success=ds.verifySignedUddiEntity(onehalfPA.get(0), outmsg);
496 Assert.assertTrue(outmsg.get(), success);
497
498
499 } finally {
500
501 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
502 tckBusiness.deleteSamSyndicatorBusiness(authInfoSam);
503 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
504 tckTModel.deleteSamSyndicatorTmodel(authInfoSam);
505 }
506 }
507 }