public void Service() { Console.Out.WriteLine("DigitalSignature svc"); businessService bs = NewBusinessService(); SigningAndVerify(bs); }
private businessService getService() { businessService bs = new businessService(); bs.serviceKey = "hello"; bs.name = new name[] { new name("hi", "en") }; bs.businessKey = "asd"; return(bs); }
void runTest(String pathAndFile) { Assume.That(File.Exists(pathAndFile)); //Wadl Import example UDDIClient clerkManager = null; Transport transport = null; UDDIClerk clerk = null; clerkManager = new UDDIClient("uddi.xml"); transport = clerkManager.getTransport("default"); clerk = clerkManager.getClerk("default"); application app = WADL2UDDI.ParseWadl(pathAndFile); List <Uri> urls = WADL2UDDI.GetBaseAddresses(app); Assert.True(urls.Count > 0); Uri url = urls[0]; String domain = url.Host; tModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en"); Assert.NotNull(keygen); Assert.NotNull(keygen.tModelKey); Properties properties = new Properties(); properties.put("keyDomain", domain); properties.put("businessName", domain); properties.put("serverName", url.Host); properties.put("serverPort", url.Port.ToString()); WADL2UDDI wadl2UDDI = new WADL2UDDI(clerk, properties); businessService businessServices = wadl2UDDI.createBusinessService(new QName("MyWasdl.namespace", "Servicename"), app); if (serialize) { Console.Out.WriteLine(new PrintUDDI <businessService>().print(businessServices)); } Assert.NotNull(businessServices); Assert.NotNull(businessServices.bindingTemplates); foreach (bindingTemplate bt in businessServices.bindingTemplates) { Assert.NotNull(bt); Assert.NotNull(bt.bindingKey); Assert.NotNull(bt.Item); Assert.NotNull(bt.serviceKey); Assert.True(bt.Item is accessPoint); Assert.NotNull(((accessPoint)bt.Item).useType); Assert.NotNull(((accessPoint)bt.Item).Value); } Assert.True(businessServices.bindingTemplates.Length > 0); Assert.NotNull(businessServices.description); Assert.True(businessServices.description.Length > 0); Assert.NotNull(businessServices.serviceKey); }
private businessService NewBusinessService() { businessService bs = new businessService(); bs.bindingTemplates = new bindingTemplate[] { NewBindingTempalte() }; bs.businessKey = "asd"; bs.categoryBag = new categoryBag(); bs.categoryBag.Items = new object[] { new keyedReference("key", "name", "val") }; bs.name = new name[] { new name("stuff", null) }; bs.serviceKey = "asd"; return(bs); }
public static businessService[] MapBusinessServices(uddi.apiv2.businessService[] businessService) { if (businessService == null) { return(null); } List <businessService> r = new List <businessService>(); for (int i = 0; i < businessService.Length; i++) { businessService x = MapService(businessService[i]); r.Add(x); } return(r.ToArray()); }
public UddiService(businessService service, List <UddiBinding> uddiBindings) { if (service == null) { throw new ArgumentNullException("service"); } if (uddiBindings == null) { throw new ArgumentNullException("uddiBindings"); } this.service = service; this.categoryBag = new UddiCategoryBag(service.categoryBag); bindings = uddiBindings; }
public static businessService MapService(uddi.apiv2.businessService businessService) { if (businessService == null) { return(null); } businessService r = new businessService(); r.bindingTemplates = MapBinding(businessService.bindingTemplates); r.businessKey = businessService.businessKey; r.categoryBag = MapCategoryBag(businessService.categoryBag); r.description = MapDescription(businessService.description); r.name = MapNames(businessService.name); r.serviceKey = businessService.serviceKey; return(r); }
public List <businessService> readServiceAnnotations(string[] classes, Properties properties) { List <businessService> items = new List <businessService>(); if (classes != null) { foreach (string s in classes) { businessService b = readServiceAnnotations(s, properties); if (b != null) { items.Add(b); } } } return(items); }
/** * Removes the bindings of the services in the annotated classes. Multiple nodes may register * the same service using different BindingTempates. If the last BindingTemplate is removed * the service can be removed as well. * * @param removeServiceWithNoBindingTemplates - if set to true it will remove the service if there * are no other BindingTemplates. */ public void unRegisterBindingsOfAnnotatedServices(bool removeServiceWithNoBindingTemplates) { Dictionary <String, UDDIClerk> clerks = clientConfig.getUDDIClerks(); if (clerks.Count > 0) { AnnotationProcessor ap = new AnnotationProcessor(); Dictionary <string, UDDIClerk> .Enumerator it = clerks.GetEnumerator(); while (it.MoveNext()) { UDDIClerk c = it.Current.Value; List <businessService> services = ap.readServiceAnnotations( c.getClassWithAnnotations(), c.getUDDINode().getProperties()); foreach (businessService businessService in services) { if (businessService.bindingTemplates != null) { foreach (bindingTemplate bindingTemplate in businessService.bindingTemplates) { c.unRegisterBinding(bindingTemplate.bindingKey, c.getUDDINode().getApiNode()); } } if (removeServiceWithNoBindingTemplates) { try { businessService existingService = c.getServiceDetail(businessService.serviceKey, c.getUDDINode().getApiNode()); if (existingService.bindingTemplates == null || existingService.bindingTemplates.Length == 0) { c.unRegisterService(businessService.serviceKey, c.getUDDINode().getApiNode()); } } catch (Exception e) { log.error(e.Message, e); } } } } } }
/** * This will setup new a business, service, and binding template that's * versioned per the article linked above */ private void Setup() { businessEntity be = new businessEntity(); keygen = clerk.register(UDDIClerk.createKeyGenator(domain_prefix + "keygenerator", "my domain", lang)).tModel[0]; be.businessKey = (domain_prefix + "zerocoolbiz"); be.name = new name[] { new name("ZeroCool Business", lang) }; businessService bs = new businessService(); bs.name = new name[] { new name("ZeroCool Service", lang) }; bs.businessKey = (domain_prefix + "zerocoolbiz"); bs.serviceKey = (domain_prefix + "zerocoolsvc"); //version 1 bindingTemplate bt1 = new bindingTemplate(); String version = "1.0.0.0"; bt1.bindingKey = (domain_prefix + "binding10"); bt1.Item = (new accessPoint("http://localhost", "wsdl")); bt1.tModelInstanceDetails = new tModelInstanceInfo[] { UDDIClerk.createServiceInterfaceVersion(version, lang) }; //version 2 bindingTemplate bt2 = new bindingTemplate(); bt2.bindingKey = (domain_prefix + "binding12"); String version2 = "1.2.0.0"; bt2.Item = (new accessPoint("http://localhost", "wsdl")); bt2.tModelInstanceDetails = new tModelInstanceInfo[] { UDDIClerk.createServiceInterfaceVersion(version2, lang) }; bs.bindingTemplates = new bindingTemplate[] { bt1, bt2 }; be.businessServices = new businessService[] { bs }; clerk.register(be); }
/** * Creates a UDDI Business Service. * * @param serviceQName This must be specified to identify the namespace of * the service, which is used to set the service uddi key * @param waldDefinition * @return */ public businessService createBusinessService(QName serviceQName, application wadlDefinition) { log.debug("Constructing Service UDDI Information for " + serviceQName); businessService service = new businessService(); // BusinessKey service.businessKey = (businessKey); // ServiceKey service.serviceKey = (UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart())); // Description String serviceDescription = properties.getProperty(Property.SERVICE_DESCRIPTION, Property.DEFAULT_SERVICE_DESCRIPTION); // Override with the service description from the WSDL if present bool lengthwarn = false; List <description> ds = new List <description>(); if (wadlDefinition.doc != null) { for (int i = 0; i < wadlDefinition.doc.Length; i++) { String locallang = lang; description description = new description(); if (wadlDefinition.doc[i].lang != null) { locallang = (wadlDefinition.doc[i].lang); } if (locallang.Length > UDDIConstants.MAX_xml_lang_length) { lengthwarn = true; locallang = (locallang.Substring(0, UDDIConstants.MAX_xml_lang_length - 1)); } StringBuilder sb = new StringBuilder(); sb.Append(wadlDefinition.doc[i].title).Append(" "); sb.Append(ContentToString(wadlDefinition.doc[i].Any)); ds.AddRange(Common2UDDI.mapdescription(sb.ToString(), locallang)); } } else { ds.AddRange(Common2UDDI.mapdescription(serviceDescription, lang)); } service.description = ds.ToArray(); // Service name name sName = new name(); sName.lang = (lang); if (wadlDefinition.doc != null && wadlDefinition.doc.Length > 0) { sName.Value = (wadlDefinition.doc[0].title); } if (sName.Value == null) { sName.Value = (serviceQName.getLocalPart()); } service.name = new name[] { sName }; categoryBag cb = new categoryBag(); List <keyedReference> krs = new List <keyedReference>(); String ns = serviceQName.getNamespaceURI(); if (ns != null && ns != "") { keyedReference namespaceReference = new keyedReference( "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", ns); krs.Add(namespaceReference); } keyedReference serviceReference = new keyedReference( "uddi:uddi.org:wadl:types", "uddi-org:wadl:types", "service"); krs.Add(serviceReference); keyedReference localNameReference = new keyedReference( "uddi:uddi.org:xml:localname", "uddi-org:xml:localName", serviceQName.getLocalPart()); krs.Add(localNameReference); cb.Items = krs.ToArray(); service.categoryBag = (cb); if (wadlDefinition.resources != null) { for (int i = 0; i < wadlDefinition.resources.Length; i++) { bindingTemplate bindingTemplate = createWADLBinding(serviceQName, getDocTitle(wadlDefinition.resources[i].doc), new Uri(wadlDefinition.resources[i].@base), wadlDefinition.resources[i]); service.bindingTemplates = new bindingTemplate[] { bindingTemplate }; } } if (lengthwarn) { log.warn("Some object descriptions are longer than the maximum allowed by UDDI and have been truncated."); } return(service); }
public static void main(string[] args) { UDDIClient clerkManager = null; Transport transport = null; UDDIClerk clerk = null; try { clerkManager = new UDDIClient("uddi.xml"); transport = clerkManager.getTransport("default_non_root"); UDDI_Security_SoapBinding security = transport.getUDDISecurityService(); UDDI_Inquiry_SoapBinding inquiry = transport.getUDDIInquiryService(); UDDI_Publication_SoapBinding publish = transport.getUDDIPublishService(); clerk = clerkManager.getClerk("default_non_root"); //Wadl Import example application app = WADL2UDDI.ParseWadl("..\\..\\..\\juddi-client.net.test\\resources\\sample.wadl"); List <Uri> urls = WADL2UDDI.GetBaseAddresses(app); Uri url = urls[0]; String domain = url.Host; tModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en"); //save the keygen save_tModel stm = new save_tModel(); stm.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl()); stm.tModel = new tModel[] { keygen }; publish.save_tModel(stm); Properties properties = new Properties(); properties.put("keyDomain", domain); properties.put("businessName", domain); properties.put("serverName", url.Host); properties.put("serverPort", url.Port.ToString()); //wsdlURL = wsdlDefinition.getDocumentBaseURI(); WADL2UDDI wadl2UDDI = new WADL2UDDI(clerk, properties); businessService businessServices = wadl2UDDI.createBusinessService(new QName("MyWasdl.namespace", "Servicename"), app); HashSet <tModel> portTypeTModels = wadl2UDDI.createWADLPortTypeTModels(url.ToString(), app); //When parsing a WSDL, there's really two things going on //1) convert a bunch of stuff (the portTypes) to tModels //2) convert the service definition to a BusinessService //Since the service depends on the tModel, we have to save the tModels first save_tModel tms = new save_tModel(); tms.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl()); HashSet <tModel> .Enumerator it = portTypeTModels.GetEnumerator(); List <tModel> ts = new List <tModel>(); while (it.MoveNext()) { ts.Add(it.Current); } tModel[] tmodels = ts.ToArray(); tms.tModel = tmodels; if (tms.tModel.Length > 0) { //important, you'll need to save your new tModels, or else saving the business/service may fail publish.save_tModel(tms); } //finaly, we're ready to save all of the services defined in the WSDL //again, we're creating a new business, if you have one already, look it up using the Inquiry getBusinessDetails // inquiry.find_tModel(new find_tModel save_business sb = new save_business(); // sb.setAuthInfo(rootAuthToken.getAuthInfo()); businessEntity be = new businessEntity(); be.businessKey = (businessServices.businessKey); //TODO, use some relevant here be.name = new name[] { new name(domain, "en") }; be.businessServices = new businessService[] { businessServices }; sb.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl()); sb.businessEntity = new businessEntity[] { be }; publish.save_business(sb); Console.Out.WriteLine("Saved!"); } catch (Exception ex) { while (ex != null) { System.Console.WriteLine("Error! " + ex.Message); ex = ex.InnerException; } } finally { if (transport != null && transport is IDisposable) { ((IDisposable)transport).Dispose(); } if (clerk != null) { clerk.Dispose(); } } }
public void setBusinessService(businessService businessService) { this.businessService = businessService; }
public businessService readServiceAnnotations(String classWithAnnotations, Properties properties) { Type t = Type.GetType(classWithAnnotations, false, true); if (t != null) { businessService service = new businessService(); object[] attrib = t.GetCustomAttributes(typeof(UDDIService), true); object[] ws = t.GetCustomAttributes(typeof(System.Web.Services.WebServiceBindingAttribute), true); WebServiceBindingAttribute webServiceAnnotation = null; if (ws != null && ws.Length > 0) { webServiceAnnotation = ((WebServiceBindingAttribute[])ws)[0]; } if (attrib != null && attrib.Length > 0) { UDDIService[] bits = attrib as UDDIService[]; UDDIService uddiService = bits[0]; name n = new name(); n.lang = uddiService.lang; service.businessKey = (TokenResolver.replaceTokens(uddiService.businessKey, properties)); service.serviceKey = (TokenResolver.replaceTokens(uddiService.serviceKey, properties)); if (!"".Equals(uddiService.serviceName, StringComparison.CurrentCultureIgnoreCase)) { n.Value = (TokenResolver.replaceTokens(uddiService.serviceName, properties)); } else if (webServiceAnnotation != null && !"".Equals(webServiceAnnotation.Name)) { n.Value = (webServiceAnnotation.Name); } else { n.Value = (classWithAnnotations); } service.name = new name[] { n }; description d = new description(); d.lang = (uddiService.lang); d.Value = (TokenResolver.replaceTokens(uddiService.description, properties)); service.description = new description[] { d }; //categoryBag on the service if (!"".Equals(uddiService.categoryBag)) { categoryBag categoryBag = parseCategoryBag(uddiService.categoryBag); service.categoryBag = (categoryBag); } //bindingTemplate on service bindingTemplate bindingTemplate = parseServiceBinding(classWithAnnotations, uddiService.lang, webServiceAnnotation, properties); if (bindingTemplate != null) { bindingTemplate.serviceKey = (service.serviceKey); if (service.bindingTemplates == null) { service.bindingTemplates = new bindingTemplate[] { bindingTemplate }; } else { List <bindingTemplate> l = new List <bindingTemplate>(); l.AddRange(service.bindingTemplates); l.Add(bindingTemplate); service.bindingTemplates = l.ToArray(); } } return(service); } else { log.error("Missing UDDIService annotation in class " + classWithAnnotations); } } log.error("Unable to load type " + classWithAnnotations); return(null); }
public static void Run(string[] args) { UDDIClient clerkManager = null; Transport transport = null; UDDIClerk clerk = null; try { clerkManager = new UDDIClient("uddi.xml"); transport = clerkManager.getTransport("default"); UDDI_Security_SoapBinding security = transport.getUDDISecurityService(); UDDI_Inquiry_SoapBinding inquiry = transport.getUDDIInquiryService(); UDDI_Publication_SoapBinding publish = transport.getUDDIPublishService(); clerk = clerkManager.getClerk("default"); find_business fb = new find_business(); fb.authInfo = clerk.getAuthToken(security.Url); fb.findQualifiers = new string[] { UDDIConstants.APPROXIMATE_MATCH }; fb.name = new name[1]; fb.name[0] = new name(UDDIConstants.WILDCARD, "en"); businessList bl = inquiry.find_business(fb); if (bl.businessInfos.Length > 0) { Console.Out.WriteLine(bl.businessInfos[0].name[0].Value); Console.Out.WriteLine("attempting to sign"); businessService sd = clerk.getServiceDetail(bl.businessInfos[0].serviceInfos[0].serviceKey); //pist, the signing config comes from the stuff in in uddi.xml DigSigUtil ds = new DigSigUtil(clerkManager.getClientConfig().getDigitalSignatureConfiguration()); businessService signedsvc = (businessService)ds.signUddiEntity(sd); PrintUDDI <businessService> p = new PrintUDDI <businessService>(); Console.Out.WriteLine("signed successfully!"); Console.Out.WriteLine(p.print(signedsvc)); Console.Out.WriteLine("attempting verify and validate"); String err = ""; bool valid = ds.verifySignedUddiEntity(signedsvc, out err); Console.Out.WriteLine("Signature is " + (valid ? "Valid, Yippy!" : "Invalid!") + " msg: " + err); Console.Out.WriteLine("saving"); clerk.register(signedsvc); Console.Out.WriteLine("reloading content from the server..."); get_serviceDetail gsd = new get_serviceDetail(); gsd.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl()); gsd.serviceKey = new string[] { signedsvc.serviceKey }; sd = inquiry.get_serviceDetail(gsd).businessService[0]; Console.Out.WriteLine(p.print(sd)); Console.Out.WriteLine("attempting verify and validate"); err = ""; valid = ds.verifySignedUddiEntity(sd, out err); Console.Out.WriteLine("Signature is " + (valid ? "Valid, Yippy!" : "Invalid!") + " msg: " + err); } else { Console.Out.WriteLine("no businesses were returned!"); } } catch (Exception ex) { while (ex != null) { System.Console.WriteLine("Error! " + ex.Message); ex = ex.InnerException; } } finally { if (transport != null && transport is IDisposable) { ((IDisposable)transport).Dispose(); } if (clerk != null) { clerk.Dispose(); } } }