Пример #1
0
        public void TestAutomatedAnnotatedClassRegistration()
        {
            //TODO
            //Normally, this code snippet would be executed by some kind of web service life cycle listener
            //such as global.asax
            //a web service contructor
            Type t = typeof(HelloImpl);

            Console.Out.WriteLine(t.AssemblyQualifiedName);
            UDDIClient clerkManager = null;
            Transport  transport    = null;
            UDDIClerk  clerk        = null;

            clerkManager = new UDDIClient("resource/uddi-autoregAnnotations.xml");

            transport = clerkManager.getTransport("default");

            org.uddi.apiv3.UDDI_Security_SoapBinding security = transport.getUDDISecurityService();
            org.uddi.apiv3.UDDI_Inquiry_SoapBinding  inquiry  = transport.getUDDIInquiryService();

            clerk = clerkManager.getClerk("default");
            clerkManager.registerAnnotatedServices();

            //TODO confirm it registered

            //this is more of an "onShutdown" event
            clerkManager.unRegisterAnnotatedServices();
            //Thread.Sleep(15000);
        }
Пример #2
0
        public void Tmodel()
        {
            Console.Out.WriteLine("DigitalSignature tmodel");
            tModel bs = UDDIClerk.createKeyGenator("part", "desc", "en");

            SigningAndVerify(bs);
        }
Пример #3
0
 public XRegistration(String entityKey, UDDIClerk fromClerk,
                      UDDIClerk toClerk)
 {
     this.fromClerk = fromClerk;
     this.toClerk   = toClerk;
     this.entityKey = entityKey;
 }
Пример #4
0
        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");

                UDDI_Security_SoapBinding    security = transport.getUDDISecurityService();
                UDDI_Inquiry_SoapBinding     inquiry  = transport.getUDDIInquiryService();
                UDDI_Publication_SoapBinding publish  = transport.getUDDIPublishService();
                JUDDIApiService juddi = transport.getJUDDIApiService();

                clerk = clerkManager.getClerk("default");

                clerk newclerk = new clerk();
                newclerk.node      = new node();
                newclerk.node.name = "juddicloud";
                newclerk.publisher = "root";
                newclerk.password  = "******";

                newclerk.name = "juddicloud";
                UDDIClerk cc = new UDDIClerk(newclerk);


                save_clerk saveClerk = new save_clerk();
                saveClerk.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                saveClerk.clerk    = new clerk[] { newclerk };
                clerk[] ret = juddi.save_Clerk(saveClerk);

                Console.Out.WriteLine(ret.Length);
            }
            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();
                }
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
        public static void Run()
        {
            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");


                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);
                for (int i = 0; i < bl.businessInfos.Length; i++)
                {
                    Console.WriteLine(bl.businessInfos[i].name[0].Value);
                }
                //  serviceDetail s= clerk.getServiceDetail("uddi:mydomain.com:zerocoolsvc");
                //   Console.Out.WriteLine(new PrintUDDI<serviceDetail>().print(s));
            }
            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();
                }
            }
        }
Пример #7
0
        public void xr_subscriptionFilterws()
        {
            Console.Out.WriteLine("serialization xr_subscriptionFilterws");
            Console.Out.WriteLine("xr_subscriptionFilterws");
            subscriptionFilter r            = new subscriptionFilter();
            UDDIClient         clerkManager = null;
            Transport          transport    = null;
            UDDIClerk          clerk        = null;

            try
            {
                clerkManager = new UDDIClient("uddi.xml");
                transport    = clerkManager.getTransport("default");
                org.uddi.apiv3.UDDI_Security_SoapBinding        security = transport.getUDDISecurityService();
                org.uddi.apiv3.UDDI_Inquiry_SoapBinding         inquiry  = transport.getUDDIInquiryService();
                org.uddi.apiv3.UDDI_Publication_SoapBinding     publish  = transport.getUDDIPublishService();
                org.uddi.apiv3.UDDI_CustodyTransfer_SoapBinding custody  = transport.getUDDICustodyTransferService();
                org.uddi.apiv3.UDDI_Subscription_SoapBinding    sub      = transport.getUDDISubscriptionService();
                clerk = clerkManager.getClerk("default");

                save_subscription ss = new save_subscription();
                ss.subscription = new subscription[] { new subscription() };
                ss.subscription[0].subscriptionFilter = r;
                sub.save_subscription(ss);
            }
            catch (Exception ex)
            {
                String s = "";
                while (ex != null)
                {
                    s  = s + ex.Message;
                    ex = ex.InnerException;
                }
                if (ContainsSerializationError(s))
                {
                    Assert.Fail(s);
                }
            }
            finally
            {
                if (transport != null && transport is IDisposable)
                {
                    ((IDisposable)transport).Dispose();
                }
                if (clerk != null)
                {
                    clerk.Dispose();
                }
            }
        }
        public static void stop(UDDIClient client, String cfg_node_name, String bindingKey)
        {
            //stop the service
            if (ep != null && ep.State == CommunicationState.Opened)
            {
                log.warn("Stopping jUDDI Subscription callback endpoint at " + callback);
                ep.Close();
                if (ep.State != CommunicationState.Closed && ep.State != CommunicationState.Closing)
                {
                    log.error("Unable to stop the endpoint. the port may be locked until this process terminates");
                }
                ep       = null;
                callback = null;
            }
            unregisterAllCallbacks();

            if (client.getClientConfig().getConfiguration().client != null &&
                client.getClientConfig().getConfiguration().client.subscriptionCallbacks != null &&
                client.getClientConfig().getConfiguration().client.subscriptionCallbacks.signatureBehavior != null &&
                client.getClientConfig().getConfiguration().client.subscriptionCallbacks.signatureBehavior.Equals("true", StringComparison.CurrentCultureIgnoreCase) &&
                bindingKey != null)
            {
                log.info("Attempting to unregister the binding");
                try
                {
                    UDDIClerk clerk = client.getClerk(cfg_node_name);
                    Transport tp    = client.getTransport(cfg_node_name);
                    String    token = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                    UDDI_Publication_SoapBinding uddiPublishService = tp.getUDDIPublishService();
                    delete_binding db = new delete_binding();
                    db.authInfo   = (token);
                    db.bindingKey = new string[] { (bindingKey) };
                    uddiPublishService.delete_binding(db);
                }
                catch (Exception ex)
                {
                    log.error("Unable to unregister binding " + bindingKey, ex);
                }
            }


            //TODO optionally kill the subscription?
            //get all subscriptions from the uddi node,
            //loop through and deduce which ones are pointed at this endpoint
            //then remove them
        }
Пример #9
0
        /**
         * this will look up our service by name and we'll discover multiple
         * bindings with different versions
         */
        private void ServiceLookUpByName()
        {
            //here we are assuming we don't know what key is used for the service, so we look it up
            find_service fs = new find_service();

            fs.findQualifiers = new string[] { UDDIConstants.EXACT_MATCH };
            fs.name           = new name[] { new name("ZeroCool Service", lang) };
            serviceList findService = inquiry.find_service(fs);

            //parse the results and get a list of services to get the details on
            get_serviceDetail gsd   = new get_serviceDetail();
            List <string>     items = new List <string>();

            for (int i = 0; i < findService.serviceInfos.Length; i++)
            {
                items.Add(findService.serviceInfos[i].serviceKey);
            }
            gsd.serviceKey = items.ToArray();
            serviceDetail          serviceDetail = inquiry.get_serviceDetail(gsd);
            List <bindingTemplate> ret           = new List <bindingTemplate>();
            //parse the service details, looking for our versioned service
            Boolean success = false;

            if (serviceDetail != null)
            {
                for (int i = 0; i < serviceDetail.businessService.Length; i++)
                {
                    if (serviceDetail.businessService[i].bindingTemplates != null)
                    {
                        List <bindingTemplate> bindingByVersion = UDDIClerk.getBindingByVersion("1.2.0.0",
                                                                                                serviceDetail.businessService[i].bindingTemplates);
                        for (int x = 0; x < bindingByVersion.Count; x++)
                        {
                            success = true;
                            Console.Out.WriteLine("SUCCESS! Found the right version on key " + bindingByVersion[x].bindingKey);
                            //TODO so now that you've found the right version of the right service
                            //now you can go execute that the url
                        }
                    }
                }
            }
            if (!success)
            {
                Console.Out.WriteLine("FAIL! We didn't find a damn thing matching that version number :(");
            }
        }
Пример #10
0
        /**
         * Saves the clerk and node info from the uddi.xml to the home jUDDI registry.
         * This info is needed if you want to JUDDI Server to do XRegistration/"replication".
         */
        public void saveClerkAndNodeInfo()
        {
            Dictionary <String, UDDIClerk> uddiClerks = clientConfig.getUDDIClerks();

            if (uddiClerks.Count > 0)
            {
                //obtaining a clerk that can write to the home registry
                UDDIClerk homeClerk = null;
                foreach (UDDIClerk clerk in uddiClerks.Values)
                {
                    if (clerk.getUDDINode().isHomeJUDDI())
                    {
                        homeClerk = clerk;
                    }
                }
                //registering nodes and clerks
                if (homeClerk != null)
                {
                    int numberOfHomeJUDDIs = 0;
                    foreach (UDDINode uddiNode in clientConfig.getUDDINodes().Values)
                    {
                        if (uddiNode.isHomeJUDDI())
                        {
                            numberOfHomeJUDDIs++;
                        }
                        homeClerk.saveNode(uddiNode.getApiNode());
                    }
                    if (numberOfHomeJUDDIs == 1)
                    {
                        foreach (UDDIClerk clerk in clientConfig.getUDDIClerks().Values)
                        {
                            //homeClerk.saveClerk(clerk);
                        }
                    }
                    else
                    {
                        log.error("The client config needs to have one homeJUDDI node and found " + numberOfHomeJUDDIs);
                    }
                }
                else
                {
                    log.debug("No home clerk found.");
                }
            }
        }
Пример #11
0
        public static void init()
        {
            if (Environment.GetEnvironmentVariable("debug") != null &&
                Environment.GetEnvironmentVariable("debug").Equals("true", StringComparison.CurrentCultureIgnoreCase))
            {
                serialize = true;
            }

            clerkManager = new UDDIClient("resource/uddi.xml");

            transport = clerkManager.getTransport("default");

            security = transport.getUDDISecurityService();
            inquiry  = transport.getUDDIInquiryService();
            publish  = transport.getUDDIPublishService();
            sub      = transport.getUDDISubscriptionService();
            clerk    = clerkManager.getClerk("default");
            node     = clerk.getUDDINode();
            WebClient c = new WebClient();

            Console.Out.WriteLine("Checking to see if tomcat is running");
            String s     = null;
            int    count = 100;

            while (s == null && count > 0)
            {
                try
                {
                    s = c.DownloadString("http://localhost:8080/");
                    Console.Out.WriteLine("Tomcat is running");
                    break;
                }
                catch
                { }
                Console.Out.WriteLine("tomcat isn't running yet, waiting...");
                Thread.Sleep(1000);
            }

            if (s == null)
            {
                Console.Out.WriteLine("Unable to confirm if tomcat is running, aborting");
                online = false;
            }
        }
Пример #12
0
        private HashSet <XRegistration> readXServiceBindingRegConfig(uddi config, Dictionary <String, UDDIClerk> clerks)
        {
            HashSet <XRegistration> xRegistrations = new HashSet <XRegistration>();

            if (config.client.clerks == null)
            {
                log.warn("XRegistration cannot continue, no clerks are defined!");
                return(xRegistrations);
            }
            if (config.client.clerks.xregister == null || config.client.clerks.xregister.servicebinding == null)
            {
                return(xRegistrations);
            }
            if (config.client.clerks.xregister.servicebinding.Length > 0)
            {
                log.info("XRegistration " + config.client.clerks.xregister.servicebinding.Length + " serviceBinding Keys");
            }
            for (int i = 0; i < config.client.clerks.xregister.servicebinding.Length; i++)
            {
                XRegistration xRegistration = new XRegistration();
                xRegistration.setEntityKey(config.client.clerks.xregister.servicebinding[i].bindingKey);

                String fromClerkRef = config.client.clerks.xregister.servicebinding[i].fromClerk;
                if (!clerks.ContainsKey(fromClerkRef))
                {
                    throw new ConfigurationErrorsException("Could not find fromClerk with name=" + fromClerkRef);
                }
                UDDIClerk fromClerk = clerks[(fromClerkRef)];
                xRegistration.setFromClerk(fromClerk);

                String toClerkRef = config.client.clerks.xregister.servicebinding[i].toClerk;
                if (!clerks.ContainsKey(toClerkRef))
                {
                    throw new ConfigurationErrorsException("Could not find toClerk with name=" + toClerkRef);
                }
                UDDIClerk toClerk = clerks[(toClerkRef)];
                xRegistration.setToClerk(toClerk);
                log.debug(xRegistration);

                xRegistrations.Add(xRegistration);
            }
            return(xRegistrations);
        }
Пример #13
0
        public WADL2UDDI(UDDIClerk clerk, Properties properties)
        {
            this.clerk      = clerk;
            this.properties = properties;

            if (clerk != null)
            {
                if (!properties.containsKey("keyDomain"))
                {
                    throw new ConfigurationErrorsException("Property keyDomain is a required property when using WADL2UDDI.");
                }
                if (!properties.containsKey("businessKey") && !properties.containsKey("businessName"))
                {
                    throw new ConfigurationErrorsException("Either property businessKey, or businessName, is a required property when using WADL2UDDI.");
                }
                if (!properties.containsKey("nodeName"))
                {
                    if (properties.containsKey("serverName") && properties.containsKey("serverPort"))
                    {
                        String nodeName = properties.getProperty("serverName") + "_" + properties.getProperty("serverPort");
                        properties.setProperty("nodeName", nodeName);
                    }
                    else
                    {
                        throw new ConfigurationErrorsException("Property nodeName is not defined and is a required property when using WADL2UDDI.");
                    }
                }
            }

            //Obtaining values from the properties
            this.keyDomainURI = "uddi:" + properties.getProperty("keyDomain") + ":";
            if (properties.containsKey(Property.BUSINESS_KEY))
            {
                this.businessKey = properties.getProperty(Property.BUSINESS_KEY);
            }
            else
            {
                //using the BusinessKey Template, and the businessName to construct the key
                this.businessKey = UDDIKeyConvention.getBusinessKey(properties);
            }
            this.lang = properties.getProperty(Property.LANG, Property.DEFAULT_LANG);
        }
Пример #14
0
        /**
         * Removes the service and all of its bindingTemplates of the annotated classes.
         */
        public void unRegisterAnnotatedServices()
        {
            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)
                    {
                        c.unRegisterService(businessService.serviceKey, c.getUDDINode().getApiNode());
                    }
                }
            }
        }
Пример #15
0
        /**
         * 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);
                            }
                        }
                    }
                }
            }
        }
Пример #16
0
        /// <summary>
        /// Registers services to UDDI using a clerk, and the uddi.xml configuration.
        /// For .NET users, the class names must be AssemblyQualifiedNames
        /// </summary>
        /// <pre>
        /// Type objType = typeof(System.Array);
        /// Console.WriteLine ("Qualified assembly name:\n   {0}.", objType.AssemblyQualifiedName.ToString());
        /// </pre>
        public void registerAnnotatedServices()
        {
            Dictionary <String, UDDIClerk> uddiClerks = clientConfig.getUDDIClerks();

            if (uddiClerks.Count > 0)
            {
                AnnotationProcessor ap = new AnnotationProcessor();
                Dictionary <string, UDDIClerk> .Enumerator it = uddiClerks.GetEnumerator();
                while (it.MoveNext())
                {
                    UDDIClerk c = it.Current.Value;
                    List <businessService> services = ap.readServiceAnnotations(
                        c.getClassWithAnnotations(), c.getUDDINode().getProperties());
                    foreach (businessService businessService in services)
                    {
                        log.info("Node=" + c.getUDDINode().getApiNode().name);
                        c.register(businessService, c.getUDDINode().getApiNode());
                    }
                }
            }
        }
Пример #17
0
        public void xr_subscriptionResultsListws()
        {
            Console.Out.WriteLine("serialization xr_subscriptionResultsListws");
            subscriptionResultsList r = new subscriptionResultsList();
            UDDIClient clerkManager   = null;
            Transport  transport      = null;
            UDDIClerk  clerk          = null;

            try
            {
                clerkManager = new UDDIClient("uddi.xml");
                transport    = clerkManager.getTransport("default");
                org.uddi.apiv3.UDDI_Security_SoapBinding        security = transport.getUDDISecurityService();
                org.uddi.apiv3.UDDI_Inquiry_SoapBinding         inquiry  = transport.getUDDIInquiryService();
                org.uddi.apiv3.UDDI_Publication_SoapBinding     publish  = transport.getUDDIPublishService();
                org.uddi.apiv3.UDDI_CustodyTransfer_SoapBinding custody  = transport.getUDDICustodyTransferService();
                org.uddi.apiv3.UDDI_Subscription_SoapBinding    sub      = transport.getUDDISubscriptionService();
                clerk = clerkManager.getClerk("default");
            }
            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();
                }
            }
        }
Пример #18
0
        static void Main(string[] args)
        {
            Type t = typeof(HelloWorldWCF);

            Console.Out.WriteLine(t.AssemblyQualifiedName);
            UDDIClient clerkManager = null;
            Transport  transport    = null;
            UDDIClerk  clerk        = null;

            clerkManager = new UDDIClient("uddi.xml");

            transport = clerkManager.getTransport("default");

            org.uddi.apiv3.UDDI_Security_SoapBinding security = transport.getUDDISecurityService();
            org.uddi.apiv3.UDDI_Inquiry_SoapBinding  inquiry  = transport.getUDDIInquiryService();

            clerk = clerkManager.getClerk("default");
            clerkManager.registerAnnotatedServices();
            HelloWorldWCF x = new HelloWorldWCF();

            //   clerkManager.unRegisterAnnotatedServices();
            Thread.Sleep(15000);
        }
Пример #19
0
 private void Init()
 {
     try {
         // create a client and read the config in the archive;
         // you can use your config file name
         client = new UDDIClient("uddi.xml");
         clerk  = client.getClerk("default_non_root");
         // a UddiClient can be a client to multiple UDDI nodes, so
         // supply the nodeName (defined in your uddi.xml.
         // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
         Transport transport = client.getTransport("default_non_root");
         // Now you create a reference to the UDDI API
         security = transport.getUDDISecurityService();
         inquiry  = transport.getUDDIInquiryService();
         publish  = transport.getUDDIPublishService();
     } catch (Exception e) {
         while (e != null)
         {
             Console.Out.WriteLine(e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine);
             e = e.InnerException;
         }
     }
 }
Пример #20
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);
        }
Пример #21
0
        private Dictionary <String, UDDIClerk> readClerkConfig(uddi config, Dictionary <String, UDDINode> uddiNodes)
        {
            clientName = config.client.name;
            Dictionary <String, UDDIClerk> clerks = new Dictionary <String, UDDIClerk>();

            if (config.client.clerks != null && config.client.clerks.clerk != null && config.client.clerks.clerk.Length > 0)//.ContainsKey("client.clerks.clerk[@name]"))
            {
                log.debug("clerk names=" + config.client.clerks.clerk.Length);
                for (int i = 0; i < config.client.clerks.clerk.Length; i++)
                {
                    UDDIClerk uddiClerk = new UDDIClerk();
                    uddiClerk.setManagerName(clientName);
                    uddiClerk.setName(config.client.clerks.clerk[i].name);
                    String nodeRef = config.client.clerks.clerk[i].node;
                    if (!uddiNodes.ContainsKey(nodeRef))
                    {
                        throw new ConfigurationErrorsException("Could not find Node with name=" + nodeRef);
                    }
                    UDDINode uddiNode = uddiNodes[nodeRef];
                    uddiClerk.setUDDInode(uddiNode);
                    uddiClerk.setPublisher(config.client.clerks.clerk[i].publisher);
                    uddiClerk.setPassword(config.client.clerks.clerk[i].password);
                    uddiClerk.setPasswordEncrypted(config.client.clerks.clerk[i].isPasswordEncrypted);
                    uddiClerk.setCryptoProvider(config.client.clerks.clerk[i].cryptoProvider);

                    String clerkBusinessKey  = config.client.clerks.clerk[i].businessKey;
                    String clerkBusinessName = config.client.clerks.clerk[i].businessName;
                    String clerkKeyDomain    = config.client.clerks.clerk[i].keyDomain;

                    String[] classes = config.client.clerks.clerk[i].@class;
                    uddiClerk.setClassWithAnnotations(classes);

                    int numberOfWslds = 0;
                    if (config.client.clerks.clerk[i].wsdl != null)
                    {
                        numberOfWslds = config.client.clerks.clerk[i].wsdl.Length;// config.getStringArray("client.clerks.clerk(" + i + ").wsdl").Length;
                    }
                    if (numberOfWslds > 0)
                    {
                        UDDIClerk.WSDL[] wsdls = new UDDIClerk.WSDL[numberOfWslds];
                        for (int w = 0; w < wsdls.Length; w++)
                        {
                            UDDIClerk.WSDL wsdl     = new UDDIClerk.WSDL();
                            String         fileName = config.client.clerks.clerk[i].wsdl[w].Value;
                            wsdl.setFileName(null);
                            String businessKey  = config.client.clerks.clerk[i].wsdl[w].businessKey;
                            String businessName = config.client.clerks.clerk[i].wsdl[w].businessName;
                            String keyDomain    = config.client.clerks.clerk[i].wsdl[w].keyDomain;
                            if (businessKey == null)
                            {
                                businessKey = clerkBusinessKey;
                            }
                            if (businessKey == null)
                            {
                                businessKey = uddiClerk.getUDDINode().getProperties().getString("businessKey");
                            }
                            if (businessKey == null)
                            {
                                //use key convention to build the businessKey
                                if (businessName == null)
                                {
                                    businessName = clerkBusinessName;
                                }
                                if (keyDomain == null)
                                {
                                    keyDomain = clerkKeyDomain;
                                }
                                if (keyDomain == null)
                                {
                                    keyDomain = uddiClerk.getUDDINode().getProperties().getString("keyDomain");
                                }
                                if ((businessName == null && !uddiClerk.getUDDINode().getProperties().containsKey("businessName")) ||
                                    keyDomain == null && !uddiClerk.getUDDINode().getProperties().containsKey("keyDomain"))
                                {
                                    throw new ConfigurationErrorsException("Either the wsdl(" + wsdls[w]
                                                                           + ") or clerk (" + uddiClerk.getName() + ") elements require a businessKey, or businessName & keyDomain attributes");
                                }
                                else
                                {
                                    Properties properties = (uddiClerk.getUDDINode().getProperties());
                                    if (businessName != null)
                                    {
                                        properties.setProperty("businessName", businessName);
                                    }
                                    if (keyDomain != null)
                                    {
                                        properties.setProperty("keyDomain", keyDomain);
                                    }
                                    businessKey = UDDIKeyConvention.getBusinessKey(properties);
                                }
                            }
                            if (!businessKey.ToLower().StartsWith("uddi:") || !businessKey.Substring(5).Contains(":"))
                            {
                                throw new ConfigurationErrorsException("The businessKey " + businessKey + " does not implement a valid UDDI v3 key format.");
                            }
                            wsdl.setBusinessKey(businessKey);
                            if (keyDomain == null)
                            {
                                keyDomain = businessKey.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries)[1];
                            }
                            wsdl.setKeyDomain(keyDomain);
                            wsdls[w] = wsdl;
                        }
                        uddiClerk.setWsdls(wsdls);
                    }

                    clerks.Add(uddiClerk.getName(), uddiClerk);
                }
            }
            else
            {
                log.warn("No clerks are defined!");
            }
            return(clerks);
        }
Пример #22
0
        internal static void Run(string[] args)
        {
            UDDIClient clerkManager = null;
            Transport  transport    = null;
            UDDIClerk  clerk        = null;

            try
            {
                clerkManager = new UDDIClient("uddi.xml");

                transport = clerkManager.getTransport("uddiv2");

                UDDI_Security_SoapBinding    security = transport.getUDDISecurityService();
                UDDI_Inquiry_SoapBinding     inquiry  = transport.getUDDIInquiryService();
                UDDI_Publication_SoapBinding publish  = transport.getUDDIPublishService();

                clerk = clerkManager.getClerk("uddiv2");

                save_business sb = new save_business();
                get_authToken rq = new get_authToken();
                rq.cred   = "username";
                rq.userID = "username";
                String token = security.get_authToken(rq).authInfo;
                System.Console.WriteLine("Got an auth token...");
                sb.authInfo                      = token;
                sb.businessEntity                = new businessEntity[1];
                sb.businessEntity[0]             = new businessEntity();
                sb.businessEntity[0].name        = new name[] { new name("test business from .net via uddi2 translation", "en") };
                sb.businessEntity[0].description = new description[] { new description("a description", "en") };
                businessDetail detail = publish.save_business(sb);
                System.Console.WriteLine("business saved");
                PrintUDDI <businessDetail> p = new PrintUDDI <businessDetail>();
                Console.Out.WriteLine(p.print(detail));

                save_service ss = new save_service();
                ss.authInfo                       = token;
                ss.businessService                = new businessService[1];
                ss.businessService[0]             = new businessService();
                ss.businessService[0].name        = new name[] { new name("hello world", "en") };
                ss.businessService[0].businessKey = detail.businessEntity[0].businessKey;
                serviceDetail sd = publish.save_service(ss);
                System.Console.WriteLine("service saved");
                PrintUDDI <serviceDetail> p1 = new PrintUDDI <serviceDetail>();
                Console.Out.WriteLine(p1.print(sd));

                save_binding sbd = new save_binding();
                sbd.authInfo                      = token;
                sbd.bindingTemplate               = new bindingTemplate[1];
                sbd.bindingTemplate[0]            = new bindingTemplate();
                sbd.bindingTemplate[0].Item       = new accessPoint("http://localhost", "endPoint");
                sbd.bindingTemplate[0].serviceKey = sd.businessService[0].serviceKey;
                bindingDetail bd = publish.save_binding(sbd);
                System.Console.WriteLine("binding saved");
                PrintUDDI <bindingDetail> p2 = new PrintUDDI <bindingDetail>();
                Console.Out.WriteLine(p2.print(bd));

                save_tModel stm = new save_tModel();
                stm.authInfo       = token;
                stm.tModel         = new tModel[1];
                stm.tModel[0]      = new tModel();
                stm.tModel[0].name = new name("a uddiv2 tmodel", "en");
                tModelDetail td = publish.save_tModel(stm);
                System.Console.WriteLine("tModel saved");
                PrintUDDI <tModelDetail> p3 = new PrintUDDI <tModelDetail>();
                Console.Out.WriteLine(p3.print(td));
            }
            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();
                }
            }
        }
Пример #23
0
 public void setFromClerk(UDDIClerk fromClerk)
 {
     this.fromClerk = fromClerk;
 }
Пример #24
0
        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();
                }
            }
        }
Пример #25
0
        public static void main(string[] args)
        {
            Console.Out.Write("Enter WSDL url: >");
            String input = Console.In.ReadLine();

            if (String.IsNullOrEmpty(input))
            {
                input = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
            }
            //String wsdlURL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
            //if (String.IsNullOrEmpty(input))
            Uri    url  = null;
            String host = "localhost";
            int    port = 80;

            try
            {
                url  = new Uri(input);
                host = url.Host;
                port = url.Port;
            }
            catch { }
            ReadWSDL     wsi            = new ReadWSDL();
            tDefinitions wsdlDefinition = wsi.readWSDL(input);
            Properties   properties1    = new Properties();

            properties1.put("serverName", host);
            properties1.put("businessName", host);
            properties1.put("keyDomain", "uddi:" + host);

            if (port <= 0)
            {
                if (url.ToString().StartsWith("https", StringComparison.CurrentCultureIgnoreCase))
                {
                    port = 443;
                }
                else
                {
                    port = 80;
                }
            }
            properties1.put("serverPort", port.ToString());

            tModel keypart = UDDIClerk.createKeyGenator(host, host + "'s key partition", "en");

            WSDL2UDDI     wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties1);
            List <tModel> tModels1  = new List <tModel>();

            Dictionary <QName, tPortType> portTypes1 = (Dictionary <QName, tPortType>)wsdlDefinition.getAllPortTypes();
            List <tModel> portTypeTModels1           = wsdl2UDDI.createWSDLPortTypeTModels(input, portTypes1);

            tModels1.AddRange(portTypeTModels1);

            Dictionary <QName, tBinding> allBindings1 = wsdlDefinition.getAllBindings();
            List <tModel> createWSDLBindingTModels1   = wsdl2UDDI.createWSDLBindingTModels(input, allBindings1);

            tModels1.AddRange(createWSDLBindingTModels1);
            businessService[] services = wsdl2UDDI.createBusinessServices(wsdlDefinition);

            save_service ss = new save_service();

            ss.businessService = services;
            Console.Out.WriteLine(new PrintUDDI <save_service>().print(ss));

            save_tModel st = new save_tModel();

            st.tModel = tModels1.ToArray();
            Console.Out.WriteLine(new PrintUDDI <save_tModel>().print(st));

            //save keypart

            //save tmodels
            //save business

            //TODO register the stuff
        }
Пример #26
0
        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");


                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);
                for (int i = 0; i < bl.businessInfos.Length; i++)
                {
                    Console.WriteLine("Business: " + bl.businessInfos[i].name[0].Value);
                    if (bl.businessInfos[i].serviceInfos != null && bl.businessInfos[i].serviceInfos.Length > 0)
                    {
                        Console.WriteLine("Service: " + bl.businessInfos[i].serviceInfos[0].serviceKey);
                        Console.WriteLine("Running find_endpoints");
                        List <String> eps = clerk.getEndpoints(bl.businessInfos[i].serviceInfos[0].serviceKey);
                        Console.WriteLine(eps.Count + " endpoints found");
                        for (int k = 0; k < eps.Count; k++)
                        {
                            Console.WriteLine("[" + k + "] " + eps[i]);
                        }
                        break;
                    }
                }
            }
            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();
                }
            }
        }
        /**
         * Registers a UDDI binding template that represents the subscription
         * callback endpoint
         *
         * @param client
         * @param cfg_node_name
         * @param bt - Binding Template
         * @param behavior
         * @return
         * @throws ServiceAlreadyStartedException
         * @throws SecurityException
         * @throws ConfigurationException
         * @throws TransportException
         * @throws DispositionReportFaultMessage
         * @throws RemoteException
         * @throws UnexpectedException
         * @throws RegistrationAbortedException
         * @throws UnableToSignException
         */
        public static bindingTemplate registerBinding(UDDIClient client, String cfg_node_name, bindingTemplate bt, SignatureBehavior behavior)
        {
            log.info("Attempting to register binding " + bt.bindingKey);
            UDDIClerk clerk = client.getClerk(cfg_node_name);
            Transport tp    = client.getTransport(cfg_node_name);
            UDDI_Inquiry_SoapBinding     uddiInquiryService = tp.getUDDIInquiryService();
            UDDI_Publication_SoapBinding uddiPublishService = tp.getUDDIPublishService();


            String token = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());

            switch (behavior)
            {
            case SignatureBehavior.AbortIfSigned:
                if (CheckExistingBindingForSignature(bt.bindingKey, uddiInquiryService, token, behavior))
                {
                    throw new RegistrationAbortedException("Aborting, Either the item exists and is signed");
                }
                if (CheckServiceAndParentForSignature(bt.serviceKey, uddiInquiryService, token))
                {
                    throw new RegistrationAbortedException("Aborting, Either the service or busness is signed");
                }
                break;

            case SignatureBehavior.DoNothing:
                break;

            case SignatureBehavior.SignAlways:
                try
                {
                    DigSigUtil ds = new DigSigUtil(client.getClientConfig().getDigitalSignatureConfiguration());
                    bt = (bindingTemplate)ds.signUddiEntity(bt);
                }
                catch (Exception ex)
                {
                    log.error("Unable to sign", ex);
                    throw new UnableToSignException("Unable to sign", ex);
                }

                break;

            case SignatureBehavior.SignOnlyIfParentIsntSigned:
                if (!CheckServiceAndParentForSignature(bt.serviceKey, uddiInquiryService, token))
                {
                    try
                    {
                        DigSigUtil ds = new DigSigUtil(client.getClientConfig().getDigitalSignatureConfiguration());
                        bt = (bindingTemplate)ds.signUddiEntity(bt);
                    }
                    catch (Exception ex)
                    {
                        log.error("Unable to sign", ex);
                        throw new UnableToSignException("Unable to sign", ex);
                    }
                }
                break;
            }
            save_binding sb = new save_binding();

            sb.authInfo        = (token);
            sb.bindingTemplate = new bindingTemplate[] { bt };

            bindingDetail saveBinding = uddiPublishService.save_binding(sb);

            log.info("Binding registered successfully");
            if (saveBinding.bindingTemplate == null || saveBinding.bindingTemplate.Length > 1)
            {
                throw new UnexpectedResponseException("The number of binding templates returned was unexpected, count=" + (saveBinding.bindingTemplate == null ? "none" : saveBinding.bindingTemplate.Length.ToString()));
            }
            return(saveBinding.bindingTemplate[0]);
        }
Пример #28
0
        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");

                UDDI_Security_SoapBinding    security = transport.getUDDISecurityService();
                UDDI_Inquiry_SoapBinding     inquiry  = transport.getUDDIInquiryService();
                UDDI_Publication_SoapBinding publish  = transport.getUDDIPublishService();
                JUDDIApiService juddi = transport.getJUDDIApiService();

                clerk = clerkManager.getClerk("default");

                node n1 = new node();
                n1.clientName = "juddicloud";
                //the following are optional

                /*
                 * max length is 255
                 * proxy transport
                 * factory*
                 * juddiapi url
                 */
                n1.proxyTransport          = "org.apache.juddi.v3.client.transport.JAXWSTransport";
                n1.custodyTransferUrl      = "http://uddi-jbossoverlord.rhcloud.com/services/custody-transfer";
                n1.inquiryUrl              = "http://uddi-jbossoverlord.rhcloud.com/services/inquiry";
                n1.publishUrl              = "http://uddi-jbossoverlord.rhcloud.com/services/publish";
                n1.securityUrl             = "http://uddi-jbossoverlord.rhcloud.com/services/security";
                n1.subscriptionUrl         = "http://uddi-jbossoverlord.rhcloud.com/services/subscription";
                n1.subscriptionListenerUrl = "http://uddi-jbossoverlord.rhcloud.com/services/subscription-listener";
                n1.name        = "juddicloud";
                n1.description = "juddicloud";
                save_node saveNode = new save_node();
                saveNode.authInfo = (clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl()));
                saveNode.node     = new node[] { (n1) };
                PrintJUDDI <save_node> p = new PrintJUDDI <save_node>();
                Console.Out.WriteLine("Before sending");
                Console.Out.WriteLine(p.print(saveNode));


                node[] nodes = clerk.getUDDINode().getTransport().getJUDDIApiService(clerk.getUDDINode().getJuddiApiUrl()).save_Node(saveNode);



                //  clerk.saveNode(n1);
            }
            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();
                }
            }
        }
        /// <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();
                }
            }
        }
Пример #30
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();
                }
            }
        }