Beispiel #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);
        }
Beispiel #2
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();
                }
            }
        }
Beispiel #3
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);
        }
Beispiel #4
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();
                }
            }
        }
        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
        }
Beispiel #7
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;
            }
        }
        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();
                }
            }
        }
Beispiel #9
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;
         }
     }
 }
Beispiel #10
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);
        }
        /**
        * 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];
        }
Beispiel #12
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");

                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();
                }
            }
        }
Beispiel #13
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();
                }
            }
        }
Beispiel #14
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();
                }
            }
        }
        /**
         * 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]);
        }
        /// <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();
                }
            }
        }
Beispiel #17
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();
                }
            }
        }
Beispiel #18
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();
                }
            }
        }
        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
        }
Beispiel #20
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();
                }
            }
        }