Пример #1
0
        /**
         * Constructs the bindingKey based on the bindingKeyFormat specified in the properties. When no
         * bindingKeyFormat is specific the default format of uddi:${keyDomain}:${nodeName}-${serviceName}-{portName} is used.
         *
         * @param properties
         * @param serviceName
         * @param portName
         * @return the bindingKey
        */
        public static String getBindingKey(Properties properties, QName serviceName, String portName, Uri bindingUrl)
        {
            Properties tempProperties = new Properties();
            tempProperties.putAll(properties);
            tempProperties.put("serviceName", serviceName.getLocalPart());
            tempProperties.put("portName", portName);
            int port = bindingUrl.Port;
            if (port < 0)
            {
                if ("http".Equals(bindingUrl.Scheme, StringComparison.CurrentCultureIgnoreCase))
                {
                    port = 80;
                }
                else if ("https".Equals(bindingUrl.Scheme))
                {
                    port = 443;
                }
            }
            if (!tempProperties.containsKey("serverPort"))
                tempProperties.put("serverPort", port.ToString());

            //Constructing the binding Key
            String keyFormat = properties.getProperty(Property.BINDING_KEY_FORMAT, DEFAULT_BINDING_KEY_FORMAT);
            String bindingKey = TokenResolver.replaceTokens(keyFormat, tempProperties).ToLower();
            return bindingKey;
        }
Пример #2
0
 /// <summary>
 /// Constructs the serviceKey based on the bindingKeyFormat specified in the properties. When no
 /// businessKeyFormat is specific the default format of uddi:${keyDomain}:${businessName} is used. The businessName
 /// property needs to be set properties.
 /// </summary>
 /// <param name="properties"></param>
 /// <returns></returns>
 public static String getBusinessKey(Properties properties)
 {
     String businessKey = properties.getProperty(Property.BUSINESS_KEY);
     if (businessKey == null)
     {
         String keyFormat = properties.getProperty(Property.BUSINESS_KEY_FORMAT, DEFAULT_BUSINESS_KEY_FORMAT);
         businessKey = TokenResolver.replaceTokens(keyFormat, properties).ToLower();
     }
     return businessKey;
 }
Пример #3
0
        public List<businessService> readServiceAnnotations(string[] classes, Properties properties)
        {
            List<businessService> items = new List<businessService>();

            if (classes != null)
            {
                foreach (string s in classes)
                {
                    businessService b = readServiceAnnotations(s, properties);
                    if (b != null)
                        items.Add(b);
                }

            }
            return items;
        }
Пример #4
0
        public static String replaceTokens(String s, Properties properties)
        {
            if (properties == null || String.IsNullOrEmpty(s)) return s;
            s = s.Replace("\\n", " ").Replace("\\r", "").Replace(" ", "");
            /* pattern that is multi-line (?m), and looks for a pattern of
             * ${token}, in a 'reluctant' manner, by using the ? to
             * make sure we find ALL the tokens.
             */
            //Pattern pattern = Pattern.compile("(?m)\\$\\{.*?\\}");
            //Matcher matcher = pattern.matcher(s);
            Match matcher = System.Text.RegularExpressions.Regex.Match(s, "(?m)\\$\\{.*?\\}");
            //Match temp = matcher.NextMatch();
            //while (temp != null && matcher.Success)
            foreach (Match m in Regex.Matches(s, "(?m)\\$\\{.*?\\}"))
            {
                String token = m.Value;
                if (token.Length < 3)
                {
                    return s;
                }
                token = token.Substring(2,token.Length - 3);
                String replacement = properties.getString(token);
                if (replacement != null)
                {
                    log.debug("Found token " + token + " and replacement value " + replacement);
                    s = s.Replace("${" + token + "}", replacement);
                }
                else
                {
                    log.error("Found token " + token + " but could not obtain its value. Data: " + s);
                }
              //  temp = matcher.NextMatch();

            }
            log.debug("Data after token replacement: " + s);
            return s;
        }
Пример #5
0
 public static String getSubscriptionKey(Properties properties)
 {
     String keyFormat = properties.getProperty(Property.SUBSCRIPTION_KEY_FORMAT, DEFAULT_SUBSCRIPTION_KEY_FORMAT);
     String subscriptionKey = TokenResolver.replaceTokens(keyFormat, properties).ToLower();
     return subscriptionKey;
 }
Пример #6
0
        /**
         * Removes the UDDI data structures belonging to the WSDLs for this
         * clerk from the UDDI node. Note, if registration fails, no exception
         * is thrown
         */
        public void unRegisterWsdls()
        {
            if (this.getWsdls() != null)
            {
                Properties properties = new Properties();
                properties.putAll(this.getUDDINode().getProperties());

                foreach (WSDL wsdl in this.getWsdls())
                {
                    try
                    {
                        ReadWSDL rw = new ReadWSDL();
                        tDefinitions wsdlDefinition = rw.readWSDL(wsdl.getFileName());
                        if (wsdl.getKeyDomain() != null)
                        {
                            properties.setProperty("keyDomain", wsdl.getKeyDomain());
                        }
                        if (wsdl.getBusinessKey() != null)
                        {
                            properties.setProperty("businessKey", wsdl.getBusinessKey());
                        }

                        WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizer(), properties);
                        wsdl2UDDI.unRegisterBusinessServices(wsdlDefinition);
                    }
                    catch (Exception e)
                    {
                        log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + e.Message, e);
                    }
                }
            }
        }
Пример #7
0
        /**
         * fetches a wsdl endpoint and parses for execution urls
         * @param value
         * @return
         */
        private List<String> FetchWSDL(String value)
        {
            List<String> items = new List<String>();

            if (value.StartsWith("http://") || value.StartsWith("https://"))
            {
                //here, we need an HTTP Get for WSDLs
                org.apache.juddi.v3.client.mapping.ReadWSDL r = new ReadWSDL();
                r.setIgnoreSSLErrors(true);
                try
                {
                    tDefinitions wsdlDefinition = r.readWSDL(value);
                    Properties properties = new Properties();

                    properties.put("keyDomain", "domain");
                    properties.put("businessName", "biz");
                    properties.put("serverName", "localhost");
                    properties.put("serverPort", "80");

                    WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties);
                    businessService[] businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition);
                    for (int i = 0; i < businessServices.Length; i++)
                    {
                        if (businessServices[i].bindingTemplates != null)
                        {
                            for (int k = 0; k < businessServices[i].bindingTemplates.Length; k++)
                            {
                                items.AddRange(ParseBinding(businessServices[i].bindingTemplates[k]));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.error("error fetching wsdl for parsing", ex);
                }

            }
            return items;
        }
Пример #8
0
        public businessService readServiceAnnotations(String classWithAnnotations, Properties properties)
        {
            Type t = Type.GetType(classWithAnnotations, false, true);
            if (t != null)
            {
                businessService service = new businessService();
                object[] attrib = t.GetCustomAttributes(typeof(UDDIService), true);

                object[] ws = t.GetCustomAttributes(typeof(System.Web.Services.WebServiceBindingAttribute), true);
                WebServiceBindingAttribute webServiceAnnotation = null;
                if (ws != null && ws.Length > 0)
                {
                    webServiceAnnotation = ((WebServiceBindingAttribute[])ws)[0];
                }
                if (attrib != null && attrib.Length > 0)
                {

                    UDDIService[] bits = attrib as UDDIService[];
                    UDDIService uddiService = bits[0];
                    name n = new name();
                    n.lang = uddiService.lang;
                    service.businessKey = (TokenResolver.replaceTokens(uddiService.businessKey, properties));
                    service.serviceKey = (TokenResolver.replaceTokens(uddiService.serviceKey, properties));
                    if (!"".Equals(uddiService.serviceName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        n.Value = (TokenResolver.replaceTokens(uddiService.serviceName, properties));
                    }
                    else if (webServiceAnnotation != null && !"".Equals(webServiceAnnotation.Name))
                    {
                        n.Value = (webServiceAnnotation.Name);
                    }
                    else
                    {
                        n.Value = (classWithAnnotations);
                    }
                    service.name = new name[] { n };
                    description d = new description();
                    d.lang = (uddiService.lang);
                    d.Value = (TokenResolver.replaceTokens(uddiService.description, properties));
                    service.description = new description[] { d };

                    //categoryBag on the service
                    if (!"".Equals(uddiService.categoryBag))
                    {
                        categoryBag categoryBag = parseCategoryBag(uddiService.categoryBag);
                        service.categoryBag = (categoryBag);
                    }

                    //bindingTemplate on service
                    bindingTemplate bindingTemplate = parseServiceBinding(classWithAnnotations, uddiService.lang, webServiceAnnotation, properties);
                    if (bindingTemplate != null)
                    {
                        bindingTemplate.serviceKey = (service.serviceKey);
                        if (service.bindingTemplates == null)
                        {
                            service.bindingTemplates = new bindingTemplate[] { bindingTemplate };
                        }
                        else
                        {
                            List<bindingTemplate> l = new List<bindingTemplate>();
                            l.AddRange(service.bindingTemplates);
                            l.Add(bindingTemplate);
                            service.bindingTemplates = l.ToArray();
                        }
                    }

                    return service;
                }
                else
                {
                    log.error("Missing UDDIService annotation in class " + classWithAnnotations);
                }
            }
            log.error("Unable to load type " + classWithAnnotations);
            return null;
        }
Пример #9
0
        /**
         * Registers a WSDL Definition onto the UDDI node referenced by the
         * clerk. Note, if registration fails, no exception is thrown
         *
         * @param wsdlDefinition - the WSDL Definition
         * @param keyDomain - the keyDomain which will be used to construct the
         * UDDI key IDs. If left null the keyDomain defined in the node's
         * properties will be used.
         * @param businessKey - the key of the business to which this service
         * belongs. If left null the businessKey defined in the node's
         * properties will be used.
         *
         */
        public void registerWsdls(tDefinitions wsdlDefinition, String keyDomain, String businessKey)
        {
            try
            {
                Properties properties = new Properties();
                properties.putAll(this.getUDDINode().getProperties());

                if (keyDomain != null)
                {
                    properties.setProperty("keyDomain", keyDomain);
                }
                if (businessKey != null)
                {
                    properties.setProperty("businessKey", businessKey);
                }
                WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizer(), properties);
                wsdl2UDDI.registerBusinessServices(wsdlDefinition);
            }
            catch (Exception e)
            {
                log.error("Unable to register wsdl " + " ." + e.Message, e);
            }
        }
Пример #10
0
 /// <summary>
 /// Constructs the serviceKey based on the serviceKeyFormat specified in the properties. When no
 ///serviceKeyFormat is specific the default format of uddi:${keyDomain}:${serviceName} is used.
 /// </summary>
 /// <param name="properties"></param>
 /// <param name="serviceName"></param>
 /// <returns></returns>
 public static String getServiceKey(Properties properties, String serviceName)
 {
     Properties tempProperties = new Properties();
     tempProperties.putAll(properties);
     tempProperties.put("serviceName", serviceName);
     //Constructing the serviceKey
     String keyFormat = tempProperties.getProperty(Property.SERVICE_KEY_FORMAT, DEFAULT_SERVICE_KEY_FORMAT);
     String serviceKey = TokenResolver.replaceTokens(keyFormat, tempProperties).ToLower();
     return serviceKey;
 }
Пример #11
0
        /**
         * Does the actual work of reading the configuration from System
         * Properties and/or uddi.xml file. When the uddi.xml
         * file is updated the file will be reloaded. By default the reloadDelay is
         * set to 1 second to prevent excessive date stamp checking.
         */
        private void loadConfiguration(String configurationFile, Properties properties)
        {
            if (config != null)
                return;
            String filename = null;

            //Properties from XML file

            if (!String.IsNullOrEmpty(configurationFile))
            {
                filename = configurationFile;
            }
            else
            {
                String prop = System.Environment.GetEnvironmentVariable(ClientConfig.UDDI_CONFIG_FILENAME_PROPERTY);
                if (!String.IsNullOrEmpty(prop))
                    filename = prop;
                else
                    filename = UDDI_CONFIG_FILENAME_PROPERTY;
            }

            log.info("Reading UDDI Client properties file " + filename);
            config = XmlConfiguration.LoadXmlConfiguration(filename);
            this.configurationFile = filename;

            //Properties from system properties

            IDictionaryEnumerator it = Environment.GetEnvironmentVariables().GetEnumerator();
            while (it.MoveNext())
            {
                config.getProperties().setProperty(it.Key.ToString(), it.Value.ToString());
            }
            readConfig(properties);
        }
Пример #12
0
 public void putAll(Properties properties)
 {
     Dictionary<string, object>.Enumerator it = properties.map.GetEnumerator();
     while (it.MoveNext())
     {
         setProperty(it.Current.Key, it.Current.Value);
     }
 }
Пример #13
0
        /// <summary>
        /// 
        /// Required Properties are: businessName, for example: &#39;Apache&#39; nodeName,
        /// for example: &#39;uddi.example.org_80&#39; keyDomain, for example:
        /// juddi.apache.org
        /// 
        /// Optional Properties are: lang: for example: &#39;nl&#39;
        /// 
        /// </summary>
        /// <param name="clerk">can be null if register/unregister methods are not used.</param>
        /// <param name="urlLocalizer">A reference to an custom</param>
        /// <param name="properties">required values keyDomain, businessKey, nodeName</param>
        /// <exception cref="ConfigurationException"></exception>
        public WSDL2UDDI(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties)
        {
            if (properties == null)
                throw new ArgumentNullException("properties");
            this.clerk = clerk;
            this.urlLocalizer = urlLocalizer;
            this.properties = properties;

            if (clerk != null)
            {
                if (!properties.containsKey("keyDomain"))
                {
                    throw new ConfigurationErrorsException("Property keyDomain is a required property when using WSDL2UDDI.");
                }
                if (!properties.containsKey("businessKey") && !properties.containsKey("businessName"))
                {
                    throw new ConfigurationErrorsException("Either property businessKey, or businessName, is a required property when using WSDL2UDDI.");
                }
                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 WSDL2UDDI.");
                    }
                }
            }

            //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
 public void setProperties(uddiClientNodeProperty[] uddiClientNodeProperty)
 {
     if (uddiClientNodeProperty == null)
         return;
     Properties p = new Properties();
     for (int i = 0; i < uddiClientNodeProperty.Length; i++)
     {
         p.setProperty(uddiClientNodeProperty[i].name, uddiClientNodeProperty[i].value);
     }
     this.properties = p;
 }
Пример #15
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);
        }
Пример #16
0
 public void setProperties(Properties properties)
 {
     this.properties = properties;
 }
Пример #17
0
 /**
  * Constructor (note Singleton pattern).
  * @
  */
 public ClientConfig(String configurationFile, Properties properties)
 {
     loadConfiguration(configurationFile, properties);
 }
Пример #18
0
        private Dictionary<String, UDDINode> readNodeConfig(uddi config, Properties properties)
        {
            //String[] names = config.getStringArray("client.nodes.node.name");
            Dictionary<String, UDDINode> nodes = new Dictionary<String, UDDINode>();
            log.debug("node count=" + config.client.nodes.Length);

            for (int i = 0; i < config.client.nodes.Length; i++)
            {
                UDDINode uddiNode = new UDDINode();

                uddiNode.setClientName(config.client.nodes[i].name);
                uddiNode.setProperties(config.client.nodes[i].properties);
                uddiNode.setHomeJUDDI(config.client.nodes[i].isHomeJUDDI);
                uddiNode.setName(config.client.nodes[i].name);
                uddiNode.setClientName(config.client.nodes[i].name);
                uddiNode.setDescription(config.client.nodes[i].description);
                uddiNode.setProxyTransport(config.client.nodes[i].proxyTransport);

                uddiNode.setInquiryUrl(TokenResolver.replaceTokens(config.client.nodes[i].inquiryUrl, config.client.nodes[i].properties));
                uddiNode.setPublishUrl(TokenResolver.replaceTokens(config.client.nodes[i].publishUrl, config.client.nodes[i].properties));
                uddiNode.setCustodyTransferUrl(TokenResolver.replaceTokens(config.client.nodes[i].custodyTransferUrl, config.client.nodes[i].properties));
                uddiNode.setSecurityUrl(TokenResolver.replaceTokens(config.client.nodes[i].securityUrl, config.client.nodes[i].properties));
                uddiNode.setSubscriptionUrl(TokenResolver.replaceTokens(config.client.nodes[i].subscriptionUrl, config.client.nodes[i].properties));
                uddiNode.setSubscriptionListenerUrl(TokenResolver.replaceTokens(config.client.nodes[i].subscriptionListenerUrl, config.client.nodes[i].properties));
                uddiNode.setJuddiApiUrl(TokenResolver.replaceTokens(config.client.nodes[i].juddiApiUrl, config.client.nodes[i].properties));
                uddiNode.setFactoryInitial(config.client.nodes[i].factoryInitial);
                uddiNode.setFactoryURLPkgs(config.client.nodes[i].factoryURLPkgs);
                uddiNode.setFactoryNamingProvider(config.client.nodes[i].factoryNamingProvider);
                nodes.Add(uddiNode.getName(), uddiNode);
            }
            return nodes;
        }
Пример #19
0
        /// <summary>
        /// Fetches all digital signature related properties for the digital signature utility.          
        /// warning, this will decrypt all passwords
        /// </summary>
        /// <returns></returns>
        public Properties getDigitalSignatureConfiguration()
        {
            Properties p = new Properties();
            if ( this.config==null ||
                this.config.client==null ||
                this.config.client.signature==null)
            {
                log.warn("No configuration data is available, signatures probably won't be possible");
                this.config.client.signature = new uddiClientSignature();
            }
            p.setProperty(DigSigUtil.CANONICALIZATIONMETHOD, this.config.client.signature.canonicalizationMethod, SignedXml.XmlDsigExcC14NWithCommentsTransformUrl);
            p.setProperty(DigSigUtil.CHECK_TIMESTAMPS, this.config.client.signature.checkTimestamps.ToString(), "true");
            p.setProperty(DigSigUtil.CHECK_REVOCATION_STATUS_CRL, this.config.client.signature.checkRevocationCRL.ToString(), "true");
            p.setProperty(DigSigUtil.CHECK_REVOCATION_STATUS_OCSP, this.config.client.signature.checkRevocationOCSP.ToString(), "true");
            p.setProperty(DigSigUtil.CHECK_TRUST_CHAIN, this.config.client.signature.checkTrust.ToString(), "true");

            p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_FILE, this.config.client.signature.signingKeyStorePath);
            p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_FILETYPE,  this.config.client.signature.signingKeyStoreType);

            if (this.config.client.signature.signingKeyPassword!=null &&
                this.config.client.signature.signingKeyPassword.isPasswordEncrypted)
            {
                String enc = this.config.client.signature.signingKeyPassword.Value;
                String prov = this.config.client.signature.signingKeyPassword.cryptoProvider;
                p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_KEY_PASSWORD, CryptorFactory.getCryptor(prov).decrypt(enc));
            }
            else
            {
                log.warn("Hey, you should consider encrypting your passwords!");
                p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_KEY_PASSWORD, this.config.client.signature.signingKeyPassword.Value);
            }
            if (this.config.client.signature.signingKeyStoreFilePassword!=null &&
                this.config.client.signature.signingKeyStoreFilePassword.isPasswordEncrypted)
            {
                String enc = this.config.client.signature.signingKeyStoreFilePassword.Value;
                String prov = this.config.client.signature.signingKeyStoreFilePassword.cryptoProvider;
                p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, CryptorFactory.getCryptor(prov).decrypt(enc));
            }
            else
            {
                log.warn("Hey, you should consider encrypting your passwords!");
                p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, this.config.client.signature.signingKeyStoreFilePassword.Value);
            }

            p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_KEY_ALIAS, this.config.client.signature.signingKeyAlias);
            p.setProperty(DigSigUtil.SIGNATURE_METHOD, this.config.client.signature.signatureMethod, "http://www.w3.org/2000/09/xmldsig#rsa-sha1");
            p.setProperty(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SUBJECTDN, this.config.client.signature.keyInfoInclusionSubjectDN.ToString());
            p.setProperty(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_BASE64, this.config.client.signature.keyInfoInclusionBase64PublicKey.ToString());
            p.setProperty(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SERIAL, this.config.client.signature.keyInfoInclusionSerial.ToString());

            p.setProperty(DigSigUtil.SIGNATURE_OPTION_DIGEST_METHOD, this.config.client.signature.digestMethod, "http://www.w3.org/2000/09/xmldsig#sha1");

            p.setProperty(DigSigUtil.TRUSTSTORE_FILE, this.config.client.signature.trustStorePath);
            p.setProperty(DigSigUtil.TRUSTSTORE_FILETYPE, this.config.client.signature.trustStoreType);

            if (this.config.client.signature.trustStorePassword!=null &&
                this.config.client.signature.trustStorePassword.isPasswordEncrypted)
            {
                String enc = this.config.client.signature.trustStorePassword.Value;
                String prov = this.config.client.signature.trustStorePassword.cryptoProvider;
                p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, CryptorFactory.getCryptor(prov).decrypt(enc));
            }
            else
            {
                log.warn("Hey, you should consider encrypting your passwords!");
                p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, this.config.client.signature.trustStorePassword);
            }
            return p;
        }
Пример #20
0
 /**
  * Manages the clerks. Initiates reading the client configuration from the uddi.xml.
  * @throws ConfigurationException
  */
 public UDDIClient(String configurationFile, Properties properties)
 {
     clientConfig = new ClientConfig(configurationFile, properties);
     UDDIClientContainer.addClient(this);
 }
Пример #21
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
        }
Пример #22
0
 /// <summary>
 /// Constructor that will accept a properties set from the juddi config file, or whatever you want
 /// 
 /// </summary>
 /// <param name="c"></param>
 public DigSigUtil(Properties c)
 {
     map = c;
 }
Пример #23
0
        void runTest(String pathAndFile)
        {
            Assume.That(File.Exists(pathAndFile));

            ReadWSDL wsi = new ReadWSDL();
            tDefinitions wsdlDefinition = wsi.readWSDL(
               pathAndFile
                );
            Properties properties1 = new Properties();
            properties1.put("keyDomain", "my.key.domain");
            WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties1);
            Assert.NotNull(wsdl2UDDI);

            Dictionary<QName, tPortType> portTypes1 = (Dictionary<QName, tPortType>)wsdlDefinition.getAllPortTypes();
            Assert.NotNull(portTypes1);
            Assert.True(portTypes1.Count > 0);
            List<tModel> portTypeTModels1 = wsdl2UDDI.createWSDLPortTypeTModels(pathAndFile, portTypes1);

            Assert.NotNull(portTypeTModels1);
            Assert.True(portTypeTModels1.Count > 0);

            Dictionary<QName, tBinding> allBindings1 = wsdlDefinition.getAllBindings();
            Assert.NotNull(allBindings1);
            Assert.True(allBindings1.Count > 0);
            List<tModel> createWSDLBindingTModels1 = wsdl2UDDI.createWSDLBindingTModels(pathAndFile, allBindings1);
            Assert.NotNull(createWSDLBindingTModels1);
            Assert.True(createWSDLBindingTModels1.Count > 0);

            businessService[] businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition);

            Assert.NotNull(businessServices);
            Assert.True(businessServices.Length > 0);
            for (int i = 0; i < businessServices.Length; i++)
            {
                foreach (description d in businessServices[i].description)
                {
                    if (d.lang != null)
                        Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length);
                    if (d.Value != null)
                        Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length);
                }
                foreach (bindingTemplate bt in businessServices[i].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);

                    foreach (description d in bt.description)
                    {
                        if (d.lang != null)
                            Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length);
                        if (d.Value != null)
                            Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length);
                    }

                    foreach (tModelInstanceInfo tm in bt.tModelInstanceDetails)
                    {
                        foreach (description d in tm.description)
                        {
                            if (d.lang != null)
                                Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length);
                            if (d.Value != null)
                                Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length);
                        }
                    }

                }
                Assert.True(businessServices[i].bindingTemplates.Length > 0);
                Assert.NotNull(businessServices[i].description);
                Assert.True(businessServices[i].description.Length > 0);
                Assert.NotNull(businessServices[i].serviceKey);
            }
        }
Пример #24
0
 protected void readConfig(Properties properties)
 {
     uddiNodes = readNodeConfig(config, properties);
     uddiClerks = readClerkConfig(config, uddiNodes);
     xServiceBindingRegistrations = readXServiceBindingRegConfig(config, uddiClerks);
     xBusinessRegistrations = readXBusinessRegConfig(config, uddiClerks);
 }
Пример #25
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();
            }
        }
Пример #26
0
        private bindingTemplate parseServiceBinding(string classWithAnnotations, string lang, WebServiceBindingAttribute webServiceAnnotation, Properties properties)
        {
            bindingTemplate bindingTemplate = null;
            Type t = Type.GetType(classWithAnnotations, false, false);
            UDDIServiceBinding uddiServiceBinding = null;
            object[] attrib = t.GetCustomAttributes(typeof(UDDIServiceBinding), true);
            if (attrib != null && attrib.Length > 0)
                uddiServiceBinding = attrib[0] as UDDIServiceBinding;

            //= (UDDIServiceBinding) classWithAnnotations.getAnnotation(UDDIServiceBinding.class);
            //binding
            if (uddiServiceBinding != null)
            {
                bindingTemplate = new bindingTemplate();

                bindingTemplate.bindingKey = (TokenResolver.replaceTokens(uddiServiceBinding.bindingKey, properties));

                String bindingLang = (lang);
                if (uddiServiceBinding.lang != null)
                {
                    bindingLang = TokenResolver.replaceTokens(uddiServiceBinding.lang, properties);
                }
                description bindingDescription = new description();
                bindingDescription.lang = (bindingLang);
                bindingDescription.Value = (TokenResolver.replaceTokens(uddiServiceBinding.description, properties));
                bindingTemplate.description = new description[] { (bindingDescription) };

                accessPoint accessPoint = new accessPoint();
                accessPoint.useType = (AccessPointType.wsdlDeployment.ToString());
                if (!"".Equals(uddiServiceBinding.accessPointType))
                {
                    accessPoint.useType = (uddiServiceBinding.accessPointType);
                }
                if (!"".Equals(uddiServiceBinding.accessPoint))
                {
                    String endPoint = uddiServiceBinding.accessPoint;
                    endPoint = TokenResolver.replaceTokens(endPoint, properties);
                    log.debug("AccessPoint EndPoint=" + endPoint);
                    accessPoint.Value = (endPoint);
                }
                else if (webServiceAnnotation != null && webServiceAnnotation.Location != null)
                {
                    accessPoint.Value = (webServiceAnnotation.Location);
                }
                bindingTemplate.Item = (accessPoint);

                //tModelKeys on the binding
                if (!"".Equals(uddiServiceBinding.tModelKeys))
                {
                    String[] tModelKeys = uddiServiceBinding.tModelKeys.Split(',');
                    foreach (String tModelKey in tModelKeys)
                    {
                        tModelInstanceInfo instanceInfo = new tModelInstanceInfo();
                        instanceInfo.tModelKey = (tModelKey);
                        if (bindingTemplate.tModelInstanceDetails == null)
                        {
                            bindingTemplate.tModelInstanceDetails = (new tModelInstanceInfo[] { instanceInfo });
                        }
                        List<tModelInstanceInfo> l = new List<tModelInstanceInfo>();
                        l.AddRange(bindingTemplate.tModelInstanceDetails);
                        l.Add(instanceInfo);
                        bindingTemplate.tModelInstanceDetails = l.ToArray();

                    }
                }
                //categoryBag on the binding
                if (!"".Equals(uddiServiceBinding.categoryBag))
                {
                    categoryBag categoryBag = parseCategoryBag(uddiServiceBinding.categoryBag);
                    bindingTemplate.categoryBag = (categoryBag);
                }
            }
            else
            {
                log.error("Missing UDDIServiceBinding annotation in class " + classWithAnnotations);
            }
            return bindingTemplate;
        }
Пример #27
0
 public void setProperties(Properties props)
 {
     p = props;
 }
Пример #28
0
 /// <summary>
 /// creates an uninitialized DigSigUtil, use put to configure
 /// </summary>
 public DigSigUtil()
 {
     map = new Properties();
 }