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
        }
        public static bindingTemplate start(UDDIClient client, String cfg_node_name)
        {
            bool              reg      = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.autoRegisterBindingTemplate;
            String            endpoint = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.listenUrl;
            String            kd       = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.keyDomain;
            String            key      = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.autoRegisterBusinessServiceKey;
            String            sbs      = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.signatureBehavior;
            SignatureBehavior sb       = SignatureBehavior.DoNothing;

            try
            {
                sb = (SignatureBehavior)Enum.Parse(typeof(SignatureBehavior), sbs);
            }
            catch (Exception ex)
            {
                log.warn("Unable to parse config setting for SignatureBehavior, defaulting to DoNothing", ex);
            }

            return(start(client, cfg_node_name, endpoint, kd, reg, key, sb));
        }
 public void run()
 {
     try
     {
         if (UDDIClientContainer.getUDDIClient(uddiClient.getName()) != null && uddiClient.getClientConfig().isRegisterOnStartup())
         {
             log.debug("Starting UDDI Clerks for uddiClient " + uddiClient.getClientConfig().getClientName() + "...");
             uddiClient.saveClerkAndNodeInfo();
             uddiClient.registerAnnotatedServices();
             uddiClient.registerWSDLs();
             uddiClient.xRegister();
             log.debug("Clerks started succesfully for uddiClient " + uddiClient.getClientConfig().getClientName());
         }
         else
         {
             log.debug(uddiClient.getName() + " already registered to the UDDIClientContainer.");
         }
     }
     catch (Exception e)
     {
         log.error(e.Message, e);
     }
 }
        /// <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 #5
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();
                }
            }
        }
        /**
         * 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 #7
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();
                }
            }
        }
        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
        }
        public static bindingTemplate start(UDDIClient client, String cfg_node_name)
        {
            bool reg = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.autoRegisterBindingTemplate;
            String endpoint = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.listenUrl;
            String kd = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.keyDomain;
            String key = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.autoRegisterBusinessServiceKey;
            String sbs = client.getClientConfig().getConfiguration().client.subscriptionCallbacks.signatureBehavior;
            SignatureBehavior sb = SignatureBehavior.DoNothing;
            try
            {
                sb = (SignatureBehavior)Enum.Parse(typeof(SignatureBehavior), sbs);
            }
            catch (Exception ex)
            {
                log.warn("Unable to parse config setting for SignatureBehavior, defaulting to DoNothing", ex);
            }

            return start(client, cfg_node_name, endpoint, kd, reg, key, sb);
        }
        /**
        * 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];
        }