Beispiel #1
0
        private Dictionary <String, UDDIClerk> readClerkConfig(uddi config, Dictionary <String, UDDINode> uddiNodes)
        {
            clientName = config.client.name;
            Dictionary <String, UDDIClerk> clerks = new Dictionary <String, UDDIClerk>();

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

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

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

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

                    clerks.Add(uddiClerk.getName(), uddiClerk);
                }
            }
            else
            {
                log.warn("No clerks are defined!");
            }
            return(clerks);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
                    }
                }
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
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;
 }
Beispiel #7
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;
        }