This project has retired. For details please refer to its
Attic page.
UddiAdminHub xref
1 package org.apache.juddi.adminconsole.hub;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.io.InputStream;
20 import java.io.StringReader;
21 import java.io.StringWriter;
22 import java.math.BigInteger;
23 import java.net.URL;
24 import java.rmi.RemoteException;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Properties;
29 import java.util.logging.Level;
30 import java.util.logging.Logger;
31 import javax.persistence.EntityManager;
32 import javax.persistence.EntityTransaction;
33 import javax.persistence.Query;
34 import javax.servlet.ServletContext;
35 import javax.servlet.http.HttpServletRequest;
36 import javax.servlet.http.HttpSession;
37 import javax.xml.XMLConstants;
38 import javax.xml.bind.JAXB;
39 import javax.xml.datatype.DatatypeConfigurationException;
40 import javax.xml.parsers.DocumentBuilder;
41 import javax.xml.parsers.DocumentBuilderFactory;
42 import javax.xml.transform.OutputKeys;
43 import javax.xml.transform.Transformer;
44 import javax.xml.transform.TransformerFactory;
45 import javax.xml.transform.dom.DOMSource;
46 import javax.xml.transform.stream.StreamResult;
47 import javax.xml.transform.stream.StreamSource;
48 import javax.xml.ws.BindingProvider;
49 import javax.xml.ws.Holder;
50 import org.apache.commons.configuration.Configuration;
51 import org.apache.commons.configuration.ConfigurationException;
52 import org.apache.commons.lang.StringEscapeUtils;
53 import org.apache.commons.logging.Log;
54 import org.apache.commons.logging.LogFactory;
55 import org.apache.juddi.api_v3.Clerk;
56 import org.apache.juddi.api_v3.ClientSubscriptionInfoDetail;
57 import org.apache.juddi.api_v3.DeleteClientSubscriptionInfo;
58 import org.apache.juddi.api_v3.DeletePublisher;
59 import org.apache.juddi.api_v3.GetAllPublisherDetail;
60 import org.apache.juddi.api_v3.GetPublisherDetail;
61 import org.apache.juddi.api_v3.Node;
62 import org.apache.juddi.api_v3.Publisher;
63 import org.apache.juddi.api_v3.PublisherDetail;
64 import org.apache.juddi.api_v3.SaveClerk;
65 import org.apache.juddi.api_v3.SaveClientSubscriptionInfo;
66 import org.apache.juddi.api_v3.SaveNode;
67 import org.apache.juddi.api_v3.SavePublisher;
68 import org.apache.juddi.api_v3.SyncSubscription;
69 import org.apache.juddi.api_v3.SyncSubscriptionDetail;
70 import org.apache.juddi.v3.client.UDDIConstants;
71 import org.apache.juddi.v3.client.config.ClientConfig;
72 import org.apache.juddi.v3.client.config.UDDIClient;
73 import org.apache.juddi.v3.client.config.UDDINode;
74 import org.apache.juddi.v3.client.transport.Transport;
75 import org.apache.juddi.v3_service.JUDDIApiPortType;
76 import org.apache.juddi.adminconsole.AES;
77 import org.apache.juddi.adminconsole.resources.ResourceLoader;
78 import org.apache.juddi.api.impl.JUDDIApiImpl;
79 import org.apache.juddi.api.impl.UDDIInquiryImpl;
80 import org.apache.juddi.api.impl.UDDIPublicationImpl;
81 import org.apache.juddi.api.impl.UDDIReplicationImpl;
82 import org.apache.juddi.api_v3.AdminSaveBusiness;
83 import org.apache.juddi.api_v3.AdminSaveSubscriptionRequest;
84 import org.apache.juddi.api_v3.AdminSaveSubscriptionResponse;
85 import org.apache.juddi.api_v3.AdminSaveTModel;
86 import org.apache.juddi.api_v3.ClerkList;
87 import org.apache.juddi.api_v3.ClientSubscriptionInfo;
88 import org.apache.juddi.api_v3.DeleteClerk;
89 import org.apache.juddi.api_v3.DeleteNode;
90 import org.apache.juddi.api_v3.GetEntityHistoryMessageRequest;
91 import org.apache.juddi.api_v3.GetEntityHistoryMessageResponse;
92 import org.apache.juddi.api_v3.GetFailedReplicationChangeRecordsMessageRequest;
93 import org.apache.juddi.api_v3.GetFailedReplicationChangeRecordsMessageResponse;
94 import org.apache.juddi.api_v3.NodeList;
95 import org.apache.juddi.api_v3.SubscriptionWrapper;
96 import org.apache.juddi.config.AppConfig;
97 import org.apache.juddi.config.PersistenceManager;
98 import org.apache.juddi.config.Property;
99 import org.apache.juddi.model.BindingTemplate;
100 import org.apache.juddi.subscription.notify.SMTPNotifier;
101 import org.apache.juddi.v3.client.cryptor.XmlUtils;
102 import org.uddi.api_v3.AuthToken;
103 import org.uddi.api_v3.BusinessDetail;
104 import org.uddi.api_v3.BusinessEntity;
105 import org.uddi.api_v3.BusinessService;
106 import org.uddi.api_v3.DeleteBusiness;
107 import org.uddi.api_v3.DeleteTModel;
108 import org.uddi.api_v3.DiscardAuthToken;
109 import org.uddi.api_v3.DispositionReport;
110 import org.uddi.api_v3.FindBusiness;
111 import org.uddi.api_v3.FindQualifiers;
112 import org.uddi.api_v3.GetAuthToken;
113 import org.uddi.api_v3.GetBusinessDetail;
114 import org.uddi.api_v3.Name;
115 import org.uddi.api_v3.SaveBusiness;
116 import org.uddi.repl_v3.ChangeRecordIDType;
117 import org.uddi.repl_v3.ChangeRecords;
118 import org.uddi.repl_v3.GetChangeRecords;
119 import org.uddi.repl_v3.HighWaterMarkVectorType;
120 import org.uddi.repl_v3.ReplicationConfiguration;
121 import org.uddi.sub_v3.Subscription;
122 import org.uddi.sub_v3.SubscriptionResultsList;
123 import org.uddi.subr_v3.NotifySubscriptionListener;
124
125 import org.uddi.v3_service.DispositionReportFaultMessage;
126 import org.uddi.v3_service.UDDISecurityPortType;
127 import org.w3c.dom.Document;
128 import org.xml.sax.InputSource;
129
130
131
132
133
134
135
136
137
138 public class UddiAdminHub {
139
140
141
142
143 public static final String LOGGER_NAME = "org.apache.juddi";
144 transient AuthStyle style = null;
145 Properties properties = null;
146
147
148
149
150 public static final Log log = LogFactory.getLog(LOGGER_NAME);
151
152 private UddiAdminHub() throws DatatypeConfigurationException {
153
154 }
155
156
157
158
159
160
161 public static void reset(HttpSession _session) {
162 _session.removeAttribute("hub");
163
164 }
165
166
167
168
169
170 public void die() {
171 if (token != null && security != null) {
172 DiscardAuthToken da = new DiscardAuthToken();
173 da.setAuthInfo(token);
174 try {
175 security.discardAuthToken(da);
176 } catch (Exception ex) {
177 HandleException(ex);
178 }
179 }
180 token = null;
181 security = null;
182 juddi = null;
183 }
184
185
186
187 public static final String PROP_CONFIG_NODE = "config.props.node";
188
189
190
191 public static final String PROP_AUTH_TYPE = "config.props.authtype";
192
193
194
195 public static final String PROP_AUTO_LOGOUT = "config.props.automaticLogouts.enable";
196
197
198
199 public static final String PROP_AUTO_LOGOUT_TIMER = "config.props.automaticLogouts.duration";
200
201
202
203 public static final String PROP_PREFIX = "config.props.";
204
205
206
207
208 public static final String PROP_ADMIN_LOCALHOST_ONLY = "config.props.configLocalHostOnly";
209
210 private transient UDDISecurityPortType security = null;
211 private transient JUDDIApiPortType juddi = null;
212 private transient String token = null;
213 private transient HttpSession session;
214 private transient Transport transport = null;
215 private transient ClientConfig clientConfig;
216 private static final long serialVersionUID = 1L;
217 private String nodename = "default";
218 private final String clientName = "juddigui";
219 private boolean WS_Transport = false;
220 private boolean WS_securePorts = false;
221
222
223
224
225
226
227
228
229
230
231 public static UddiAdminHub getInstance(ServletContext application, HttpSession _session) throws Exception {
232 Object j = _session.getAttribute("hub");
233 if (j == null) {
234 UddiAdminHub hub = new UddiAdminHub(application, _session);
235 _session.setAttribute("hub", hub);
236 return hub;
237 }
238
239 return (UddiAdminHub) j;
240 }
241 String locale = "en";
242
243 private UddiAdminHub(ServletContext application, HttpSession _session) throws Exception {
244 URL prop = application.getResource("/WEB-INF/config.properties");
245 if (prop == null) {
246 application.getResource("WEB-INF/config.properties");
247 }
248 if (prop == null) {
249 throw new Exception("Cannot locate the configuration file.");
250 }
251 session = _session;
252
253 InputStream in = prop.openStream();
254 Properties p = new Properties();
255 p.load(in);
256 in.close();
257 session = _session;
258 properties = p;
259 EnsureConfig();
260 }
261
262 private void EnsureConfig() {
263 if (clientConfig == null) {
264 try {
265 UDDIClient client = new UDDIClient();
266
267 clientConfig = client.getClientConfig();
268 try {
269 style = AuthStyle.valueOf(clientConfig.getConfiguration().getString(PROP_AUTH_TYPE));
270 } catch (Exception ex) {
271 log.warn("'UDDI_AUTH' is not defined in the config (" + PROP_AUTH_TYPE + ")! defaulting to UDDI_AUTH");
272 style = AuthStyle.UDDI_AUTH;
273 }
274
275 nodename = clientConfig.getConfiguration().getString(PROP_CONFIG_NODE);
276 if (nodename == null || nodename.equals("")) {
277 log.warn("'node' is not defined in the config! defaulting to 'default'");
278 nodename = "default";
279 }
280 UDDINode uddiNode = clientConfig.getUDDINode(nodename);
281
282 String clazz = uddiNode.getProxyTransport();
283 if (clazz.contains("JAXWSTransport")) {
284 WS_Transport = true;
285 }
286
287 transport = client.getTransport(nodename);
288 security = transport.getUDDISecurityService();
289 juddi = transport.getJUDDIApiService();
290 if (WS_Transport) {
291 if (uddiNode.getJuddiApiUrl().toLowerCase().startsWith("https://")
292 && (uddiNode.getSecurityUrl() != null && uddiNode.getSecurityUrl().toLowerCase().startsWith("https://"))) {
293 WS_securePorts = true;
294 }
295 }
296
297 } catch (Exception ex) {
298 HandleException(ex);
299 }
300 }
301
302 }
303
304
305
306
307
308
309
310
311
312 private String HandleException(Exception ex) {
313 if (ex instanceof DispositionReportFaultMessage) {
314 DispositionReportFaultMessage f = (DispositionReportFaultMessage) ex;
315 log.error(ex.getMessage() + (f.detail != null && f.detail.getMessage() != null ? StringEscapeUtils.escapeHtml(f.detail.getMessage()) : ""));
316 log.debug(ex.getMessage(), ex);
317 return ResourceLoader.GetResource(session, "errors.generic") + " " + StringEscapeUtils.escapeHtml(ex.getMessage()) + " " + (f.detail != null && f.detail.getMessage() != null ? StringEscapeUtils.escapeHtml(f.detail.getMessage()) : "");
318 } else if (ex instanceof RemoteException) {
319 RemoteException f = (RemoteException) ex;
320 log.error("RemoteException " + ex.getMessage());
321 log.debug("RemoteException " + ex.getMessage(), ex);
322 return ResourceLoader.GetResource(session, "errors.generic") + " " + StringEscapeUtils.escapeHtml(ex.getMessage()) + " " + (f.detail != null && f.detail.getMessage() != null ? StringEscapeUtils.escapeHtml(f.detail.getMessage()) : "");
323 } else if (ex instanceof NullPointerException) {
324 log.error("NPE! Please report! " + ex.getMessage(), ex);
325 log.debug("NPE! Please report! " + ex.getMessage(), ex);
326 return ResourceLoader.GetResource(session, "errors.generic") + " " + StringEscapeUtils.escapeHtml(ex.getMessage());
327 } else {
328 log.error("Unexpected error " + ex.getMessage(), ex);
329
330 return ResourceLoader.GetResource(session, "errors.generic") + " " + StringEscapeUtils.escapeHtml(ex.getMessage());
331 }
332 }
333
334
335
336
337
338
339
340 public boolean isSecure() {
341
342 EnsureConfig();
343 return WS_securePorts;
344 }
345
346
347
348
349
350
351
352
353 public ClientConfig GetJuddiClientConfig() throws ConfigurationException {
354 EnsureConfig();
355 return clientConfig;
356 }
357
358
359
360
361
362
363
364 public String go(HttpServletRequest parameters) {
365 try {
366 String action = parameters.getParameter("soapaction");
367 if (action.equalsIgnoreCase("adminDelete_tmodel")) {
368 return adminDelete_tmodel(parameters);
369 } else if (action.equalsIgnoreCase("delete_ClientSubscriptionInfo")) {
370 return delete_ClientSubscriptionInfo(parameters);
371 } else if (action.equalsIgnoreCase("delete_publisher")) {
372 return delete_publisher(parameters);
373 } else if (action.equalsIgnoreCase("getAllPublisherDetail")) {
374 return getAllPublisherDetail(parameters);
375 } else if (action.equalsIgnoreCase("get_publisherDetail")) {
376 return get_publisherDetail(parameters);
377 } else if (action.equalsIgnoreCase("invoke_SyncSubscription")) {
378 return invoke_SyncSubscription(parameters);
379 } else if (action.equalsIgnoreCase("save_Clerk")) {
380 return save_Clerk(parameters);
381 } else if (action.equalsIgnoreCase("save_ClientSubscriptionInfo")) {
382 return save_ClientSubscriptionInfo(parameters);
383 } else if (action.equalsIgnoreCase("save_Node")) {
384 return save_Node(parameters);
385 } else if (action.equalsIgnoreCase("save_publisher")) {
386 return save_publisher(parameters);
387 } else if (action.equalsIgnoreCase("send_EmailTest")) {
388 return sendTestEmail(parameters);
389 } else if (action.equalsIgnoreCase("get_AllNodes")) {
390 return getAllNodes(parameters);
391 } else if (action.equalsIgnoreCase("get_AllClerks")) {
392 return getAllClerks(parameters);
393 } else if (action.equalsIgnoreCase("delete_Node")) {
394 return deleteNode(parameters);
395 } else if (action.equalsIgnoreCase("delete_Clerk")) {
396 return deleteClerk(parameters);
397 } else if (action.equalsIgnoreCase("admin_DeleteSubscription")) {
398 return deleteSubscription(parameters);
399 } else if (action.equalsIgnoreCase("admin_SaveBusiness")) {
400 return adminSaveBusiness(parameters);
401 } else if (action.equalsIgnoreCase("admin_SaveTModel")) {
402 return adminSaveTmodel(parameters);
403 } else if (action.equalsIgnoreCase("get_AllClientSubscriptionInfo")) {
404 return getAllClientSubscriptionInfo(parameters);
405 } else if (action.equalsIgnoreCase("set_ReplicationNodes")) {
406 return setReplicationConfig(parameters);
407 } else if (action.equalsIgnoreCase("get_ReplicationNodes")) {
408 return getReplicationNodes(parameters);
409 } else if (action.equalsIgnoreCase("admin_SaveSubscription")) {
410 return adminSaveSubscription(parameters);
411 } else if (action.equalsIgnoreCase("get_EntityHistory")) {
412 return getEntityHistory(parameters);
413 } else if (action.equalsIgnoreCase("change_NodeID")) {
414 return change_NodeID(parameters);
415 } else if (action.equalsIgnoreCase("changeRecord")) {
416 return getChangeRecord(parameters);
417 } else if (action.equalsIgnoreCase("getFailedReplicationChangeRecords")) {
418 return getFailedReplicationChangeRecords(parameters);
419 }
420
421 } catch (Exception ex) {
422 return "Error!" + HandleException(ex);
423 }
424 return "not yet implemented!";
425 }
426
427 private String save_Clerk(HttpServletRequest parameters) {
428 SaveClerk sc = new SaveClerk();
429 sc.setAuthInfo(GetToken());
430 Clerk c = new Clerk();
431 c.setName(parameters.getParameter("CLERKsetName"));
432 Node node = new Node();
433 node.setClientName(parameters.getParameter("CLERKNODEsetClientName"));
434 node.setCustodyTransferUrl(parameters.getParameter("CLERKNODEsetCustodyTransferUrl"));
435 node.setDescription(parameters.getParameter("CLERKNODEsetDescription"));
436 node.setFactoryInitial(parameters.getParameter("CLERKNODEsetFactoryInitial"));
437 node.setFactoryNamingProvider(parameters.getParameter("CLERKNODEsetFactoryNamingProvider"));
438 node.setFactoryURLPkgs(parameters.getParameter("CLERKNODEsetFactoryURLPkgs"));
439 node.setInquiryUrl(parameters.getParameter("CLERKNODEsetInquiryUrl"));
440 node.setJuddiApiUrl(parameters.getParameter("CLERKNODEsetJuddiApiUrl"));
441 node.setName(parameters.getParameter("CLERKNODEsetName"));
442 node.setProxyTransport(parameters.getParameter("CLERKNODEsetProxyTransport"));
443 node.setPublishUrl(parameters.getParameter("CLERKNODEsetPublishUrl"));
444 node.setReplicationUrl(parameters.getParameter("CLERKNODEsetReplicationUrl"));
445 node.setSecurityUrl(parameters.getParameter("CLERKNODEsetSecurityUrl"));
446 node.setSubscriptionListenerUrl(parameters.getParameter("CLERKNODEsetSubscriptionListenerUrl"));
447 node.setSubscriptionUrl(parameters.getParameter("CLERKNODEsetSubscriptionUrl"));
448 c.setNode(node);
449 c.setPassword(parameters.getParameter("CLERKsetPassword"));
450 c.setPublisher(parameters.getParameter("CLERKsetPublisher"));
451
452 sc.getClerk().add(c);
453 try {
454 juddi.saveClerk(sc);
455 } catch (Exception ex) {
456 if (isExceptionExpiration(ex)) {
457 token = null;
458 sc.setAuthInfo(GetToken());
459 try {
460 juddi.saveClerk(sc);
461 } catch (Exception ex1) {
462 return "Error!" + HandleException(ex1);
463 }
464
465 } else {
466 return "Error!" + HandleException(ex);
467 }
468 }
469 return "Success";
470 }
471
472 private String save_Node(HttpServletRequest parameters) {
473 SaveNode sn = new SaveNode();
474 sn.setAuthInfo(GetToken());
475 Node node = new Node();
476 node.setClientName(parameters.getParameter("NODEsetClientName"));
477 node.setCustodyTransferUrl(parameters.getParameter("NODEsetCustodyTransferUrl"));
478 node.setDescription(parameters.getParameter("NODEsetDescription"));
479 node.setFactoryInitial(parameters.getParameter("NODEsetFactoryInitial"));
480 node.setFactoryNamingProvider(parameters.getParameter("NODEsetFactoryNamingProvider"));
481 node.setFactoryURLPkgs(parameters.getParameter("NODEsetFactoryURLPkgs"));
482 node.setInquiryUrl(parameters.getParameter("NODEsetInquiryUrl"));
483 node.setJuddiApiUrl(parameters.getParameter("NODEsetJuddiApiUrl"));
484 node.setName(parameters.getParameter("NODEsetName"));
485 node.setProxyTransport(parameters.getParameter("NODEsetProxyTransport"));
486 node.setPublishUrl(parameters.getParameter("NODEsetPublishUrl"));
487 node.setReplicationUrl(parameters.getParameter("NODEsetReplicationUrl"));
488 node.setSecurityUrl(parameters.getParameter("NODEsetSecurityUrl"));
489 node.setSubscriptionListenerUrl(parameters.getParameter("NODEsetSubscriptionListenerUrl"));
490 node.setSubscriptionUrl(parameters.getParameter("NODEsetSubscriptionUrl"));
491 sn.getNode().add(node);
492
493 try {
494 juddi.saveNode(sn);
495 } catch (Exception ex) {
496 if (isExceptionExpiration(ex)) {
497 token = null;
498 sn.setAuthInfo(GetToken());
499 try {
500 juddi.saveNode(sn);
501 } catch (Exception ex1) {
502 return "Error!" + HandleException(ex1);
503 }
504
505 } else {
506 return "Error!" + HandleException(ex);
507 }
508 }
509 return "Success";
510 }
511
512 private String sendTestEmail(HttpServletRequest parameters) {
513 try {
514
515 String to = parameters.getParameter("send_EmailTestEMAIL");
516 if (!to.startsWith("mailto:")) {
517 to = "mailto:" + to;
518 }
519 BindingTemplate modellbt = new BindingTemplate("test", null, "endpoint", to, null, null, null, null, null);
520 org.apache.juddi.subscription.notify.SMTPNotifier smtp = new SMTPNotifier(modellbt);
521 NotifySubscriptionListener body = new NotifySubscriptionListener();
522
523 body.setSubscriptionResultsList(new SubscriptionResultsList());
524 body.getSubscriptionResultsList().setSubscription(new Subscription());
525 body.getSubscriptionResultsList().getSubscription().setSubscriptionKey("TEST");
526 smtp.notifySubscriptionListener(body);
527 return "Success";
528 } catch (Exception ex) {
529 return "Failure!" + HandleException(ex);
530 }
531 }
532
533 private String getAllNodes(HttpServletRequest parameters) {
534 NodeList allNodes = null;
535 try {
536
537 allNodes = juddi.getAllNodes(GetToken());
538 } catch (Exception ex) {
539
540 if (isExceptionExpiration(ex)) {
541 token = null;
542 try {
543 allNodes = juddi.getAllNodes(GetToken());
544 } catch (Exception ex1) {
545 return HandleException(ex1);
546 }
547 } else {
548 return HandleException(ex);
549 }
550 }
551 try {
552 return PrettyPrintJaxbObject(allNodes);
553 } catch (Exception ex) {
554 return HandleException(ex);
555 }
556
557 }
558
559 private String getAllClerks(HttpServletRequest parameters) {
560 ClerkList allNodes = null;
561 try {
562
563 allNodes = juddi.getAllClerks(GetToken());
564 } catch (Exception ex) {
565
566 if (isExceptionExpiration(ex)) {
567 token = null;
568 try {
569 allNodes = juddi.getAllClerks(GetToken());
570 } catch (Exception ex1) {
571 return HandleException(ex1);
572 }
573 } else {
574 return HandleException(ex);
575 }
576 }
577 try {
578 return PrettyPrintJaxbObject(allNodes);
579 } catch (Exception ex) {
580 return HandleException(ex);
581 }
582 }
583
584 private String getAllClientSubscriptionInfo(HttpServletRequest parameters) {
585 List<SubscriptionWrapper> allClientSubscriptionInfo = null;
586 try {
587
588 allClientSubscriptionInfo = juddi.getAllClientSubscriptionInfo(GetToken());
589 } catch (Exception ex) {
590
591 if (isExceptionExpiration(ex)) {
592 token = null;
593 try {
594 allClientSubscriptionInfo = juddi.getAllClientSubscriptionInfo(GetToken());
595 } catch (Exception ex1) {
596 return HandleException(ex1);
597 }
598 } else {
599 return HandleException(ex);
600 }
601 }
602 try {
603 return PrettyPrintJaxbObject(allClientSubscriptionInfo);
604 } catch (Exception ex) {
605 return HandleException(ex);
606 }
607 }
608
609 private String getReplicationNodes(HttpServletRequest parameters) {
610 ReplicationConfiguration cfg = null;
611 try {
612
613 cfg = juddi.getReplicationNodes(GetToken());
614 } catch (Exception ex) {
615
616 if (isExceptionExpiration(ex)) {
617 token = null;
618 try {
619 cfg = juddi.getReplicationNodes(GetToken());
620 } catch (Exception ex1) {
621 return HandleException(ex1);
622 }
623 } else {
624 return HandleException(ex);
625 }
626 }
627 try {
628 return PrettyPrintJaxbObject(cfg);
629 } catch (Exception ex) {
630 return HandleException(ex);
631 }
632 }
633
634 private String deleteNode(HttpServletRequest parameters) {
635 DeleteNode cfg = new DeleteNode();
636 cfg.setAuthInfo(GetToken());
637 cfg.setNodeID(parameters.getParameter("delete_NodeName"));
638 try {
639
640 juddi.deleteNode(cfg);
641 } catch (Exception ex) {
642
643 if (isExceptionExpiration(ex)) {
644 token = null;
645 try {
646 cfg.setAuthInfo(GetToken());
647 juddi.deleteNode(cfg);
648 } catch (Exception ex1) {
649 return HandleException(ex1);
650 }
651 } else {
652 return HandleException(ex);
653 }
654 }
655
656 return "Success";
657 }
658
659 private String deleteSubscription(HttpServletRequest parameters) {
660 List<String> keys = new ArrayList<String>();
661 keys.add(parameters.getParameter("admin_DeleteSubscriptionKey"));
662 try {
663
664 juddi.adminDeleteSubscription(GetToken(), keys);
665 } catch (Exception ex) {
666
667 if (isExceptionExpiration(ex)) {
668 token = null;
669 try {
670 juddi.adminDeleteSubscription(GetToken(), keys);
671 } catch (Exception ex1) {
672 return HandleException(ex1);
673 }
674 } else {
675 return HandleException(ex);
676 }
677 }
678
679 return "Success";
680 }
681
682 private String deleteClerk(HttpServletRequest parameters) {
683 DeleteClerk cfg = new DeleteClerk();
684 cfg.setAuthInfo(GetToken());
685 cfg.setClerkID(parameters.getParameter("delete_ClerkName"));
686 try {
687
688 juddi.deleteClerk(cfg);
689 } catch (Exception ex) {
690
691 if (isExceptionExpiration(ex)) {
692 token = null;
693 try {
694 cfg.setAuthInfo(GetToken());
695 juddi.deleteClerk(cfg);
696 } catch (Exception ex1) {
697 return HandleException(ex1);
698 }
699 } else {
700 return HandleException(ex);
701 }
702 }
703
704 return "Success";
705 }
706
707 private String setReplicationConfig(HttpServletRequest parameters) {
708 ReplicationConfiguration cfg = (ReplicationConfiguration) JUDDIRequestsAsXML.getObjectJuddi("set_ReplicationNodes", parameters.getParameter("set_ReplicationNodesXML"));
709 DispositionReport setReplicationNodes = null;
710 try {
711
712 setReplicationNodes = juddi.setReplicationNodes(GetToken(), cfg);
713 } catch (Exception ex) {
714
715 if (isExceptionExpiration(ex)) {
716 token = null;
717 try {
718 setReplicationNodes = juddi.setReplicationNodes(GetToken(), cfg);
719 } catch (Exception ex1) {
720 return HandleException(ex1);
721 }
722 } else {
723 return HandleException(ex);
724 }
725 }
726 try {
727 return PrettyPrintJaxbObject(setReplicationNodes);
728 } catch (Exception ex) {
729 return HandleException(ex);
730 }
731 }
732
733 private String adminSaveBusiness(HttpServletRequest parameters) {
734
735 AdminSaveBusiness cfg = (AdminSaveBusiness) JUDDIRequestsAsXML.getObjectJuddi("admin_SaveBusiness", parameters.getParameter("admin_SaveBusinessXML"));
736 DispositionReport setReplicationNodes = null;
737 try {
738
739 setReplicationNodes = juddi.adminSaveBusiness(GetToken(), cfg.getValues());
740 } catch (Exception ex) {
741
742 if (isExceptionExpiration(ex)) {
743 token = null;
744 try {
745 setReplicationNodes = juddi.adminSaveBusiness(GetToken(), cfg.getValues());
746 } catch (Exception ex1) {
747 return HandleException(ex1);
748 }
749 } else {
750 return HandleException(ex);
751 }
752 }
753 try {
754 return PrettyPrintJaxbObject(setReplicationNodes);
755 } catch (Exception ex) {
756 return HandleException(ex);
757 }
758 }
759
760 private String adminSaveTmodel(HttpServletRequest parameters) {
761
762 AdminSaveTModel cfg = (AdminSaveTModel) JUDDIRequestsAsXML.getObjectJuddi("admin_SaveTModel", parameters.getParameter("admin_SaveTModelXML"));
763
764 DispositionReport setReplicationNodes = null;
765 try {
766
767 setReplicationNodes = juddi.adminSaveTModel(GetToken(), cfg.getValues());
768 } catch (Exception ex) {
769
770 if (isExceptionExpiration(ex)) {
771 token = null;
772 try {
773 setReplicationNodes = juddi.adminSaveTModel(GetToken(), cfg.getValues());
774 } catch (Exception ex1) {
775 return HandleException(ex1);
776 }
777 } else {
778 return HandleException(ex);
779 }
780 }
781 try {
782 return PrettyPrintJaxbObject(setReplicationNodes);
783 } catch (Exception ex) {
784 return HandleException(ex);
785 }
786 }
787
788 private String adminSaveSubscription(HttpServletRequest parameters) {
789
790 AdminSaveSubscriptionRequest cfg = (AdminSaveSubscriptionRequest) JUDDIRequestsAsXML.getObjectJuddi("admin_SaveSubscription", parameters.getParameter("admin_SaveSubscriptionXML"));
791
792 Holder<List<Subscription>> holder = new Holder<List<Subscription>>(cfg.getSubscriptions());
793 try {
794
795 juddi.adminSaveSubscription(GetToken(), cfg.getPublisherOrUsername(), holder);
796 } catch (Exception ex) {
797
798 if (isExceptionExpiration(ex)) {
799 token = null;
800 try {
801 juddi.adminSaveSubscription(GetToken(), cfg.getPublisherOrUsername(), holder);
802 } catch (Exception ex1) {
803 return HandleException(ex1);
804 }
805 } else {
806 return HandleException(ex);
807 }
808 }
809 AdminSaveSubscriptionResponse res = new AdminSaveSubscriptionResponse();
810 res.getSubscriptions().addAll(holder.value);
811 try {
812 return PrettyPrintJaxbObject(res);
813 } catch (Exception ex) {
814 return HandleException(ex);
815 }
816 }
817
818 private String getEntityHistory(HttpServletRequest parameters) {
819 GetEntityHistoryMessageRequest sn = new GetEntityHistoryMessageRequest();
820 sn.setAuthInfo(GetToken());
821 sn.setEntityKey(parameters.getParameter("get_EntityHistoryKey"));
822 GetEntityHistoryMessageResponse entityHistory = null;
823 try {
824 sn.setMaxRecords(Long.parseLong(parameters.getParameter("get_EntityHistoryMaxCount")));
825 sn.setOffset(Long.parseLong(parameters.getParameter("get_EntityHistoryOffset")));
826 entityHistory = juddi.getEntityHistory(sn);
827 } catch (Exception ex) {
828 if (isExceptionExpiration(ex)) {
829 token = null;
830 sn.setAuthInfo(GetToken());
831 try {
832 entityHistory = juddi.getEntityHistory(sn);
833 } catch (Exception ex1) {
834 return "Error!" + HandleException(ex1);
835 }
836
837 } else {
838 return "Error!" + HandleException(ex);
839 }
840 }
841 if (entityHistory == null) {
842 return "Something went wrong!";
843 }
844 try {
845 return PrettyPrintJaxbObject(entityHistory);
846 } catch (Exception ex) {
847 return HandleException(ex);
848 }
849
850 }
851
852 private String change_NodeID(HttpServletRequest parameters) {
853
854
855 EntityManager em = PersistenceManager.getEntityManager();
856 EntityTransaction tx = em.getTransaction();
857
858 try {
859
860 ReplicationConfiguration replicationNodes = new JUDDIApiImpl().getReplicationNodes(GetToken());
861 if (replicationNodes.getOperator().size() > 1) {
862 throw new Exception("Replication is configured with " + replicationNodes.getOperator() + " nodes. Node rename aborted");
863 }
864 Configuration configuration = AppConfig.getConfiguration();
865
866 String currentnode = configuration.getString(Property.JUDDI_NODE_ID);
867 String newnode = parameters.getParameter("change_NodeIDKey");
868 if (newnode == null) {
869 throw new Exception("The new node id was not specified");
870 }
871 newnode = newnode.trim();
872 newnode = newnode.toLowerCase();
873 log.warn("AUDIT - Renaming Node ID from " + currentnode + " to " + newnode);
874
875 UDDIPublicationImpl pub = new UDDIPublicationImpl();
876 UDDIInquiryImpl inquire = new UDDIInquiryImpl();
877
878 GetBusinessDetail gbd = new GetBusinessDetail();
879 gbd.setAuthInfo(GetToken());
880 gbd.getBusinessKey().add(newnode);
881 BusinessDetail businessDetail = null;
882 try {
883 businessDetail = inquire.getBusinessDetail(gbd);
884 } catch (Exception ex) {
885
886 }
887 if (businessDetail == null || businessDetail.getBusinessEntity().isEmpty()) {
888
889
890 gbd.getBusinessKey().clear();
891 gbd.getBusinessKey().add(AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ROOT_BUSINESS));
892 businessDetail = inquire.getBusinessDetail(gbd);
893 BusinessEntity get = businessDetail.getBusinessEntity().get(0);
894 get.setBusinessKey(newnode);
895 get.getSignature().clear();
896 if (get.getBusinessServices() != null) {
897 for (BusinessService bs : get.getBusinessServices().getBusinessService()) {
898 bs.setBusinessKey(newnode);
899 bs.getSignature().clear();
900
901
902 }
903 }
904 SaveBusiness sb = new SaveBusiness();
905 sb.setAuthInfo(GetToken());
906 sb.getBusinessEntity().add(get);
907
908 BusinessDetail saveBusiness = pub.saveBusiness(sb);
909 newnode = saveBusiness.getBusinessEntity().get(0).getBusinessKey();
910 }
911
912 tx.begin();
913
914 Query createQuery = em.createQuery("Update UddiEntity ue set ue.nodeId=:node where ue.nodeId=:oldnode");
915 createQuery.setParameter("node", newnode);
916 createQuery.setParameter("oldnode", currentnode);
917 int records = createQuery.executeUpdate();
918
919 createQuery = em.createQuery("Update ChangeRecord ue set ue.nodeID=:node where ue.nodeID=:oldnode");
920 createQuery.setParameter("node", newnode);
921 createQuery.setParameter("oldnode", currentnode);
922 records += createQuery.executeUpdate();
923
924
925 tx.commit();
926 try {
927 DeleteBusiness db = new DeleteBusiness();
928 db.setAuthInfo(GetToken());
929 db.getBusinessKey().add(currentnode);
930 pub.deleteBusiness(db);
931 } catch (Exception ex) {
932 log.warn("Node id change error: ", ex);
933 }
934
935
936 AppConfig.setJuddiProperty(Property.JUDDI_NODE_ID, newnode);
937 AppConfig.setJuddiProperty(Property.JUDDI_NODE_ROOT_BUSINESS, newnode);
938
939 return "Sucess, Records update: " + records + " current node id is now " + AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID);
940 } catch (Exception ex) {
941 return HandleException(ex);
942 } finally {
943 if (tx.isActive()) {
944 tx.rollback();
945 }
946 em.close();
947 }
948 }
949
950 private String getChangeRecord(HttpServletRequest parameters) {
951 try {
952 GetChangeRecords req = new GetChangeRecords();
953
954 req.setRequestingNode(AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID));
955
956 req.setResponseLimitCount(BigInteger.ONE);
957 req.setChangesAlreadySeen(new HighWaterMarkVectorType());
958 req.getChangesAlreadySeen().getHighWaterMark().add(
959 new ChangeRecordIDType(parameters.getParameter("nodeid"),
960 Long.parseLong(parameters.getParameter("recordid"))));
961 ChangeRecords changeRecords = new UDDIReplicationImpl().getChangeRecords(req);
962 return PrettyPrintJaxbObject(changeRecords);
963
964 } catch (Exception ex) {
965 return HandleException(ex);
966 }
967 }
968
969
970
971
972
973
974
975
976 private String PrettyPrintJaxbObject(Object jaxb) throws Exception {
977 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
978 dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
979 DocumentBuilder db = dbf.newDocumentBuilder();
980 StringWriter sw = new StringWriter();
981 JAXB.marshal(jaxb, sw);
982 InputSource is = new InputSource(new StringReader(sw.toString()));
983
984 TransformerFactory transFactory = TransformerFactory.newInstance();
985 transFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
986 transFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
987 Transformer transformer = transFactory.newTransformer();
988 transformer.setOutputProperty(OutputKeys.INDENT, "yes");
989
990 StreamResult result = new StreamResult(new StringWriter());
991 Document document = db.parse(is);
992 DOMSource source = new DOMSource(document);
993 transformer.transform(source, result);
994 String xmlString = result.getWriter().toString();
995
996 return "<pre>" + StringEscapeUtils.escapeXml(xmlString) + "</pre>";
997 }
998
999 private String getFailedReplicationChangeRecords(HttpServletRequest parameters) {
1000 try {
1001
1002 GetFailedReplicationChangeRecordsMessageRequest req = new GetFailedReplicationChangeRecordsMessageRequest();
1003 req.setAuthInfo(GetToken());
1004 req.setMaxRecords(Integer.parseInt(parameters.getParameter("getFailedReplicationChangeRecordsMaxCount")));
1005 req.setOffset(0);
1006 req.setOffset(Integer.parseInt(parameters.getParameter("getFailedReplicationChangeRecordsOffset")));
1007 GetFailedReplicationChangeRecordsMessageResponse failedReplicationChangeRecords = null;
1008 try {
1009 failedReplicationChangeRecords = juddi.getFailedReplicationChangeRecords(req);
1010 } catch (Exception ex) {
1011 if (isExceptionExpiration(ex)) {
1012 token = null;
1013 req.setAuthInfo(GetToken());
1014 try {
1015 failedReplicationChangeRecords = juddi.getFailedReplicationChangeRecords(req);
1016 } catch (Exception ex1) {
1017 return "Error!" + HandleException(ex1);
1018 }
1019
1020 } else {
1021 return "Error!" + HandleException(ex);
1022 }
1023 }
1024
1025 return PrettyPrintJaxbObject(failedReplicationChangeRecords);
1026 } catch (Exception ex) {
1027 return HandleException(ex);
1028 }
1029 }
1030
1031 public enum AuthStyle {
1032
1033
1034
1035
1036 HTTP,
1037
1038
1039
1040 UDDI_AUTH
1041 }
1042
1043 private String GetToken() {
1044 EnsureConfig();
1045 if (style != AuthStyle.UDDI_AUTH) {
1046 BindingProvider bp = null;
1047 if (WS_Transport) {
1048 Map<String, Object> context = null;
1049 bp = (BindingProvider) juddi;
1050 context = bp.getRequestContext();
1051 context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
1052 context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
1053 }
1054 return null;
1055 } else {
1056 if (token != null) {
1057 return token;
1058 }
1059 GetAuthToken req = new GetAuthToken();
1060 if (session.getAttribute("username") != null
1061 && session.getAttribute("password") != null) {
1062 req.setUserID((String) session.getAttribute("username"));
1063 req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
1064 try {
1065 AuthToken authToken = security.getAuthToken(req);
1066 token = authToken.getAuthInfo();
1067 } catch (Exception ex) {
1068 return HandleException(ex);
1069 }
1070 }
1071 }
1072 return token;
1073 }
1074
1075 private String delete_publisher(HttpServletRequest parameters) {
1076 DeletePublisher sb = new DeletePublisher();
1077 sb.setAuthInfo(GetToken());
1078 sb.getPublisherId().add(parameters.getParameter("delete_publisherKEY"));
1079 try {
1080 juddi.deletePublisher(sb);
1081 } catch (Exception ex) {
1082 if (isExceptionExpiration(ex)) {
1083 token = null;
1084 sb.setAuthInfo(GetToken());
1085 try {
1086 juddi.deletePublisher(sb);
1087 } catch (Exception e) {
1088 return HandleException(e);
1089 }
1090
1091 } else {
1092 return HandleException(ex);
1093 }
1094 }
1095 return "Success";
1096 }
1097
1098 private String getAllPublisherDetail(HttpServletRequest parameters) {
1099 StringBuilder ret = new StringBuilder();
1100 GetAllPublisherDetail sb = new GetAllPublisherDetail();
1101 sb.setAuthInfo(GetToken());
1102 PublisherDetail d = null;
1103 try {
1104 d = juddi.getAllPublisherDetail(sb);
1105 } catch (Exception ex) {
1106 if (isExceptionExpiration(ex)) {
1107 token = null;
1108 sb.setAuthInfo(GetToken());
1109 try {
1110 d = juddi.getAllPublisherDetail(sb);
1111 } catch (Exception ex1) {
1112 return HandleException(ex1);
1113 }
1114
1115 } else {
1116 return HandleException(ex);
1117 }
1118 }
1119 if (d != null) {
1120 ret.append("<table class=\"table table-hover\"><tr><th>Name</th><th>Info</th></tr>");
1121 for (int i = 0; i < d.getPublisher().size(); i++) {
1122 ret.append("<tr><td>").append(StringEscapeUtils.escapeHtml(d.getPublisher().get(i).getPublisherName()))
1123 .append("</td><td>");
1124 ret.append(PrintPublisherDetail(d.getPublisher().get(i)))
1125 .append("</td></tr>");
1126 }
1127 ret.append("</table>");
1128 } else {
1129 ret.append("No data returned");
1130 }
1131 return ret.toString();
1132 }
1133
1134 private String PrintPublisherDetail(Publisher p) {
1135 StringBuilder ret = new StringBuilder();
1136
1137 ret.append("Authorized Name = ").append(StringEscapeUtils.escapeHtml(p.getAuthorizedName()))
1138 .append("<br>")
1139 .append("Publisher Name = ").append(StringEscapeUtils.escapeHtml(p.getPublisherName()))
1140 .append("<br>")
1141 .append("Email = ")
1142 .append(StringEscapeUtils.escapeHtml(p.getEmailAddress()))
1143 .append("<br>")
1144 .append("Administrator = ")
1145 .append((p.isIsAdmin()))
1146 .append("<br>")
1147 .append("Enabled = ")
1148 .append((p.isIsEnabled()))
1149 .append("<br>")
1150 .append("Max Bindings per = ")
1151 .append(p.getMaxBindingsPerService())
1152 .append("<br>")
1153 .append("Max Businesses = ")
1154 .append(p.getMaxBusinesses())
1155 .append("<br>")
1156 .append("Max Services per = ")
1157 .append(p.getMaxServicePerBusiness())
1158 .append("<br>")
1159 .append("Max tModels = ")
1160 .append(p.getMaxTModels())
1161 .append("");
1162 return ret.toString();
1163 }
1164
1165 private String get_publisherDetail(HttpServletRequest parameters) {
1166 StringBuilder ret = new StringBuilder();
1167 GetPublisherDetail sb = new GetPublisherDetail();
1168 sb.getPublisherId().add(parameters.getParameter("get_publisherDetailKEY"));
1169 sb.setAuthInfo(GetToken());
1170 PublisherDetail d = null;
1171 try {
1172 d = juddi.getPublisherDetail(sb);
1173 } catch (Exception ex) {
1174 if (isExceptionExpiration(ex)) {
1175 token = null;
1176 sb.setAuthInfo(GetToken());
1177 try {
1178 d = juddi.getPublisherDetail(sb);
1179 } catch (Exception ex1) {
1180 return HandleException(ex1);
1181 }
1182
1183 } else {
1184 return HandleException(ex);
1185 }
1186 }
1187 if (d != null) {
1188 ret.append("<table class=\"table table-hover\"><tr><th>Name</th><th>Info</th></tr>");
1189 for (int i = 0; i < d.getPublisher().size(); i++) {
1190 ret.append("<tr><td>").append(StringEscapeUtils.escapeHtml(d.getPublisher().get(i).getPublisherName()))
1191 .append("</td><td>");
1192 ret.append(PrintPublisherDetail(d.getPublisher().get(i)))
1193 .append("</td></tr>");
1194 }
1195 ret.append("</table>");
1196 } else {
1197 ret.append("No data returned");
1198 }
1199 return ret.toString();
1200 }
1201
1202 private String invoke_SyncSubscription(HttpServletRequest parameters) {
1203 StringBuilder ret = new StringBuilder();
1204 SyncSubscription sb = new SyncSubscription();
1205
1206 SyncSubscriptionDetail d = null;
1207 try {
1208 StringReader sr = new StringReader(parameters.getParameter("invoke_SyncSubscriptionXML").trim());
1209 sb = (SyncSubscription) (XmlUtils.unmarshal(sr, SyncSubscription.class));
1210 sb.setAuthInfo(GetToken());
1211 d = juddi.invokeSyncSubscription(sb);
1212 } catch (Exception ex) {
1213 if (isExceptionExpiration(ex)) {
1214 token = null;
1215 sb.setAuthInfo(GetToken());
1216 try {
1217 d = juddi.invokeSyncSubscription(sb);
1218 } catch (Exception ex1) {
1219 return HandleException(ex1);
1220 }
1221
1222 } else {
1223 return HandleException(ex);
1224 }
1225 }
1226 if (d != null) {
1227 try {
1228 ret.append(PrettyPrintJaxbObject(d));
1229 } catch (Exception ex) {
1230 return HandleException(ex);
1231 }
1232
1233 } else {
1234 ret.append("No data returned");
1235 }
1236 return ret.toString();
1237 }
1238
1239 private static String PrettyPrintXML(String input) {
1240 try {
1241 TransformerFactory transFactory = TransformerFactory.newInstance();
1242 transFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
1243 transFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
1244 Transformer transformer = transFactory.newTransformer();
1245 transformer.setOutputProperty(OutputKeys.INDENT, "yes");
1246
1247 StreamResult result = new StreamResult(new StringWriter());
1248 StreamSource source = new StreamSource(new StringReader(input));
1249 transformer.transform(source, result);
1250 String xmlString = result.getWriter().toString();
1251 return (xmlString);
1252 } catch (Exception ex) {
1253 }
1254 return null;
1255 }
1256
1257 public String getSampleSave_ClientSubscriptionInfo() {
1258 SaveClientSubscriptionInfo x = new SaveClientSubscriptionInfo();
1259 x.setAuthInfo("");
1260 x.getClientSubscriptionInfo().add(new ClientSubscriptionInfo());
1261 x.getClientSubscriptionInfo().get(0).setFromClerk(new Clerk());
1262 x.getClientSubscriptionInfo().get(0).setToClerk(new Clerk());
1263 x.getClientSubscriptionInfo().get(0).setSubscriptionKey("subscription key");
1264 x.getClientSubscriptionInfo().get(0).setLastModified(null);
1265 x.getClientSubscriptionInfo().get(0).setLastNotified(null);
1266 x.getClientSubscriptionInfo().get(0).getFromClerk().setName("ClerkName");
1267 x.getClientSubscriptionInfo().get(0).getFromClerk().setPublisher("username");
1268 x.getClientSubscriptionInfo().get(0).getFromClerk().setPassword("password");
1269 x.getClientSubscriptionInfo().get(0).getFromClerk().setNode(new Node());
1270 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setClientName("clientname");
1271 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setName("nodename");
1272 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setDescription("description");
1273 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setInquiryUrl("http://localhost:8080/juddiv3/services/inquiry");
1274 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setPublishUrl("http://localhost:8080/juddiv3/services/publish");
1275 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setCustodyTransferUrl("http://localhost:8080/juddiv3/services/custody-transfer");
1276 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setSubscriptionUrl("http://localhost:8080/juddiv3/services/subscription");
1277 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setSubscriptionListenerUrl("http://localhost:8080/juddiv3/services/subscription-listener");
1278 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setJuddiApiUrl("http://localhost:8080/juddiv3/services/juddi-api");
1279 x.getClientSubscriptionInfo().get(0).getFromClerk().getNode().setReplicationUrl("http://localhost:8080/juddiv3/services/replication");
1280
1281 x.getClientSubscriptionInfo().get(0).getToClerk().setName("ClerkName");
1282 x.getClientSubscriptionInfo().get(0).getToClerk().setPublisher("username");
1283 x.getClientSubscriptionInfo().get(0).getToClerk().setPassword("password");
1284 x.getClientSubscriptionInfo().get(0).getToClerk().setNode(new Node());
1285 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setClientName("clientname");
1286 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setName("nodename");
1287 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setDescription("description");
1288 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setInquiryUrl("http://localhost:8080/juddiv3/services/inquiry");
1289 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setPublishUrl("http://localhost:8080/juddiv3/services/publish");
1290 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setCustodyTransferUrl("http://localhost:8080/juddiv3/services/custody-transfer");
1291 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setSubscriptionUrl("http://localhost:8080/juddiv3/services/subscription");
1292 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setSubscriptionListenerUrl("http://localhost:8080/juddiv3/services/subscription-listener");
1293 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setJuddiApiUrl("http://localhost:8080/juddiv3/services/juddi-api");
1294 x.getClientSubscriptionInfo().get(0).getToClerk().getNode().setReplicationUrl("http://localhost:8080/juddiv3/services/replication");
1295 StringWriter sw = new StringWriter();
1296 JAXB.marshal(x, sw);
1297 return sw.toString();
1298 }
1299
1300 private String save_ClientSubscriptionInfo(HttpServletRequest parameters) {
1301 StringBuilder ret = new StringBuilder();
1302 SaveClientSubscriptionInfo sb = new SaveClientSubscriptionInfo();
1303
1304 if (parameters.getParameter("ClientSubscriptionInfoDetailXML") == null) {
1305 return "No input!";
1306 }
1307 ClientSubscriptionInfoDetail d = null;
1308 try {
1309 StringReader sr = new StringReader(parameters.getParameter("ClientSubscriptionInfoDetailXML").trim());
1310 sb = (JAXB.unmarshal(sr, SaveClientSubscriptionInfo.class));
1311 sb.setAuthInfo(GetToken());
1312 d = juddi.saveClientSubscriptionInfo(sb);
1313 } catch (Exception ex) {
1314 if (ex instanceof DispositionReportFaultMessage) {
1315 DispositionReportFaultMessage f = (DispositionReportFaultMessage) ex;
1316 if (f.getFaultInfo().countainsErrorCode(DispositionReport.E_AUTH_TOKEN_EXPIRED)) {
1317 token = null;
1318 sb.setAuthInfo(GetToken());
1319 try {
1320 d = juddi.saveClientSubscriptionInfo(sb);
1321 } catch (Exception ex1) {
1322 return HandleException(ex1);
1323 }
1324 }
1325 } else {
1326 return HandleException(ex);
1327 }
1328 }
1329 if (d != null) {
1330 try {
1331 ret.append(PrettyPrintJaxbObject(d));
1332 } catch (Exception ex) {
1333 return HandleException(ex);
1334 }
1335
1336 } else {
1337 ret.append("No data returned");
1338 }
1339 return ret.toString();
1340 }
1341
1342
1343
1344
1345
1346
1347
1348
1349 public static boolean isExceptionExpiration(Exception ex) {
1350 if (ex == null) {
1351 return false;
1352 }
1353 if (ex instanceof DispositionReportFaultMessage) {
1354 DispositionReportFaultMessage f = (DispositionReportFaultMessage) ex;
1355 if (f.getFaultInfo().countainsErrorCode(DispositionReport.E_AUTH_TOKEN_EXPIRED) || ex.getMessage().contains(DispositionReport.E_AUTH_TOKEN_EXPIRED) || ex.getMessage().toLowerCase().contains("expired")) {
1356 return true;
1357 }
1358 }
1359
1360 if (ex.getMessage() == null) {
1361 return false;
1362 }
1363 if (ex.getMessage().toLowerCase().contains("expire")) {
1364 return true;
1365 }
1366
1367 if (ex.getMessage().toLowerCase().contains(DispositionReport.E_AUTH_TOKEN_EXPIRED.toLowerCase())) {
1368 return true;
1369 }
1370 if (ex.getLocalizedMessage() == null) {
1371 return false;
1372 }
1373 if (ex.getLocalizedMessage().toLowerCase().contains("expire")) {
1374 return true;
1375 }
1376 return false;
1377 }
1378
1379 private String save_publisher(HttpServletRequest parameters) {
1380
1381 SavePublisher sb = new SavePublisher();
1382 Publisher p = new Publisher();
1383 p.setAuthorizedName(parameters.getParameter("savePublisherAuthorizedName"));
1384 p.setPublisherName(parameters.getParameter("savePublisherNAME"));
1385 p.setEmailAddress(parameters.getParameter("savePublisherEMAIL"));
1386 try {
1387 p.setIsAdmin(Boolean.parseBoolean(parameters.getParameter("savePublisherIsAdmin")));
1388 } catch (Exception ex) {
1389 }
1390 try {
1391 p.setIsEnabled(Boolean.parseBoolean(parameters.getParameter("savePublisherIsEnabled")));
1392 } catch (Exception ex) {
1393 }
1394
1395 PublisherDetail d = null;
1396 sb.setAuthInfo(GetToken());
1397 try {
1398 if (parameters.getParameter("savePublisherMaxBindings") != null) {
1399 p.setMaxBindingsPerService(Integer.parseInt(parameters.getParameter("savePublisherMaxBindings")));
1400 }
1401 } catch (Exception ex) {
1402 }
1403 try {
1404 if (parameters.getParameter("savePublisherMaxServices") != null) {
1405 p.setMaxServicePerBusiness(Integer.parseInt(parameters.getParameter("savePublisherMaxServices")));
1406 }
1407 } catch (Exception ex) {
1408 }
1409 try {
1410 if (parameters.getParameter("savePublisherMaxBusiness") != null) {
1411 p.setMaxBusinesses(Integer.parseInt(parameters.getParameter("savePublisherMaxBusiness")));
1412 }
1413 } catch (Exception ex) {
1414 }
1415 try {
1416 if (parameters.getParameter("savePublisherMaxTModels") != null) {
1417 p.setMaxTModels(Integer.parseInt(parameters.getParameter("savePublisherMaxTModels")));
1418 }
1419 } catch (Exception ex) {
1420 }
1421 sb.getPublisher().add(p);
1422 try {
1423
1424 d = juddi.savePublisher(sb);
1425 } catch (Exception ex) {
1426
1427 if (isExceptionExpiration(ex)) {
1428 token = null;
1429 sb.setAuthInfo(GetToken());
1430 try {
1431 d = juddi.savePublisher(sb);
1432 } catch (Exception ex1) {
1433 return HandleException(ex1);
1434 }
1435 } else {
1436 return HandleException(ex);
1437 }
1438 }
1439 return "Success";
1440 }
1441
1442 private String adminDelete_tmodel(HttpServletRequest parameters) {
1443 DeleteTModel sb = new DeleteTModel();
1444 sb.getTModelKey().add(parameters.getParameter("adminDelete_tmodelKEY"));
1445 sb.setAuthInfo(GetToken());
1446 try {
1447 juddi.adminDeleteTModel(sb);
1448 } catch (Exception ex) {
1449 if (isExceptionExpiration(ex)) {
1450 token = null;
1451 sb.setAuthInfo(GetToken());
1452 try {
1453 juddi.adminDeleteTModel(sb);
1454 } catch (Exception ex1) {
1455 return HandleException(ex1);
1456 }
1457 } else {
1458 return HandleException(ex);
1459 }
1460 }
1461 return "Success";
1462 }
1463
1464 private String delete_ClientSubscriptionInfo(HttpServletRequest parameters) {
1465 DeleteClientSubscriptionInfo sb = new DeleteClientSubscriptionInfo();
1466 sb.getSubscriptionKey().add(parameters.getParameter("delete_ClientSubscriptionInfoKEY"));
1467 sb.setAuthInfo(GetToken());
1468 try {
1469 juddi.deleteClientSubscriptionInfo(sb);
1470 } catch (Exception ex) {
1471 if (isExceptionExpiration(ex)) {
1472 token = null;
1473 sb.setAuthInfo(GetToken());
1474 try {
1475 juddi.deleteClientSubscriptionInfo(sb);
1476 } catch (Exception ex1) {
1477 return HandleException(ex1);
1478 }
1479
1480 } else {
1481 return HandleException(ex);
1482 }
1483 }
1484 return "Success";
1485 }
1486
1487
1488
1489
1490
1491
1492
1493
1494 public boolean isAdminLocalhostOnly() {
1495 return clientConfig.getConfiguration().getBoolean(PROP_ADMIN_LOCALHOST_ONLY, true);
1496 }
1497
1498 public String verifyLogin() {
1499 EnsureConfig();
1500 if (style != AuthStyle.UDDI_AUTH) {
1501 if (WS_Transport) {
1502 BindingProvider bp = null;
1503 Map<String, Object> context = null;
1504
1505 bp = (BindingProvider) juddi;
1506 context = bp.getRequestContext();
1507 context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
1508 context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
1509 }
1510 FindBusiness fb = new FindBusiness();
1511 fb.setListHead(0);
1512 fb.setMaxRows(1);
1513 fb.setFindQualifiers(new FindQualifiers());
1514 fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
1515 fb.getName().add(new Name(UDDIConstants.WILDCARD, null));
1516 try {
1517 GetPublisherDetail publisherDetail = new GetPublisherDetail();
1518 publisherDetail.getPublisherId().add((String) session.getAttribute("username"));
1519 juddi.getPublisherDetail(publisherDetail);
1520
1521 } catch (Exception ex) {
1522 return HandleException(ex);
1523 }
1524
1525
1526
1527
1528
1529 return null;
1530 } else {
1531 if (token != null) {
1532 return token;
1533 }
1534 if (WS_Transport) {
1535 BindingProvider bp = null;
1536 Map<String, Object> context = null;
1537
1538 bp = (BindingProvider) juddi;
1539 context = bp.getRequestContext();
1540 context.remove(BindingProvider.USERNAME_PROPERTY);
1541 context.remove(BindingProvider.PASSWORD_PROPERTY);
1542 }
1543 GetAuthToken req = new GetAuthToken();
1544 try {
1545 if (security == null) {
1546 security = transport.getUDDISecurityService();
1547 }
1548 } catch (Exception ex) {
1549 return HandleException(ex);
1550 }
1551 if (session.getAttribute("username") != null
1552 && session.getAttribute("password") != null) {
1553 req.setUserID((String) session.getAttribute("username"));
1554 req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
1555 log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is " + ((security == null) ? "HTTP" : "AUTH_TOKEN"));
1556 try {
1557 AuthToken authToken = security.getAuthToken(req);
1558 token = authToken.getAuthInfo();
1559 return null;
1560 } catch (Exception ex) {
1561 return HandleException(ex);
1562 }
1563 }
1564 }
1565 return "Unexpected error";
1566 }
1567
1568 public String SendAdvanced(Object request, String method) {
1569 StringWriter sw = new StringWriter();
1570 Object result=null;
1571 try {
1572 if (method.equalsIgnoreCase("save_ClientSubscriptionInfo")) {
1573 SaveClientSubscriptionInfo x = (SaveClientSubscriptionInfo) request;
1574 x.setAuthInfo(GetToken());
1575 ClientSubscriptionInfoDetail saveClientSubscriptionInfo = null;
1576 try {
1577 result = juddi.saveClientSubscriptionInfo(x);
1578 sw.append("Success:<br>");
1579
1580 } catch (Exception ex) {
1581 if (isExceptionExpiration(ex)) {
1582 token = null;
1583 x.setAuthInfo(GetToken());
1584 result = juddi.saveClientSubscriptionInfo(x);
1585 sw.append("Success:<br>");
1586
1587
1588 } else {
1589 throw ex;
1590 }
1591 }
1592
1593 }
1594 if (method.equalsIgnoreCase("invoke_SyncSubscription")) {
1595 SyncSubscription x = (SyncSubscription) request;
1596 x.setAuthInfo(GetToken());
1597 SyncSubscriptionDetail invokeSyncSubscription = null;
1598 try {
1599 result = juddi.invokeSyncSubscription(x);
1600 sw.append("Success:<br>");
1601
1602 } catch (Exception ex) {
1603 if (isExceptionExpiration(ex)) {
1604 token = null;
1605 x.setAuthInfo(GetToken());
1606 result = juddi.invokeSyncSubscription(x);
1607 sw.append("Success:<br>");
1608
1609
1610 } else {
1611 throw ex;
1612 }
1613 }
1614
1615 }
1616 if (method.equalsIgnoreCase("admin_SaveBusiness")) {
1617 AdminSaveBusiness x = (AdminSaveBusiness) request;
1618
1619 DispositionReport adminSaveBusiness = null;
1620
1621 try {
1622 result = juddi.adminSaveBusiness(GetToken(), x.getValues());
1623 sw.append("Success:<br>");
1624
1625
1626 } catch (Exception ex) {
1627 if (isExceptionExpiration(ex)) {
1628 token = null;
1629 x.setAuthInfo(GetToken());
1630 result = juddi.adminSaveBusiness(GetToken(), x.getValues());
1631 sw.append("Success:<br>");
1632
1633
1634 } else {
1635 throw ex;
1636 }
1637 }
1638 }
1639 if (method.equalsIgnoreCase("admin_SaveTModel")) {
1640 AdminSaveTModel x = (AdminSaveTModel) request;
1641
1642 DispositionReport adminSaveTModel = null;
1643 try {
1644 result = juddi.adminSaveTModel(GetToken(), x.getValues());
1645 sw.append("Success:<br>");
1646
1647
1648 } catch (Exception ex) {
1649 if (isExceptionExpiration(ex)) {
1650 token = null;
1651 x.setAuthInfo(GetToken());
1652 result = juddi.adminSaveTModel(GetToken(), x.getValues());
1653 sw.append("Success:<br>");
1654
1655
1656 } else {
1657 throw ex;
1658 }
1659 }
1660
1661 }
1662
1663 if (method.equalsIgnoreCase("admin_SaveSubscription")) {
1664 AdminSaveSubscriptionRequest x = (AdminSaveSubscriptionRequest) request;
1665 Holder<List<Subscription>> holder = new Holder<List<Subscription>>(x.getSubscriptions());
1666 try {
1667 juddi.adminSaveSubscription(GetToken(), x.getPublisherOrUsername(), holder);
1668 sw.append("Success:<br>");
1669 result=holder;
1670 } catch (Exception ex) {
1671 if (isExceptionExpiration(ex)) {
1672 token = null;
1673
1674 juddi.adminSaveSubscription(GetToken(), x.getPublisherOrUsername(), holder);
1675 sw.append("Success:<br>");
1676 result=holder;
1677
1678 } else {
1679 throw ex;
1680 }
1681 }
1682 }
1683 if (method.equalsIgnoreCase("set_ReplicationNodes")) {
1684 ReplicationConfiguration x = (ReplicationConfiguration) request;
1685
1686 try {
1687 result = juddi.setReplicationNodes(GetToken(), x);
1688 sw.append("Success:<br>");
1689
1690 } catch (Exception ex) {
1691 if (isExceptionExpiration(ex)) {
1692 token = null;
1693
1694 result = juddi.setReplicationNodes(GetToken(), x);
1695 sw.append("Success:<br>");
1696
1697
1698 } else {
1699 throw ex;
1700 }
1701 }
1702 }
1703
1704 } catch (Exception ex) {
1705 return HandleException(ex);
1706 }
1707 if (result!=null){
1708 try {
1709 return sw.toString() + "<br>" + PrettyPrintJaxbObject(result);
1710 } catch (Exception ex) {
1711 return HandleException(ex);
1712 }
1713 }
1714 return "Error! no work was done?";
1715
1716 }
1717
1718 }