コード例 #1
0
        /// <summary>
        /// From file
        /// create business, save in juddi, download from juddi, sign and save it,
        /// download it again, verify sig is valid
        /// </summary>
        /// <param name="config"></param>
        void SignSaveAndVerifyToJuddi(String config)
        {
            UDDIClient clerkManager = null;
            Transport transport = null;
            UDDIClerk clerk = null;
            try
            {
                clerkManager = new UDDIClient(config);
                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");

                businessEntity be = new businessEntity();
                be.name = new name[] { new name("Test biz", "en") };

                Console.Out.WriteLine("saving test biz");
                businessEntity complete = clerk.register(be);
                Console.Out.WriteLine("attempting to sign");

                DigSigUtil ds = new DigSigUtil(clerkManager.getClientConfig().getDigitalSignatureConfiguration());
                businessEntity signed = (businessEntity)ds.signUddiEntity(complete);

                PrintUDDI<businessEntity> p = new PrintUDDI<businessEntity>();
                Console.Out.WriteLine("signed successfully!");
                if (serialize)
                    Console.Out.WriteLine(p.print(signed));

                Console.Out.WriteLine("attempting verify signature locally");
                String err = "";
                bool valid = ds.verifySignedUddiEntity(signed, out err);
                Console.Out.WriteLine("Signature is " + (valid ? "Valid, Yippy!" : "Invalid!") + " msg: " + err);
                Assert.True(valid);
                Assert.True(String.IsNullOrEmpty(err));

                Console.Out.WriteLine("saving to signed entity to the registry");
                clerk.register(signed);
                Console.Out.WriteLine("reloading content from the server...");

                get_businessDetail gsd = new get_businessDetail();
                gsd.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                gsd.businessKey = new string[] { signed.businessKey };
                businessDetail saved = inquiry.get_businessDetail(gsd);

                Console.Out.WriteLine("done. attempting verify signed entity");
                if (serialize)
                    Console.Out.WriteLine(p.print(saved.businessEntity[0]));

                err = "";
                valid = ds.verifySignedUddiEntity(saved.businessEntity[0], out err);
                Console.Out.WriteLine("Signature is " + (valid ? "Valid, Yippy!" : "Invalid!") + " msg: " + err);

            }
            catch (Exception ex)
            {
                while (ex != null)
                {
                    System.Console.WriteLine("Error! " + ex.Message);
                    ex = ex.InnerException;
                }
                throw ex;
            }
            finally
            {
                if (transport != null && transport is IDisposable)
                {
                    ((IDisposable)transport).Dispose();
                }
                if (clerk != null)
                    clerk.Dispose();
            }
        }
コード例 #2
0
ファイル: MapUDDIv2to3.cs プロジェクト: lazycrazyowl/juddi
 public static businessEntity MapBusinessEntity(uddi.apiv2.businessEntity businessEntity)
 {
     if (businessEntity == null) return null;
     businessEntity be = new businessEntity();
     be.businessKey = businessEntity.businessKey;
     be.categoryBag = MapCategoryBag(businessEntity.categoryBag);
     be.contacts = MapContacts(businessEntity.contacts);
     be.description = MapDescription(businessEntity.description);
     be.discoveryURLs = MapDiscoUrls(businessEntity.discoveryURLs);
     be.name = MapNames(businessEntity.name);
     be.identifierBag = MapIdentifierBag(businessEntity.identifierBag);
     be.businessServices = MapBusinessServices(businessEntity.businessServices);
     return be;
 }
コード例 #3
0
ファイル: WadlImport.cs プロジェクト: lazycrazyowl/juddi
        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();
            }
        }
コード例 #4
0
        /**
         * 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);
        }
コード例 #5
0
        public void Business()
        {
            Console.Out.WriteLine("DigitalSignature biz");
            businessEntity be = new businessEntity();
            be.businessKey = "uddi:business";
            be.businessServices = new businessService[] { NewBusinessService() };
            be.name = new name[] { new name("stuff", null) };
            be.identifierBag = new keyedReference[] { new keyedReference("key", "name", "val") };
            be.categoryBag = new categoryBag();
            be.categoryBag.Items = new object[] { new keyedReference("key", "name", "val") };
            be.contacts = new contact[] { new contact() };

            be.contacts[0].useType = "admin";
            be.contacts[0].personName = new personName[] { new personName("bob", "en") };
            be.businessServices = new businessService[] { getService() };

            SigningAndVerify(be);
        }
コード例 #6
0
        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_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");

                //this part just confirms that the keydomain exists for our new service and binding template
                String keydomain = null;
                if (clerkManager.getClientConfig().getConfiguration() != null &&
                     clerkManager.getClientConfig().getConfiguration().client != null &&
                     clerkManager.getClientConfig().getConfiguration().client.subscriptionCallbacks != null &&
                     clerkManager.getClientConfig().getConfiguration().client.subscriptionCallbacks.keyDomain != null)
                    keydomain = clerkManager.getClientConfig().getConfiguration().client.subscriptionCallbacks.keyDomain;
                else
                    keydomain = "uddi:org.apache.demos";
                tModel createKeyGenator = UDDIClerk.createKeyGenator(keydomain + ":keygenerator", "Test domain", "en");
                clerk.register(createKeyGenator);

                //we'll also create a business and a service here so that we can hook in our callback endpoint
                businessEntity be = new businessEntity();

                be.businessKey = keydomain + ":coolbizexample";
                be.name = new name[] { new name("Coolbiz Inc", "en") };
                be.businessServices = new businessService[] { new businessService() };
                be.businessServices[0].businessKey = keydomain + ":coolbizexample";
                be.businessServices[0].serviceKey = keydomain + ":coolbizexample-service";
                be.businessServices[0].name = new name[] { new name("Coolbiz Service", "en") };
                clerk.register(be);

                bindingTemplate start = SubscriptionCallbackListener.start(clerkManager, "default_non_root");
                Console.WriteLine("Started and waiting for inbound traffic");
                //bkeep alive
                DateTime stop = DateTime.Now.Add(new TimeSpan(0, 0, 10));
                while (DateTime.Now < stop)
                {
                    Thread.Sleep(1000);
                }
                Console.WriteLine("Stopping");
                SubscriptionCallbackListener.stop(clerkManager, "default_non_root", start.bindingKey);

                //get rid of it once we're done
                clerk.unRegisterBusiness(keydomain + ":coolbizexample");
                clerk.unRegisterTModel(createKeyGenator.tModelKey);
            }
            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();
            }
        }