You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2014/01/12 16:59:17 UTC
svn commit: r1557549 [2/3] - in /juddi/trunk:
juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/
juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/
juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/ juddi-gu...
Modified: juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java?rev=1557549&r1=1557548&r2=1557549&view=diff
==============================================================================
--- juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java (original)
+++ juddi/trunk/juddi-gui/src/main/java/org/apache/juddi/webconsole/hub/UddiHub.java Sun Jan 12 15:59:16 2014
@@ -83,3537 +83,3527 @@ import sun.misc.BASE64Encoder;
*/
public class UddiHub implements Serializable {
- /**
- * The logger name
- */
- public static final String LOGGER_NAME = "org.apache.juddi";
- private static final long serialVersionUID = 1L;
- AuthStyle style = null;
- private String nodename = "default";
- private final String clientName = "juddigui";
- private boolean WS_Transport = false;
- private boolean WS_securePorts = false;
- private transient HttpSession session;
- private transient Transport transport = null;
- private transient ClientConfig clientConfig;
- private transient Properties properties;
- private transient UDDISubscriptionPortType subscription = null;
- private transient UDDISecurityPortType security = null;
- private transient UDDIInquiryPortType inquiry = null;
- private transient UDDIPublicationPortType publish = null;
- private transient UDDICustodyTransferPortType custody = null;
- //private JUDDIApiPortType juddi = null;
- private transient String token = null;
- /**
- * The Log4j logger. This is also referenced from the Builders class, thus
- * it is public
- */
- public transient static final Log log = LogFactory.getLog(LOGGER_NAME);
- private transient DatatypeFactory df;
- /**
- * the name of the 'node' property in the config
- */
- public static final String PROP_CONFIG_NODE = "config.props.node";
- /**
- *
- */
- public static final String PROP_AUTH_TYPE = "config.props.authtype";
- /**
- *
- */
- public static final String PROP_AUTO_LOGOUT = "config.props.automaticLogouts.enable";
- /**
- *
- */
- public static final String PROP_AUTO_LOGOUT_TIMER = "config.props.automaticLogouts.duration";
- /**
- *
- */
- public static final String PROP_PREFIX = "config.props.";
- /**
- *
- *
- */
- public static final String PROP_ADMIN_LOCALHOST_ONLY = "config.props.configLocalHostOnly";
-
- private UddiHub() throws DatatypeConfigurationException {
- df = DatatypeFactory.newInstance();
- }
-
- /**
- * removes the Hub from the current http session
- *
- * @param _session
- */
- public static void reset(HttpSession _session) {
- _session.removeAttribute("hub");
- // token = null;
- }
-
- /**
- * This kills any authentication tokens, logs the user out and nulls out all
- * services
- */
- public void die() {
- DiscardAuthToken da = new DiscardAuthToken();
- da.setAuthInfo(token);
- try {
- security.discardAuthToken(da);
- } catch (Exception ex) {
- HandleException(ex);
- }
-
- token = null;
- inquiry = null;
- publish = null;
- custody = null;
- security = null;
- //juddi = null;
- subscription = null;
- }
-
- /**
- * This is the singleton accessor UddiHub. There should be at most 1
- * instance per HTTP Session (user login)
- *
- * @param application
- * @param _session
- * @return
- * @throws Exception
- */
- public static UddiHub getInstance(ServletContext application, HttpSession _session) throws Exception {
- Object j = _session.getAttribute("hub");
- if (j == null) {
- UddiHub hub = new UddiHub(application, _session);
- _session.setAttribute("hub", hub);
- hub.locale = (String) _session.getAttribute("locale");
- return hub;
- }
-
- return (UddiHub) j;
- }
- String locale = "en";
-
- /**
- * gets the user selected locale
- *
- * @return
- */
- public String getLocale() {
- return locale;
- }
-
- private void EnsureConfig() {
- if (clientConfig == null) {
- try {
- UDDIClient client = new UDDIClient();
- clientConfig = client.getClientConfig();
- try {
- style = AuthStyle.valueOf(clientConfig.getConfiguration().getString(PROP_AUTH_TYPE));
- } catch (Exception ex) {
- log.warn("'UDDI_AUTH' is not defined in the config (" + PROP_AUTH_TYPE + ")! defaulting to UDDI_AUTH");
- style = AuthStyle.UDDI_AUTH;
- }
-
- nodename = clientConfig.getConfiguration().getString(PROP_CONFIG_NODE);
- if (nodename == null || nodename.equals("")) {
- log.warn("'node' is not defined in the config! defaulting to 'default'");
- nodename = "default";
- }
- UDDINode uddiNode = clientConfig.getUDDINode(nodename);
-
- String clazz = uddiNode.getProxyTransport();
- if (clazz.contains("JAXWSTransport")) {
- WS_Transport = true;
- }
- Class<?> transportClass = ClassUtil.forName(clazz, Transport.class);
- if (transportClass != null) {
- transport = client.getTransport(nodename);
-
- security = transport.getUDDISecurityService();
- inquiry = transport.getUDDIInquiryService();
- subscription = transport.getUDDISubscriptionService();
- publish = transport.getUDDIPublishService();
- custody = transport.getUDDICustodyTransferService();
-
- if (WS_Transport) {
- if (uddiNode.getPublishUrl().toLowerCase().startsWith("https://")
- && (uddiNode.getSecurityUrl() != null && uddiNode.getSecurityUrl().toLowerCase().startsWith("https://"))
- && uddiNode.getInquiryUrl().toLowerCase().startsWith("https://")
- && (uddiNode.getCustodyTransferUrl() != null && uddiNode.getCustodyTransferUrl().toLowerCase().startsWith("https://"))
- && uddiNode.getSubscriptionUrl().toLowerCase().startsWith("https://")) {
- WS_securePorts = true;
- }
- }
-
- }
- } catch (Exception ex) {
- HandleException(ex);
- }
- }
-
- }
-
- private UddiHub(ServletContext application, HttpSession _session) throws Exception {
- session = _session;
-
- URL prop = application.getResource("/META-INF/config.properties");
- if (prop == null) {
- throw new Exception("Cannot locate the configuration file.");
- }
-
- InputStream in = prop.openStream();
- Properties p = new Properties();
- p.load(in);
- in.close();
- properties = p;
-
-
- EnsureConfig();
- }
-
- /**
- * returns true if we are using JAXWS transport AND all of the URLs start
- * with https://
- *
- * @return
- */
- public boolean isSecure() {
-
- EnsureConfig();
- return WS_securePorts;
- }
-
- /**
- * gets a reference to the current juddi client config file. this is a live
- * instance changes can be stored to disk, usually
- *
- * @return
- * @throws ConfigurationException g
- */
- public ClientConfig GetJuddiClientConfig() throws ConfigurationException {
- EnsureConfig();
- return clientConfig;
- }
-
- /**
- * returns all of the current properties defining digital signatures
- *
- * @return
- */
- public Properties GetDigitalSignatureConfig() {
- try {
- return GetJuddiClientConfig().getDigitalSignatureConfiguration();
- } catch (Exception ex) {
- log.error("error fetching uddi.xml", ex);
- }
- return new Properties();
- }
-
- private String GetToken() {
- EnsureConfig();
- if (style != AuthStyle.UDDI_AUTH) {
- BindingProvider bp = null;
- Map<String, Object> context = null;
- bp = (BindingProvider) inquiry;
- context = bp.getRequestContext();
- context.remove(BindingProvider.USERNAME_PROPERTY);
- context.remove(BindingProvider.PASSWORD_PROPERTY);
-
- context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
- context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
-
- bp = (BindingProvider) publish;
- context = bp.getRequestContext();
- context.remove(BindingProvider.USERNAME_PROPERTY);
- context.remove(BindingProvider.PASSWORD_PROPERTY);
-
- context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
- context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
-
- bp = (BindingProvider) custody;
- context = bp.getRequestContext();
- context.remove(BindingProvider.USERNAME_PROPERTY);
- context.remove(BindingProvider.PASSWORD_PROPERTY);
-
- context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
- context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
-
- bp = (BindingProvider) subscription;
- context = bp.getRequestContext();
- context.remove(BindingProvider.USERNAME_PROPERTY);
- context.remove(BindingProvider.PASSWORD_PROPERTY);
-
- context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
- context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
-
- /*
- bp = (BindingProvider) juddi;
- context = bp.getRequestContext();
- context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
- context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/
- return null;
- } else {
- if (token != null) {
- return token;
- }
- BindingProvider bp = null;
- Map<String, Object> context = null;
-
- bp = (BindingProvider) inquiry;
- context = bp.getRequestContext();
- context.remove(BindingProvider.USERNAME_PROPERTY);
- context.remove(BindingProvider.PASSWORD_PROPERTY);
-
- bp = (BindingProvider) publish;
- context = bp.getRequestContext();
- context.remove(BindingProvider.USERNAME_PROPERTY);
- context.remove(BindingProvider.PASSWORD_PROPERTY);
-
-
- bp = (BindingProvider) custody;
- context = bp.getRequestContext();
- context.remove(BindingProvider.USERNAME_PROPERTY);
- context.remove(BindingProvider.PASSWORD_PROPERTY);
-
- bp = (BindingProvider) subscription;
- context = bp.getRequestContext();
- context.remove(BindingProvider.USERNAME_PROPERTY);
- context.remove(BindingProvider.PASSWORD_PROPERTY);
-
-
- GetAuthToken req = new GetAuthToken();
- try {
- if (security == null) {
- security = transport.getUDDISecurityService();
- }
- } catch (Exception ex) {
- log.error(ex);
- }
- if (session.getAttribute("username") != null
- && session.getAttribute("password") != null) {
- req.setUserID((String) session.getAttribute("username"));
- req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
- log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is " + ((security == null) ? "HTTP" : "AUTH_TOKEN"));
- try {
- AuthToken authToken = security.getAuthToken(req);
- token = authToken.getAuthInfo();
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
- }
- return token;
- }
-
- /**
- * Returns true if the current user has a token and is signed in. Does not
- * apply to non-UDDI security API logins
- *
- * @return
- */
- public boolean getUddiIsAuthenticated() {
- return (token != null && !token.isEmpty());
- }
-
- /**
- * Performs a find_business call in the inquiry API
- *
- * @param offset
- * @param maxrecords
- * @param keyword
- * @param lang
- * @param isChooser
- * @return
- */
- public PagableContainer GetBusinessListAsHtml(int offset, int maxrecords, String keyword, String lang, boolean isChooser) {
- PagableContainer ret = new PagableContainer();
- ret.offset = offset;
- ret.displaycount = 0;
- ret.totalrecords = 0;
-
- try {
- FindBusiness fb = new FindBusiness();
- fb.setMaxRows(maxrecords);
- fb.setListHead(offset);
- fb.setAuthInfo(GetToken());
- org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
- fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
-
- fb.setFindQualifiers(fq);
- Name searchname = new Name();
- searchname.setLang(lang);
- searchname.setValue(keyword);
- fb.getName().add(searchname);
- //transport
- BusinessList findBusiness = null;
- try {
- findBusiness = inquiry.findBusiness(fb);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- fb.setAuthInfo(GetToken());
- findBusiness = inquiry.findBusiness(fb);
- } else {
- throw ex;
- }
- }
- if (findBusiness == null || findBusiness.getBusinessInfos() == null) {
- ret.renderedHtml = (ResourceLoader.GetResource(session, "errors.nodatareturned"));
- } else {
- ret.displaycount = findBusiness.getListDescription().getIncludeCount();
- ret.offset = findBusiness.getListDescription().getListHead();
- ret.totalrecords = findBusiness.getListDescription().getActualCount();
- ret.renderedHtml = Printers.BusinessListAsTable(findBusiness, session, isChooser);
- }
-
- } catch (Exception ex) {
- ret.renderedHtml = (HandleException(ex));
- }
-
- return ret;
- }
-
- /**
- * The get_registeredInfo API call is used to get an abbreviated list of all
- * businessEntity and tModel data that are controlled by a publisher. When
- * the registry distinguishes between publishers, this is the individual
- * associated with the credentials passed in the authInfo element. This
- * returned information is intended, for example, for driving tools that
- * display lists of registered information and then provide drill-down
- * features. This is the recommended API to use after a network problem
- * results in an unknown status of saved information.
- *
- * @return
- */
- public String GetMyTransferableKeys(boolean businesses, boolean tModels) {
-
- StringBuilder sb = new StringBuilder();
-
-
- RegisteredInfo findBusiness = null;
- try {
- GetRegisteredInfo r = new GetRegisteredInfo();
- r.setAuthInfo(GetToken());
- if (r.getAuthInfo() == null) {
- return ToErrorAlert(ResourceLoader.GetResource(session, "errors.notsignedin"));
- }
- r.setInfoSelection(InfoSelection.ALL);
-
- try {
- findBusiness = publish.getRegisteredInfo(r);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- r.setAuthInfo(GetToken());
- findBusiness = publish.getRegisteredInfo(r);
- } else {
- throw ex;
- }
- }
+ /**
+ * The logger name
+ */
+ public static final String LOGGER_NAME = "org.apache.juddi";
+ private static final long serialVersionUID = 1L;
+ AuthStyle style = null;
+ private String nodename = "default";
+ private final String clientName = "juddigui";
+ private boolean WS_Transport = false;
+ private boolean WS_securePorts = false;
+ private transient HttpSession session;
+ private transient Transport transport = null;
+ private transient ClientConfig clientConfig;
+ private transient Properties properties;
+ private transient UDDISubscriptionPortType subscription = null;
+ private transient UDDISecurityPortType security = null;
+ private transient UDDIInquiryPortType inquiry = null;
+ private transient UDDIPublicationPortType publish = null;
+ private transient UDDICustodyTransferPortType custody = null;
+ //private JUDDIApiPortType juddi = null;
+ private transient String token = null;
+ /**
+ * The Log4j logger. This is also referenced from the Builders class,
+ * thus it is public
+ */
+ public transient static final Log log = LogFactory.getLog(LOGGER_NAME);
+ private transient DatatypeFactory df;
+ /**
+ * the name of the 'node' property in the config
+ */
+ public static final String PROP_CONFIG_NODE = "config.props.node";
+ /**
+ *
+ */
+ public static final String PROP_AUTH_TYPE = "config.props.authtype";
+ /**
+ *
+ */
+ public static final String PROP_AUTO_LOGOUT = "config.props.automaticLogouts.enable";
+ /**
+ *
+ */
+ public static final String PROP_AUTO_LOGOUT_TIMER = "config.props.automaticLogouts.duration";
+ /**
+ *
+ */
+ public static final String PROP_PREFIX = "config.props.";
+ /**
+ *
+ *
+ */
+ public static final String PROP_ADMIN_LOCALHOST_ONLY = "config.props.configLocalHostOnly";
- } catch (Exception ex) {
- return ToErrorAlert(HandleException(ex));
+ private UddiHub() throws DatatypeConfigurationException {
+ df = DatatypeFactory.newInstance();
}
+ /**
+ * removes the Hub from the current http session
+ *
+ * @param _session
+ */
+ public static void reset(HttpSession _session) {
+ _session.removeAttribute("hub");
+ // token = null;
+ }
- if (findBusiness == null || findBusiness.getBusinessInfos() == null) {
- return (ResourceLoader.GetResource(session, "errors.nodatareturned"));
-
- } else {
- if (findBusiness.getBusinessInfos() != null && businesses) {
- sb.append("<select id=\"businesslist\" multiple=\"multiple\" size=\"10\">");
- for (int i = 0; i < findBusiness.getBusinessInfos().getBusinessInfo().size(); i++) {
- sb.append("<option class=\"transferable\" id=\"").
- append(StringEscapeUtils.escapeHtml(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey())).
- append("\" title=\"").
- append(StringEscapeUtils.escapeHtml(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey())).
- append("\">").
- append(StringEscapeUtils.escapeHtml(Printers.ListNamesToString(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getName()))).
- append("</option>");
- }
- sb.append("</select>");
- }
- if (findBusiness.getTModelInfos() != null && tModels) {
- sb.append("<select id=\"tmodellist\" multiple=\"multiple\" size=\"10\">");
- for (int i = 0; i < findBusiness.getTModelInfos().getTModelInfo().size(); i++) {
- sb.append("<option class=\"transferable\" id=\"").
- append(StringEscapeUtils.escapeHtml(findBusiness.getTModelInfos().getTModelInfo().get(i).getTModelKey())).
- append("\" title=\"").
- append(StringEscapeUtils.escapeHtml(findBusiness.getTModelInfos().getTModelInfo().get(i).getTModelKey())).
- append("\">").
- append(StringEscapeUtils.escapeHtml((findBusiness.getTModelInfos().getTModelInfo().get(i).getName().getValue()))).
- append("</option>");
- }
- sb.append("</select>");
- }
-
- return sb.toString();
- }
-
- }
-
- /**
- * Performs Inquiry Find_service API used from servicedetails.jsp
- *
- * @param serviceid
- * @return
- */
- public String GetServiceDetailAsHtml(String serviceid) {
- if (serviceid == null || serviceid.length() == 0) {
- return ResourceLoader.GetResource(session, "errors.noinput");
- }
- StringBuilder sb = new StringBuilder();
- try {
- GetServiceDetail gbd = new GetServiceDetail();
- gbd.setAuthInfo(GetToken());
- gbd.getServiceKey().add(serviceid);
- ServiceDetail get = null;//inquiry.getServiceDetail(gbd);
- try {
- get = inquiry.getServiceDetail(gbd);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- gbd.setAuthInfo(GetToken());
- get = inquiry.getServiceDetail(gbd);
-
- } else {
- throw ex;
- }
- }
- if (get != null) {
- for (int i = 0; i < get.getBusinessService().size(); i++) {
- session.setAttribute(get.getBusinessService().get(i).getServiceKey(), get.getBusinessService().get(i));
- sb.append("<b>").append(ResourceLoader.GetResource(session, "items.name")).append(":</b><div class=\"editable\" id=\"ServiceName\">").append(StringEscapeUtils.escapeHtml(Printers.ListNamesToString(get.getBusinessService().get(i).getName()))).append("</div><Br>");
- sb.append("<b>").append(ResourceLoader.GetResource(session, "items.description")).append(":</b><div class=\"editable\" id=\"ServiceDescription\">").append(StringEscapeUtils.escapeHtml((Printers.ListToDescString(get.getBusinessService().get(i).getDescription())))).append("</div><Br>");
- sb.append("<b>").append(ResourceLoader.GetResource(session, "items.key")).append(":</b><div class=\"editable\" id=\"ServiceKey\">").append(StringEscapeUtils.escapeHtml((get.getBusinessService().get(i).getServiceKey()))).append("</div><Br>");
- sb.append("<b>").append(ResourceLoader.GetResource(session, "items.keyrefcat")).append(":</b> ").append(Printers.CatBagToString(get.getBusinessService().get(i).getCategoryBag(), (String) session.getAttribute("locale"))).append("<Br>");
- if (!get.getBusinessService().get(i).getSignature().isEmpty()) {
- sb.append(ResourceLoader.GetResource(session, "items.signed")).append("<Br>");
- } else {
- sb.append(ResourceLoader.GetResource(session, "items.signed.not")).append("<Br>");
- }
-
- sb.append(Printers.PrintBindingTemplates(get.getBusinessService().get(i).getBindingTemplates(), locale)).append("<Br>");
- }
- } else {
- sb.append(ResourceLoader.GetResource(session, "errors.nodatareturned"));
- }
- } catch (Exception ex) {
- sb.append(HandleException(ex));
- }
- return sb.toString();
- }
-
- /**
- * return true if the word expire is in the exception or the UDDI error code
- * representing an expired token
- *
- * @param ex
- * @return r
- */
- public static boolean isExceptionExpiration(Exception ex) {
- if (ex == null) {
- return false;
- }
- if (ex instanceof DispositionReportFaultMessage) {
- DispositionReportFaultMessage f = (DispositionReportFaultMessage) ex;
- if (f.getFaultInfo().countainsErrorCode(DispositionReport.E_AUTH_TOKEN_EXPIRED) || ex.getMessage().contains(DispositionReport.E_AUTH_TOKEN_EXPIRED) || ex.getMessage().toLowerCase().contains("expired")) {
- return true;
- }
- }
-
- if (ex.getMessage()==null){
- return false;
- }
- if (ex.getMessage().toLowerCase().contains("expire")) {
- return true;
- }
-
- if (ex.getMessage().toLowerCase().contains(DispositionReport.E_AUTH_TOKEN_EXPIRED.toLowerCase())) {
- return true;
- }
- if (ex.getLocalizedMessage()==null){
- return false;
- }
- if (ex.getLocalizedMessage().toLowerCase().contains("expire")) {
- return true;
- }
- return false;
- }
-
- /**
- * returns an html formatted list of services for a specific business used
- * on browse.jsp
- *
- * @param bizid
- * @return retu
- */
- public String GetServiceList(String bizid) {
- if (bizid == null || bizid.isEmpty()) {
- return ResourceLoader.GetResource(session, "errors.nobusinessid");
- }
- StringBuilder sb = new StringBuilder();
- try {
- GetBusinessDetail gbd = new GetBusinessDetail();
- gbd.setAuthInfo(GetToken());
- gbd.getBusinessKey().add(bizid);
- BusinessDetail businessDetail = null;
- try {
- businessDetail = inquiry.getBusinessDetail(gbd);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
-
- token = null;
- gbd.setAuthInfo(GetToken());
- businessDetail = inquiry.getBusinessDetail(gbd);
-
- } else {
- throw ex;
- }
- }
- if (businessDetail != null) {
- for (int i = 0; i < businessDetail.getBusinessEntity().size(); i++) {
- if (businessDetail.getBusinessEntity().get(i).getBusinessServices() == null) {
- sb.append(ResourceLoader.GetResource(session, "errors.noservicesdefined"));
- } else {
- for (int k = 0; k < businessDetail.getBusinessEntity().get(i).getBusinessServices().getBusinessService().size(); k++) {
- sb.append("<div><a href=\"serviceEditor.jsp?id=").
- append(StringEscapeUtils.escapeHtml(businessDetail.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(k).getServiceKey())).append("\">").
- append(StringEscapeUtils.escapeHtml(Printers.ListNamesToString(businessDetail.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(k).getName()))).append("</a></div>");
- }
- }
- }
- } else {
- sb.append(ResourceLoader.GetResource(session, "errors.nodatareturned"));
- }
- } catch (Exception ex) {
- sb.append(ResourceLoader.GetResource(session, "errors.generic")).append(ex.getMessage());
- }
- return sb.toString();
- }
-
- /**
- * Performs a getServiceDetails in Inquiry API
- *
- * @param serviceid
- * @return null if no id was specified or if it didn't exist
- */
- public BusinessService GetServiceDetail(String serviceid) {
- if (serviceid == null || serviceid.length() == 0) {
- return null;
- }
-
- try {
- GetServiceDetail gbd = new GetServiceDetail();
- gbd.setAuthInfo(GetToken());
- gbd.getServiceKey().add(serviceid);
- ServiceDetail get = null;
- try {
- get = inquiry.getServiceDetail(gbd);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- gbd.setAuthInfo(GetToken());
- get = inquiry.getServiceDetail(gbd);
+ /**
+ * This kills any authentication tokens, logs the user out and nulls out
+ * all services
+ */
+ public void die() {
+ DiscardAuthToken da = new DiscardAuthToken();
+ da.setAuthInfo(token);
+ try {
+ security.discardAuthToken(da);
+ } catch (Exception ex) {
+ HandleException(ex);
+ }
+
+ token = null;
+ inquiry = null;
+ publish = null;
+ custody = null;
+ security = null;
+ //juddi = null;
+ subscription = null;
+ }
- } else {
- throw ex;
+ /**
+ * This is the singleton accessor UddiHub. There should be at most 1
+ * instance per HTTP Session (user login)
+ *
+ * @param application
+ * @param _session
+ * @return
+ * @throws Exception
+ */
+ public static UddiHub getInstance(ServletContext application, HttpSession _session) throws Exception {
+ Object j = _session.getAttribute("hub");
+ if (j == null) {
+ UddiHub hub = new UddiHub(application, _session);
+ _session.setAttribute("hub", hub);
+ hub.locale = (String) _session.getAttribute("locale");
+ return hub;
}
- }
- if (get == null || get.getBusinessService().isEmpty()) {
- return null;
- }
- return get.getBusinessService().get(0);
+ return (UddiHub) j;
+ }
+ String locale = "en";
- } catch (Exception ex) {
- HandleException(ex);
+ /**
+ * gets the user selected locale
+ *
+ * @return
+ */
+ public String getLocale() {
+ return locale;
}
- return null;
- }
- /**
- * Calls Publisher Save Service API
- *
- * @param be
- * @return
- */
- public String SaveService(BusinessService be) {
- try {
- SaveService sb = new SaveService();
- sb.setAuthInfo(GetToken());
- sb.getBusinessService().add(be);
- try {
- publish.saveService(sb);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- sb.setAuthInfo(GetToken());
- publish.saveService(sb);
- } else {
- throw ex;
+ private void EnsureConfig() {
+ if (clientConfig == null) {
+ try {
+ UDDIClient client = new UDDIClient();
+ clientConfig = client.getClientConfig();
+ try {
+ style = AuthStyle.valueOf(clientConfig.getConfiguration().getString(PROP_AUTH_TYPE));
+ } catch (Exception ex) {
+ log.warn("'UDDI_AUTH' is not defined in the config (" + PROP_AUTH_TYPE + ")! defaulting to UDDI_AUTH");
+ style = AuthStyle.UDDI_AUTH;
+ }
+
+ nodename = clientConfig.getConfiguration().getString(PROP_CONFIG_NODE);
+ if (nodename == null || nodename.equals("")) {
+ log.warn("'node' is not defined in the config! defaulting to 'default'");
+ nodename = "default";
+ }
+ UDDINode uddiNode = clientConfig.getUDDINode(nodename);
+
+ String clazz = uddiNode.getProxyTransport();
+ if (clazz.contains("JAXWSTransport")) {
+ WS_Transport = true;
+ }
+ Class<?> transportClass = ClassUtil.forName(clazz, Transport.class);
+ if (transportClass != null) {
+ transport = client.getTransport(nodename);
+
+ security = transport.getUDDISecurityService();
+ inquiry = transport.getUDDIInquiryService();
+ subscription = transport.getUDDISubscriptionService();
+ publish = transport.getUDDIPublishService();
+ custody = transport.getUDDICustodyTransferService();
+
+ if (WS_Transport) {
+ if (uddiNode.getPublishUrl().toLowerCase().startsWith("https://")
+ && (uddiNode.getSecurityUrl() != null && uddiNode.getSecurityUrl().toLowerCase().startsWith("https://"))
+ && uddiNode.getInquiryUrl().toLowerCase().startsWith("https://")
+ && (uddiNode.getCustodyTransferUrl() != null && uddiNode.getCustodyTransferUrl().toLowerCase().startsWith("https://"))
+ && uddiNode.getSubscriptionUrl().toLowerCase().startsWith("https://")) {
+ WS_securePorts = true;
+ }
+ }
+
+ }
+ } catch (Exception ex) {
+ HandleException(ex);
+ }
}
- }
- return ResourceLoader.GetResource(session, "actions.saved");
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- /**
- * don't think this is used yet
- *
- * @param be
- * @return
- */
- @Deprecated
- public String SaveBindingTemplate(BindingTemplate be) {
- try {
- SaveBinding sb = new SaveBinding();
- sb.setAuthInfo(GetToken());
- sb.getBindingTemplate().add(be);
- try {
- publish.saveBinding(sb);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- sb.setAuthInfo(GetToken());
- publish.saveBinding(sb);
+ }
- } else {
- throw ex;
- }
- }
- return ResourceLoader.GetResource(session, "actions.save.bindingtemplate");
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- /**
- * This method will rebuild a Service entity from the HTTP request from the
- * Service Editor page and will then attempt to save it.
- *
- * @param request
- * @return a localized Saved or an error message
- */
- public String SaveServiceDetails(HttpServletRequest request) {
-
- BusinessService be = new BusinessService();
- be.setBusinessKey(request.getParameter(PostBackConstants.BUSINESSKEY).trim());
- be.setServiceKey(request.getParameter(PostBackConstants.SERVICEKEY).trim());
-
- if (be.getServiceKey().equalsIgnoreCase(ResourceLoader.GetResource(session, "items.clicktoedit"))) {
- be.setServiceKey(null);
- }
- if (be.getBusinessKey() == null || be.getBusinessKey().length() == 0) {
- return ResourceLoader.GetResource(session, "errors.noinput.businesskey");
- }
-
- be.getName().addAll(Builders.BuildNames(Builders.MapFilter(request.getParameterMap(), PostBackConstants.NAME), PostBackConstants.NAME, ResourceLoader.GetResource(session, "items.clicktoedit"), locale));
- BindingTemplates bt = new BindingTemplates();
- bt.getBindingTemplate().addAll(Builders.BuildBindingTemplates(Builders.MapFilter(request.getParameterMap(), PostBackConstants.BINDINGTEMPLATE), PostBackConstants.BINDINGTEMPLATE, ResourceLoader.GetResource(session, "items.clicktoedit"), locale));
- if (!bt.getBindingTemplate().isEmpty()) {
- be.setBindingTemplates(bt);
- }
-
- be.getDescription().addAll(Builders.BuildDescription(Builders.MapFilter(request.getParameterMap(), PostBackConstants.DESCRIPTION), PostBackConstants.DESCRIPTION, ResourceLoader.GetResource(session, "items.clicktoedit"), locale));
-
- CategoryBag cb = new CategoryBag();
- cb.getKeyedReference().addAll(Builders.BuildKeyedReference(Builders.MapFilter(request.getParameterMap(), PostBackConstants.CATBAG_KEY_REF), PostBackConstants.CATBAG_KEY_REF, locale));
- cb.getKeyedReferenceGroup().addAll(Builders.BuildKeyedReferenceGroup(Builders.MapFilter(request.getParameterMap(), PostBackConstants.CATBAG_KEY_REF_GRP), PostBackConstants.CATBAG_KEY_REF_GRP, locale));
-
- if (!cb.getKeyedReference().isEmpty() || !cb.getKeyedReferenceGroup().isEmpty()) {
- be.setCategoryBag(cb);
- }
-
- return SaveServiceDetails(be);
- }
-
- /**
- * Saves a Service
- *
- * @param be
- * @return a readable error message or, success
- */
- public String SaveServiceDetails(BusinessService be) {
- try {
- SaveService sb = new SaveService();
- sb.setAuthInfo(GetToken());
- sb.getBusinessService().add(be);
- try {
- publish.saveService(sb);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- sb.setAuthInfo(GetToken());
- publish.saveService(sb);
+ private UddiHub(ServletContext application, HttpSession _session) throws Exception {
+ session = _session;
- } else {
- throw ex;
+ URL prop = application.getResource("/META-INF/config.properties");
+ if (prop == null) {
+ throw new Exception("Cannot locate the configuration file.");
}
- }
- return ResourceLoader.GetResource(session, "actions.save.service");
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- /**
- * Saves a business entity
- *
- * @param be
- * @return a readable error message
- */
- public String SaveBusinessDetails(BusinessEntity be) {
- try {
- SaveBusiness sb = new SaveBusiness();
- sb.setAuthInfo(GetToken());
- sb.getBusinessEntity().add(be);
- try {
- publish.saveBusiness(sb);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- sb.setAuthInfo(GetToken());
- publish.saveBusiness(sb);
- } else {
- throw ex;
- }
- }
+ InputStream in = prop.openStream();
+ Properties p = new Properties();
+ p.load(in);
+ in.close();
+ properties = p;
- return ResourceLoader.GetResource(session, "actions.saved");
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- /**
- * Save Business
- *
- * This method saves a business to a UDDI registry, preserving the service
- * listing The request is build from the HTTP post back parameters. A human
- * readable response message is returned
- *
- * @param request
- * @return
- */
- public String SaveBusinessDetails(HttpServletRequest request) {
-
-
-
- BusinessEntity be = new BusinessEntity();
- be.setBusinessKey(request.getParameter(PostBackConstants.BUSINESSKEY).trim());
- if (be.getBusinessKey().equalsIgnoreCase(ResourceLoader.GetResource(session, "items.clicktoedit"))) {
- be.setBusinessKey(null);
- } else {
- BusinessEntity GetBusinessDetails = GetBusinessDetails(be.getBusinessKey());
- if (GetBusinessDetails == null) //this is a new business
- {
- } else {
- //copy over the existing child element, business
- be.setBusinessServices(GetBusinessDetails.getBusinessServices());
- }
- }
- be.getName().addAll(Builders.BuildNames(Builders.MapFilter(request.getParameterMap(), PostBackConstants.NAME), PostBackConstants.NAME, ResourceLoader.GetResource(session, "items.clicktoedit"), locale));
-
-
- be.setContacts(Builders.BuildContacts(request.getParameterMap(), ResourceLoader.GetResource(session, "items.clicktoedit"), locale));
-
- be.getDescription().addAll(Builders.BuildDescription(Builders.MapFilter(request.getParameterMap(), PostBackConstants.DESCRIPTION), PostBackConstants.DESCRIPTION, ResourceLoader.GetResource(session, "items.clicktoedit"), locale));
- be.setDiscoveryURLs(Builders.BuildDisco(Builders.MapFilter(request.getParameterMap(), PostBackConstants.DISCOVERYURL), PostBackConstants.DISCOVERYURL, locale));
- CategoryBag cb = new CategoryBag();
- cb.getKeyedReference().addAll(Builders.BuildKeyedReference(Builders.MapFilter(request.getParameterMap(), PostBackConstants.CATBAG_KEY_REF), PostBackConstants.CATBAG_KEY_REF, locale));
- cb.getKeyedReferenceGroup().addAll(Builders.BuildKeyedReferenceGroup(Builders.MapFilter(request.getParameterMap(), PostBackConstants.CATBAG_KEY_REF_GRP), PostBackConstants.CATBAG_KEY_REF_GRP, locale));
-
- if (!cb.getKeyedReference().isEmpty() || !cb.getKeyedReferenceGroup().isEmpty()) {
- be.setCategoryBag(cb);
- }
- be.setIdentifierBag(Builders.BuildIdentBag(Builders.MapFilter(request.getParameterMap(), PostBackConstants.IDENT_KEY_REF), PostBackConstants.IDENT_KEY_REF, locale));
- return SaveBusinessDetails(be);
- }
-
- /**
- * Returns
- *
- * @param bizid
- * @return
- * @throws Exception
- */
- /**
- * Gets a business's details used for the businessEditor
- *
- * @param bizid
- * @return null if no id is provided or if there is a remote error
- */
- public BusinessEntity GetBusinessDetails(String bizid) {
- if (bizid == null || bizid.isEmpty()) {
- return null;
- }
-
- try {
- GetBusinessDetail gbd = new GetBusinessDetail();
- gbd.setAuthInfo(GetToken());
-
- gbd.getBusinessKey().add(bizid);
-
- BusinessDetail businessDetail = null;
- try {
- businessDetail = inquiry.getBusinessDetail(gbd);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- gbd.setAuthInfo(GetToken());
- businessDetail = inquiry.getBusinessDetail(gbd);
+ EnsureConfig();
+ }
- } else {
- throw ex;
- }
- }
- if (businessDetail != null && businessDetail.getBusinessEntity().size() == 1) {
- return businessDetail.getBusinessEntity().get(0);
- }
- } catch (Exception ex) {
- HandleException(ex);
- }
- return null;
-
- }
-
- /**
- * returns a bootstrap html stylizies an error message with a warning icon
- *
- * @param HandleException, any string representing an error message
- * @return
- */
- public static String ToErrorAlert(String HandleException) {
- return "<div class=\"alert alert-error\"><i class=\"icon-warning-sign icon-large\"></i> " + HandleException + "</div>";
- }
-
- /**
- * AuthStyles for the Hub to use, default is UDDI_AUTH
- */
- public enum AuthStyle {
-
- /**
- * Http
- */
- HTTP,
- /**
- * UDDI Authentication via the Security API
- */
- UDDI_AUTH
- }
-
- /**
- * Search for services using find_services
- *
- * @param keyword
- * @param lang
- * @param maxrecords
- * @param offset
- * @param isChooser
- * @return
- */
- public PagableContainer SearchForServices(String keyword, String lang, int maxrecords, int offset, boolean isChooser) {
- PagableContainer ret = new PagableContainer();
- ret.displaycount = 0;
- ret.offset = offset;
- ret.totalrecords = 0;
- try {
-
- FindService fs = new FindService();
- fs.setAuthInfo(GetToken());
- fs.setMaxRows(maxrecords);
- fs.setListHead(offset);
- Name n = new Name();
- if (lang == null || lang.equalsIgnoreCase(ResourceLoader.GetResource(session, "items.clicktoedit"))) {
- n.setLang(null);
- } else {
- n.setLang(lang);
- }
- n.setValue(keyword);
- fs.getName().add(n);
- fs.setFindQualifiers(new org.uddi.api_v3.FindQualifiers());
- fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
- ServiceList findService = null;//inquiry.findService(fs);
- try {
- findService = inquiry.findService(fs);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- fs.setAuthInfo(GetToken());
- findService = inquiry.findService(fs);
+ /**
+ * returns true if we are using JAXWS transport AND all of the URLs
+ * start with https://
+ *
+ * @return
+ */
+ public boolean isSecure() {
- } else {
- throw ex;
- }
- }
+ EnsureConfig();
+ return WS_securePorts;
+ }
- if (findService == null || findService.getServiceInfos() == null) {
- ret.renderedHtml = ResourceLoader.GetResource(session, "errors.norecordsfound");
- return ret;
- }
- ret.displaycount = findService.getListDescription().getIncludeCount();
- ret.totalrecords = findService.getListDescription().getActualCount();
- ret.renderedHtml = Printers.ServiceListAsHtml(findService, isChooser, session);
-
- // ret.renderedHtml = sb.toString();
- return ret;
- } catch (Exception ex) {
- ret.renderedHtml = HandleException(ex);
- }
- return ret;
-
- }
-
- /**
- * Adds a special tModel key generator keyGenerator: Marking a tModel with
- * this categorization designates it as one whose tModelKey identifies a key
- * generator partition that can be used by its owner to derive and assign
- * other entity keys. This categorization is reserved for key generator
- * tModels. Any attempt to use this categorization for something other than
- * a key generator tModel will fail with E_valueNotAllowed returned.
- *
- * @param partitionName
- * @return
- */
- public String AddTmodelKenGenerator(String partitionName, String name, String lang) {
- try {
- if (!partitionName.startsWith("uddi:")) {
- return ResourceLoader.GetResource(session, "errors.tmodel.prefix");
-
- }
- if (!partitionName.endsWith(":keyGenerator")) {
- return ResourceLoader.GetResource(session, "errors.tmodel.postfix");
- }
-
-
- SaveTModel st = new SaveTModel();
- st.setAuthInfo(GetToken());
- TModel tm = new TModel();
- tm.setName(new Name());
- tm.getName().setValue(name);
- if (lang == null || lang.equalsIgnoreCase(ResourceLoader.GetResource(session, "items.clicktoedit"))) {
- tm.getName().setLang(null);
- } else {
- tm.getName().setLang(lang);
- }
- tm.setCategoryBag(new CategoryBag());
- KeyedReference kr = new KeyedReference();
- kr.setTModelKey("uddi:uddi.org:categorization:types");
- kr.setKeyName("uddi-org:keyGenerator");
- kr.setKeyValue("keyGenerator");
- tm.getCategoryBag().getKeyedReference().add(kr);
- OverviewDoc overviewDoc = new OverviewDoc();
- OverviewURL overviewUrl = new OverviewURL();
- overviewUrl.setUseType("text");
- overviewUrl.setValue("http://uddi.org/pubs/uddi_v3.htm#keyGen");
- overviewDoc.setOverviewURL(overviewUrl);
- tm.getOverviewDoc().add(overviewDoc);
- tm.setTModelKey(partitionName.toLowerCase());
- st.getTModel().add(tm);
- publish.saveTModel(st);
- return ResourceLoader.GetResource(session, "messages.success");
- // "Success";
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- /**
- * This function provides a basic error handling rutine that will pull out
- * the true error message in a UDDI fault message, returning bootstrap
- * stylized html error message
- *
- * @param ex
- * @return
- */
- private String HandleException(Exception ex) {
- if (ex instanceof DispositionReportFaultMessage) {
- DispositionReportFaultMessage f = (DispositionReportFaultMessage) ex;
- log.error(ex.getMessage());
- log.debug(null, ex);
- return ResourceLoader.GetResource(session, "errors.uddi") + " " + ex.getMessage() + " " + f.detail.getMessage();
- }
- if (ex instanceof RemoteException) {
- RemoteException f = (RemoteException) ex;
- log.error(ex.getMessage());
- log.debug(null, ex);
- return ResourceLoader.GetResource(session, "errors.generic") + " " + ex.getMessage() + " " + f.detail.getMessage();
- }
- log.error(ex.getMessage());
- log.debug(null, ex);
- return ResourceLoader.GetResource(session, "errors.generic") + " " + StringEscapeUtils.escapeHtml(ex.getMessage());
- }
-
- /**
- * provides based tmodel searching/browser capability that's pagable
- *
- * @param keyword
- * @param lang
- * @param offset
- * @param maxrecords
- * @param isChooser if true, tModel keys will not be clickable and will
- * instead be render for a modal dialog box
- * @return
- */
- public PagableContainer tModelListAsHtml(String keyword, String lang, int offset, int maxrecords, boolean isChooser) {
- PagableContainer ret = new PagableContainer();
- try {
- FindTModel fm = new FindTModel();
- fm.setAuthInfo(GetToken());
- fm.setMaxRows(maxrecords);
- fm.setListHead(offset);
- fm.setName(new Name());
- if (lang == null || lang.equalsIgnoreCase(ResourceLoader.GetResource(session, "items.clicktoedit"))) {
- fm.getName().setLang(null);
- } else {
- fm.getName().setLang(lang);
- }
- fm.getName().setValue(keyword);
- fm.setFindQualifiers(new org.uddi.api_v3.FindQualifiers());
- fm.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
- TModelList findTModel = null;
- try {
- findTModel = inquiry.findTModel(fm);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- fm.setAuthInfo(GetToken());
- findTModel = inquiry.findTModel(fm);
+ /**
+ * gets a reference to the current juddi client config file. this is a
+ * live instance changes can be stored to disk, usually
+ *
+ * @return
+ * @throws ConfigurationException g
+ */
+ public ClientConfig GetJuddiClientConfig() throws ConfigurationException {
+ EnsureConfig();
+ return clientConfig;
+ }
- } else {
- throw ex;
+ /**
+ * returns all of the current properties defining digital signatures
+ *
+ * @return
+ */
+ public Properties GetDigitalSignatureConfig() {
+ try {
+ return GetJuddiClientConfig().getDigitalSignatureConfiguration();
+ } catch (Exception ex) {
+ log.error("error fetching uddi.xml", ex);
}
- }
+ return new Properties();
+ }
- ret.offset = offset;
- if (findTModel.getListDescription() != null) {
- ret.displaycount = findTModel.getListDescription().getIncludeCount();
- ret.totalrecords = findTModel.getListDescription().getActualCount();
- }
- if (findTModel.getTModelInfos() == null || findTModel.getTModelInfos().getTModelInfo().isEmpty()) {
- ret.renderedHtml = ResourceLoader.GetResource(session, "errors.norecordsfound");//"No tModels are defined";
- } else {
- // if (!isChooser) {
- ret.renderedHtml = Printers.PrintTModelListAsHtml(findTModel, session, isChooser);
- // } else {
- // ret.renderedHtml = Printers.PrintTModelListAsHtmlModel(findTModel, session);
- // }
+ private String GetToken() {
+ EnsureConfig();
+ if (style != AuthStyle.UDDI_AUTH) {
+ BindingProvider bp = null;
+ Map<String, Object> context = null;
+ bp = (BindingProvider) inquiry;
+ context = bp.getRequestContext();
+ context.remove(BindingProvider.USERNAME_PROPERTY);
+ context.remove(BindingProvider.PASSWORD_PROPERTY);
- }
- } catch (Exception ex) {
- ret.renderedHtml = HandleException(ex);
- }
- return ret;
- }
-
- /**
- * Returns the details of a tModel by tModelKey
- *
- * @param id
- * @return the details or null if it doesn't exist or a null value was
- * passed
- */
- public TModel getTmodelDetails(String id) {
- try {
- if (id == null || id.length() == 0) {
- return null;
- }
+ context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
+ context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
- GetTModelDetail req = new GetTModelDetail();
- req.setAuthInfo(GetToken());
- req.getTModelKey().add(id);
- TModelDetail tModelDetail = null;
- try {
- tModelDetail = inquiry.getTModelDetail(req);
-
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- req.setAuthInfo(GetToken());
- tModelDetail = inquiry.getTModelDetail(req);
+ bp = (BindingProvider) publish;
+ context = bp.getRequestContext();
+ context.remove(BindingProvider.USERNAME_PROPERTY);
+ context.remove(BindingProvider.PASSWORD_PROPERTY);
+ context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
+ context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
- } else {
- throw ex;
- }
- }
+ bp = (BindingProvider) custody;
+ context = bp.getRequestContext();
+ context.remove(BindingProvider.USERNAME_PROPERTY);
+ context.remove(BindingProvider.PASSWORD_PROPERTY);
- if (tModelDetail != null && !tModelDetail.getTModel().isEmpty()) {
- return tModelDetail.getTModel().get(0);
- }
-
- } catch (Exception ex) {
- HandleException(ex);
- }
- return null;
- }
-
- /**
- * A convenience function for GetBusinessDetails
- *
- * @param key
- * @return
- */
- public BusinessEntity GetBusinessDetailsAsObject(String key) {
- return GetBusinessDetails(key);
- }
-
- /**
- * A convenience function for GetServiceDetail
- *
- * @param key
- * @return
- */
- public BusinessService GetServiceDetailsAsObject(String key) {
- return GetServiceDetail(key);
- }
-
- /**
- * Returns a specific binding template as an object
- *
- * @param key
- * @return null if not found
- */
- public BindingTemplate GetBindingDetailsAsObject(String key) {
- try {
- GetBindingDetail r = new GetBindingDetail();
- r.setAuthInfo(GetToken());
- r.getBindingKey().add(key);
- BindingDetail bindingDetail = null;
- try {
- bindingDetail = inquiry.getBindingDetail(r);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- r.setAuthInfo(GetToken());
- bindingDetail = inquiry.getBindingDetail(r);
+ context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
+ context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
+ bp = (BindingProvider) subscription;
+ context = bp.getRequestContext();
+ context.remove(BindingProvider.USERNAME_PROPERTY);
+ context.remove(BindingProvider.PASSWORD_PROPERTY);
+
+ context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
+ context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));
+
+ /*
+ bp = (BindingProvider) juddi;
+ context = bp.getRequestContext();
+ context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username"));
+ context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/
+ return null;
} else {
- throw ex;
- }
- }
- return bindingDetail.getBindingTemplate().get(0);
- } catch (Exception ex) {
- HandleException(ex);
- }
- return null;
- }
-
- /**
- * Returns a tmodel given the key
- *
- * @param key
- * @return null if not found
- */
- public TModel GettModelDetailsAsObject(String key) {
- try {
- GetTModelDetail r = new GetTModelDetail();
- r.setAuthInfo(GetToken());
- r.getTModelKey().add(key);
- TModelDetail tModelDetail = null;
- try {
- tModelDetail = inquiry.getTModelDetail(r);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- r.setAuthInfo(GetToken());
- tModelDetail = inquiry.getTModelDetail(r);
- } else {
- throw ex;
- }
- }
+ if (token != null) {
+ return token;
+ }
+ BindingProvider bp = null;
+ Map<String, Object> context = null;
- return tModelDetail.getTModel().get(0);
- } catch (Exception ex) {
- HandleException(ex);
+ bp = (BindingProvider) inquiry;
+ context = bp.getRequestContext();
+ context.remove(BindingProvider.USERNAME_PROPERTY);
+ context.remove(BindingProvider.PASSWORD_PROPERTY);
+
+ bp = (BindingProvider) publish;
+ context = bp.getRequestContext();
+ context.remove(BindingProvider.USERNAME_PROPERTY);
+ context.remove(BindingProvider.PASSWORD_PROPERTY);
+
+ bp = (BindingProvider) custody;
+ context = bp.getRequestContext();
+ context.remove(BindingProvider.USERNAME_PROPERTY);
+ context.remove(BindingProvider.PASSWORD_PROPERTY);
+
+ bp = (BindingProvider) subscription;
+ context = bp.getRequestContext();
+ context.remove(BindingProvider.USERNAME_PROPERTY);
+ context.remove(BindingProvider.PASSWORD_PROPERTY);
+
+ GetAuthToken req = new GetAuthToken();
+ try {
+ if (security == null) {
+ security = transport.getUDDISecurityService();
+ }
+ } catch (Exception ex) {
+ log.error(ex);
+ }
+ if (session.getAttribute("username") != null
+ && session.getAttribute("password") != null) {
+ req.setUserID((String) session.getAttribute("username"));
+ req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key")));
+ log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is " + ((security == null) ? "HTTP" : "AUTH_TOKEN"));
+ try {
+ AuthToken authToken = security.getAuthToken(req);
+ token = authToken.getAuthInfo();
+ } catch (Exception ex) {
+ return HandleException(ex);
+ }
+ }
+ }
+ return token;
}
- return null;
- }
- /**
- * An enum to help make UDDI searching easier to work with
- */
- public enum FindType {
-
- /**
- * search for a business
- */
- Business,
- /**
- * search for a related business
- */
- RelatedBusiness,
- /**
- * search for a business
- */
- Service,
- /**
- * search for a tmodel
- */
- tModel,
/**
- * search for a binding template
+ * Returns true if the current user has a token and is signed in. Does
+ * not apply to non-UDDI security API logins
+ *
+ * @return
*/
- BindingTemplate
- }
-
- /**
- * An enum to help make UDDI searching easier to work with
- */
- public enum CriteriaType {
+ public boolean getUddiIsAuthenticated() {
+ return (token != null && !token.isEmpty());
+ }
/**
- * search by name
- */
- Name,
- /**
- * by category
- */
- Category,
- /**
- * by key
- */
- uid,
- /**
- * by tmodel
- */
- tmodel,
- /**
- * by identifier bag
+ * Performs a find_business call in the inquiry API
+ *
+ * @param offset
+ * @param maxrecords
+ * @param keyword
+ * @param lang
+ * @param isChooser
+ * @return
*/
- identbag
- }
-
- /**
- * Provides a simple search interface for the complex UDDI search APIs
- *
- * @param type
- * @param criteria
- * @param parameters
- * @param lang
- * @param findqualifier
- * @return stylized html
- */
- public String Search(FindType type, CriteriaType criteria, String parameters, String lang, String[] findqualifier) {
- switch (type) {
- case BindingTemplate:
- return FindBindingTemplateToHtml(criteria, parameters, lang, findqualifier);
- case Business:
- return FindBusiness(criteria, parameters, lang, findqualifier);
- case RelatedBusiness:
- return FindRelatedBusiness(criteria, parameters, lang, findqualifier);
-
- case Service:
- return FindService(criteria, parameters, lang, findqualifier);
- case tModel:
- return FindtModels(criteria, parameters, lang, findqualifier);
- }
- return ResourceLoader.GetResource(session, "items.unknown");
- }
-
- private String FindBindingTemplateToHtml(CriteriaType criteria, String parameters, String lang, String[] fq) {
- try {
- FindBinding fb = new FindBinding();
- fb.setAuthInfo(GetToken());
- if (fq != null) {
- fb.setFindQualifiers(new org.uddi.api_v3.FindQualifiers());
- for (int i = 0; i < fq.length; i++) {
- fb.getFindQualifiers().getFindQualifier().add(fq[i]);
- }
- }
- BindingDetail findBusiness = null;
- switch (criteria) {
- case Category:
- fb.setCategoryBag(new CategoryBag());
- KeyedReference kr = new KeyedReference();
- kr.setTModelKey(parameters);
- fb.getCategoryBag().getKeyedReference().add(kr);
- break;
- case Name:
- break;
- case tmodel:
- fb.setTModelBag(new TModelBag());
- fb.getTModelBag().getTModelKey().add(parameters);
- break;
- case uid:
- BusinessEntity t = GetBusinessDetails(parameters);
- findBusiness = new BindingDetail();
- BindingTemplate bt = GetBindingDetailsAsObject(parameters);
- findBusiness.getBindingTemplate().add(bt);
+ public PagableContainer GetBusinessListAsHtml(int offset, int maxrecords, String keyword, String lang, boolean isChooser) {
+ PagableContainer ret = new PagableContainer();
+ ret.offset = offset;
+ ret.displaycount = 0;
+ ret.totalrecords = 0;
- break;
-
- }
- if (findBusiness == null) {
try {
- findBusiness = inquiry.findBinding(fb);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
+ FindBusiness fb = new FindBusiness();
+ fb.setMaxRows(maxrecords);
+ fb.setListHead(offset);
fb.setAuthInfo(GetToken());
- findBusiness = inquiry.findBinding(fb);
-
- } else {
- throw ex;
- }
- }
+ org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
+ fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
- }
- if (findBusiness != null && findBusiness.getBindingTemplate() != null) {
- StringBuilder sb = new StringBuilder();
- sb.append("<table class=\"table\">");
- for (int i = 0; i < findBusiness.getBindingTemplate().size(); i++) {
- sb.append("<tr><td>");
- sb.append("<a href=\"serviceEditor.jsp?id=").
- append(StringEscapeUtils.escapeHtml(findBusiness.getBindingTemplate().get(i).getServiceKey())).
- append("\">");
- if (findBusiness.getBindingTemplate().get(i).getDescription().isEmpty()) {
- sb.append(StringEscapeUtils.escapeHtml(findBusiness.getBindingTemplate().get(i).getBindingKey()));
- } else {
- String t = StringEscapeUtils.escapeHtml(Printers.ListToDescString(findBusiness.getBindingTemplate().get(i).getDescription()));
- if (t == null || t.trim().length() == 0) {
- sb.append(StringEscapeUtils.escapeHtml(findBusiness.getBindingTemplate().get(i).getBindingKey()));
+ fb.setFindQualifiers(fq);
+ Name searchname = new Name();
+ searchname.setLang(lang);
+ searchname.setValue(keyword);
+ fb.getName().add(searchname);
+ //transport
+ BusinessList findBusiness = null;
+ try {
+ findBusiness = inquiry.findBusiness(fb);
+ } catch (Exception ex) {
+ if (isExceptionExpiration(ex)) {
+ token = null;
+ fb.setAuthInfo(GetToken());
+ findBusiness = inquiry.findBusiness(fb);
+ } else {
+ throw ex;
+ }
+ }
+ if (findBusiness == null || findBusiness.getBusinessInfos() == null) {
+ ret.renderedHtml = (ResourceLoader.GetResource(session, "errors.nodatareturned"));
} else {
- sb.append(t);
+ ret.displaycount = findBusiness.getListDescription().getIncludeCount();
+ ret.offset = findBusiness.getListDescription().getListHead();
+ ret.totalrecords = findBusiness.getListDescription().getActualCount();
+ ret.renderedHtml = Printers.BusinessListAsTable(findBusiness, session, isChooser);
}
- }
- sb.append("</a>");
- sb.append("</td></tr>");
- }
- sb.append("</table>");
- return sb.toString();
- } else {
- return ResourceLoader.GetResource(session, "errors.norecordsfound");
- }
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- private String FindBusiness(CriteriaType criteria, String parameters, String lang, String[] fq) {
- try {
- FindBusiness fb = new FindBusiness();
- fb.setAuthInfo(GetToken());
- if (fq != null) {
- fb.setFindQualifiers(new org.uddi.api_v3.FindQualifiers());
- if (fq != null) {
- for (int i = 0; i < fq.length; i++) {
- fb.getFindQualifiers().getFindQualifier().add(fq[i]);
- }
- }
- }
- BusinessList findBusiness = null;
- switch (criteria) {
- case Category:
- fb.setCategoryBag(new CategoryBag());
- KeyedReference kr = new KeyedReference();
- kr.setTModelKey(parameters);
- fb.getCategoryBag().getKeyedReference().add(kr);
- break;
- case Name:
- Name n = new Name();
- n.setLang(lang);
- n.setValue(parameters);
- fb.getName().add(n);
- break;
- case tmodel:
- fb.setTModelBag(new TModelBag());
- fb.getTModelBag().getTModelKey().add(parameters);
- break;
- case uid:
- BusinessEntity t = GetBusinessDetails(parameters);
- findBusiness = new BusinessList();
- findBusiness.setBusinessInfos(new BusinessInfos());
-
- BusinessInfo bd = new BusinessInfo();
- bd.setBusinessKey(t.getBusinessKey());
- bd.getName().addAll(t.getName());
- findBusiness.getBusinessInfos().getBusinessInfo().add(bd);
- break;
- }
- if (findBusiness == null) {
-
- try {
- findBusiness = inquiry.findBusiness(fb);
} catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- fb.setAuthInfo(GetToken());
- findBusiness = inquiry.findBusiness(fb);
-
- } else {
- throw ex;
- }
+ ret.renderedHtml = (HandleException(ex));
}
- }
- if (findBusiness != null && findBusiness.getBusinessInfos() != null) {
- StringBuilder sb = new StringBuilder();
- sb.append("<table class=\"table\">");
- for (int i = 0; i < findBusiness.getBusinessInfos().getBusinessInfo().size(); i++) {
- sb.append("<tr><td>");
- sb.append("<a href=\"businessEditor2.jsp?id=").
- append(StringEscapeUtils.escapeHtml(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey())).
- append("\">");
- if (findBusiness.getBusinessInfos().getBusinessInfo().get(i).getName().isEmpty()) {
- sb.append(StringEscapeUtils.escapeHtml(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey()));
- } else {
- sb.append(StringEscapeUtils.escapeHtml(Printers.ListNamesToString(findBusiness.getBusinessInfos().getBusinessInfo().get(i).getName())));
- }
- sb.append("</a>");
- sb.append("</td></tr>");
- }
- sb.append("</table>");
- return sb.toString();
- } else {
- return ResourceLoader.GetResource(session, "errors.norecordsfound");
- }
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- private String FindRelatedBusiness(CriteriaType criteria, String parameters, String lang, String[] fq) {
- try {
- FindRelatedBusinesses fb = new FindRelatedBusinesses();
- fb.setAuthInfo(GetToken());
- fb.setBusinessKey(parameters);
- RelatedBusinessesList findBusiness = null;
- switch (criteria) {
- case Category:
- break;
- case Name:
- break;
- case tmodel:
- break;
- case uid:
- break;
- }
-
- try {
- findBusiness = inquiry.findRelatedBusinesses(fb);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- fb.setAuthInfo(GetToken());
- findBusiness = inquiry.findRelatedBusinesses(fb);
- } else {
- throw ex;
- }
- }
+ return ret;
+ }
+ /**
+ * The get_registeredInfo API call is used to get an abbreviated list of
+ * all businessEntity and tModel data that are controlled by a
+ * publisher. When the registry distinguishes between publishers, this
+ * is the individual associated with the credentials passed in the
+ * authInfo element. This returned information is intended, for example,
+ * for driving tools that display lists of registered information and
+ * then provide drill-down features. This is the recommended API to use
+ * after a network problem results in an unknown status of saved
+ * information.
+ *
+ * @return
+ */
+ public String GetMyTransferableKeys(boolean businesses, boolean tModels) {
- if (findBusiness != null && findBusiness.getRelatedBusinessInfos() != null) {
StringBuilder sb = new StringBuilder();
- sb.append("<table class=\"table\">");
- for (int i = 0; i < findBusiness.getRelatedBusinessInfos().getRelatedBusinessInfo().size(); i++) {
- sb.append("<tr><td>");
- sb.append("<a href=\"businessEditor2.jsp?id=").
- append(StringEscapeUtils.escapeHtml(findBusiness.getRelatedBusinessInfos().getRelatedBusinessInfo().get(i).getBusinessKey())).
- append("\">");
- if (findBusiness.getRelatedBusinessInfos().getRelatedBusinessInfo().get(i).getName().isEmpty()) {
- sb.append(StringEscapeUtils.escapeHtml(findBusiness.getRelatedBusinessInfos().getRelatedBusinessInfo().get(i).getBusinessKey()));
- } else {
- sb.append(StringEscapeUtils.escapeHtml(Printers.ListNamesToString(findBusiness.getRelatedBusinessInfos().getRelatedBusinessInfo().get(i).getName())));
- }
- sb.append("</a>");
- sb.append("</td></tr>");
- }
- sb.append("</table>");
- return sb.toString();
- } else {
- return ResourceLoader.GetResource(session, "errors.norecordsfound");
- }
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- private String FindService(CriteriaType criteria, String parameters, String lang, String[] fq) {
- try {
- FindService fb = new FindService();
- fb.setAuthInfo(GetToken());
- if (fq != null) {
- fb.setFindQualifiers(new org.uddi.api_v3.FindQualifiers());
- if (fq != null) {
- fb.getFindQualifiers().getFindQualifier().addAll(Arrays.asList(fq));
- }
- }
- ServiceList findBusiness = null;
- switch (criteria) {
- case Category:
- fb.setCategoryBag(new CategoryBag());
- KeyedReference kr = new KeyedReference();
- kr.setTModelKey(parameters);
- fb.getCategoryBag().getKeyedReference().add(kr);
- break;
- case Name:
- Name n = new Name();
- n.setLang(lang);
- n.setValue(parameters);
- fb.getName().add(n);
- break;
- case tmodel:
- fb.setTModelBag(new TModelBag());
- fb.getTModelBag().getTModelKey().add(parameters);
- break;
- case uid:
- BusinessEntity t = GetBusinessDetails(parameters);
- findBusiness = new ServiceList();
- findBusiness.setServiceInfos(new ServiceInfos());
- BusinessService GetServiceDetail = GetServiceDetail(parameters);
- if (GetServiceDetail != null) {
- ServiceInfo si = new ServiceInfo();
- si.setBusinessKey(GetServiceDetail.getBusinessKey());
- si.setServiceKey(GetServiceDetail.getServiceKey());
- si.getName().addAll(GetServiceDetail.getName());
- findBusiness.getServiceInfos().getServiceInfo().add(si);
- }
- break;
- }
- if (findBusiness == null) {
+ RegisteredInfo findBusiness = null;
try {
- findBusiness = inquiry.findService(fb);
- } catch (Exception ex) {
- if (isExceptionExpiration(ex)) {
- token = null;
- fb.setAuthInfo(GetToken());
- findBusiness = inquiry.findService(fb);
+ GetRegisteredInfo r = new GetRegisteredInfo();
+ r.setAuthInfo(GetToken());
+ if (r.getAuthInfo() == null) {
+ return ToErrorAlert(ResourceLoader.GetResource(session, "errors.notsignedin"));
+ }
+ r.setInfoSelection(InfoSelection.ALL);
- } else {
- throw ex;
- }
- }
+ try {
+ findBusiness = publish.getRegisteredInfo(r);
+ } catch (Exception ex) {
+ if (isExceptionExpiration(ex)) {
+ token = null;
+ r.setAuthInfo(GetToken());
+ findBusiness = publish.getRegisteredInfo(r);
+ } else {
+ throw ex;
+ }
+ }
- }
- if (findBusiness.getServiceInfos() != null) {
- StringBuilder sb = new StringBuilder();
- sb.append("<table class=\"table\">");
- for (int i = 0; i < findBusiness.getServiceInfos().getServiceInfo().size(); i++) {
- sb.append("<tr><td>");
- sb.append("<a href=\"serviceEditor.jsp?id=").
- append(StringEscapeUtils.escapeHtml(findBusiness.getServiceInfos().getServiceInfo().get(i).getServiceKey())).
- append("\">");
- if (findBusiness.getServiceInfos().getServiceInfo().get(i).getName().isEmpty()) {
- sb.append(StringEscapeUtils.escapeHtml(findBusiness.getServiceInfos().getServiceInfo().get(i).getServiceKey()));
- } else {
- sb.append(StringEscapeUtils.escapeHtml(Printers.ListNamesToString(findBusiness.getServiceInfos().getServiceInfo().get(i).getName())));
- }
- sb.append("</a>");
- sb.append("</td></tr>");
+ } catch (Exception ex) {
+ return ToErrorAlert(HandleException(ex));
}
- sb.append("</table>");
- return sb.toString();
- } else {
- return ResourceLoader.GetResource(session, "errors.norecordsfound");
- }
- } catch (Exception ex) {
- return HandleException(ex);
- }
- }
-
- private String FindtModels(CriteriaType criteria, String parameters, String lang, String[] fq) {
- try {
- FindTModel fb = new FindTModel();
- fb.setAuthInfo(GetToken());
- if (fq != null) {
- fb.setFindQualifiers(new org.uddi.api_v3.FindQualifiers());
- if (fq != null) {
- for (int i = 0; i < fq.length; i++) {
- fb.getFindQualifiers().getFindQualifier().add(fq[i]);
- }
- }
- }
- TModelList findBusiness = null;
- switch (criteria) {
- case Category:
- fb.setCategoryBag(new CategoryBag());
- KeyedReference kr = new KeyedReference();
- kr.setTModelKey(parameters);
- fb.getCategoryBag().getKeyedReference().add(kr);
- break;
- case Name:
- Name n = new Name();
- n.setLang(lang);
- n.setValue(parameters);
- fb.setName(n);
- break;
- case tmodel:
- fb.setCategoryBag(new CategoryBag());
- KeyedReference kr2 = new KeyedReference();
- kr2.setTModelKey(parameters);
- fb.getCategoryBag().getKeyedReference().add(kr2);
- //TODO
- break;
- case uid:
- BusinessEntity t = GetBusinessDetails(parameters);
- TModel tmodelDetails = this.getTmodelDetails(parameters);
- TModelInfo tmi = new TModelInfo();
- tmi.setName(tmodelDetails.getName());
- tmi.setTModelKey(tmodelDetails.getTModelKey());
- tmi.getDescription().addAll(tmodelDetails.getDescription());
- findBusiness.setTModelInfos(new TModelInfos());
- findBusiness.getTModelInfos().getTModelInfo().add(tmi);
-
- break;
- }
[... 4745 lines stripped ...]
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org