juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexo...@apache.org
Subject juddi git commit: JUDDI-895 done with support for tokens JUDDI-861 dialing back the logging a bit
Date Fri, 30 Jan 2015 04:21:11 GMT
Repository: juddi
Updated Branches:
  refs/heads/master c345d30d5 -> ac44bfd3f


JUDDI-895 done with support for tokens
JUDDI-861 dialing back the logging a bit


Project: http://git-wip-us.apache.org/repos/asf/juddi/repo
Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/ac44bfd3
Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/ac44bfd3
Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/ac44bfd3

Branch: refs/heads/master
Commit: ac44bfd3f6356b4bca39a7d8b8fc70fff217f742
Parents: c345d30
Author: Alex <alexoree@apache.org>
Authored: Thu Jan 29 23:21:03 2015 -0500
Committer: Alex <alexoree@apache.org>
Committed: Thu Jan 29 23:21:03 2015 -0500

----------------------------------------------------------------------
 .../org/apache/juddi/api/impl/JUDDIApiImpl.java |  10 +-
 .../java/org/apache/juddi/config/Install.java   | 141 ++++++++++++++++---
 .../juddi/replication/ReplicationNotifier.java  |   2 +-
 .../notify/USERFRIENDLYSMTPNotifier.java        |   6 +-
 .../juddi/validation/ValidateReplication.java   |  81 ++++++++++-
 .../root_replicationConfiguration.xml           |  39 +++++
 .../org/apache/juddi/config/InstallTest.java    |  89 ++++++++++++
 .../resources/juddiv3DisabledTModelKeybag.xml   |   5 +-
 .../tck/JUDDI_300_MultiNodeIntegrationTest.java |   4 +-
 9 files changed, 342 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/juddi-core/src/main/java/org/apache/juddi/api/impl/JUDDIApiImpl.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/api/impl/JUDDIApiImpl.java b/juddi-core/src/main/java/org/apache/juddi/api/impl/JUDDIApiImpl.java
index 725f0f3..7fbb109 100644
--- a/juddi-core/src/main/java/org/apache/juddi/api/impl/JUDDIApiImpl.java
+++ b/juddi-core/src/main/java/org/apache/juddi/api/impl/JUDDIApiImpl.java
@@ -26,12 +26,8 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebResult;
 
 import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityTransaction;
 import javax.persistence.Query;
@@ -1242,7 +1238,6 @@ public class JUDDIApiImpl extends AuthenticatedService implements JUDDIApiPortTy
                                 stm.getBusinessEntity().addAll(values.get(i).getBusinessEntity());
                                 pub.saveBusiness(stm);
                         }
-                        //TODO replication?
 
                         tx.commit();
                         long procTime = System.currentTimeMillis() - startTime;
@@ -1286,7 +1281,6 @@ public class JUDDIApiImpl extends AuthenticatedService implements JUDDIApiPortTy
                                 stm.getTModel().addAll(values.get(i).getTModel());
                                 pub.saveTModel(stm);
                         }
-                        //TODO replication?
                         tx.commit();
                         long procTime = System.currentTimeMillis() - startTime;
                         serviceCounter.update(JUDDIQuery.ADMIN_SAVE_TMODEL,
@@ -1371,7 +1365,7 @@ public class JUDDIApiImpl extends AuthenticatedService implements JUDDIApiPortTy
                         if (!((Publisher) publisher).isAdmin()) {
                                 throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));
                         }
-                        new ValidateReplication(publisher).validateSetReplicationNodes(replicationConfiguration,
em, node);
+                        new ValidateReplication(publisher).validateSetReplicationNodes(replicationConfiguration,
em, node, AppConfig.getConfiguration());
 
                         //StringWriter sw = new StringWriter();
                         //JAXB.marshal(replicationConfiguration, sw);
@@ -1472,14 +1466,12 @@ public class JUDDIApiImpl extends AuthenticatedService implements
JUDDIApiPortTy
                         throw drfm;
                 } catch (Exception ex) {
                         //possible that there is no config to return
-                        //logger.warn("Error caught, is there a replication config is avaiable?
Returning a default config (no replication): " + ex.getMessage());
                         logger.debug("Error caught, is there a replication config is avaiable?
Returning a default config (no replication): ", ex);
 
                         r.setCommunicationGraph(new CommunicationGraph());
                         Operator op = new Operator();
                         op.setOperatorNodeID(node);
                         op.setSoapReplicationURL(baseUrlSSL + "/services/replication");
-                        //TODO lookup from the root business
 
                         op.getContact().add(new Contact());
                         op.getContact().get(0).getPersonName().add(new PersonName("Unknown",
null));

http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/juddi-core/src/main/java/org/apache/juddi/config/Install.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/config/Install.java b/juddi-core/src/main/java/org/apache/juddi/config/Install.java
index 63cbf97..6b5097d 100644
--- a/juddi-core/src/main/java/org/apache/juddi/config/Install.java
+++ b/juddi-core/src/main/java/org/apache/juddi/config/Install.java
@@ -23,6 +23,7 @@ import java.io.StringReader;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Enumeration;
@@ -34,6 +35,7 @@ import java.util.jar.JarFile;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityTransaction;
+import javax.xml.bind.JAXB;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
@@ -49,6 +51,8 @@ import org.apache.juddi.api.impl.UDDIInquiryImpl;
 import org.apache.juddi.api.impl.UDDIPublicationImpl;
 import org.apache.juddi.keygen.KeyGenerator;
 import org.apache.juddi.mapping.MappingApiToModel;
+import org.apache.juddi.mapping.MappingModelToApi;
+import org.apache.juddi.model.ReplicationConfiguration;
 import org.apache.juddi.model.UddiEntityPublisher;
 import org.apache.juddi.replication.ReplicationNotifier;
 import org.apache.juddi.v3.error.ErrorMessage;
@@ -57,10 +61,12 @@ import org.apache.juddi.v3.error.InvalidKeyPassedException;
 import org.apache.juddi.v3.error.KeyUnavailableException;
 import org.apache.juddi.v3.error.ValueNotAllowedException;
 import org.apache.juddi.validation.ValidatePublish;
+import org.apache.juddi.validation.ValidateReplication;
 import org.apache.juddi.validation.ValidateUDDIKey;
 import org.uddi.api_v3.SaveBusiness;
 import org.uddi.api_v3.SaveTModel;
 import org.uddi.api_v3.TModel;
+import org.uddi.repl_v3.Operator;
 import org.uddi.v3_service.DispositionReportFaultMessage;
 
 /**
@@ -80,6 +86,7 @@ public class Install {
         public static final String FILE_PERSISTENCE = "persistence.xml";
         public static final String JUDDI_INSTALL_DATA_DIR = "juddi_install_data/";
         public static final String JUDDI_CUSTOM_INSTALL_DATA_DIR = "juddi_custom_install_data/";
+        public static final String FILE_REPLICATION_CONFIG = "_replicationConfiguration.xml";
         public static final Log log = LogFactory.getLog(Install.class);
 
         protected static void install(Configuration config) throws JAXBException, DispositionReportFaultMessage,
IOException, ConfigurationException {
@@ -109,6 +116,8 @@ public class Install {
                         //getNodeId(rootBusinessEntity.getBusinessKey(), rootPartition);
                         String rootbizkey = getNodeId(rootBusinessEntity.getBusinessKey(),
rootPartition);
                         String fileRootPublisher = rootPublisherStr + FILE_PUBLISHER;
+                        String fileReplicationConfig = rootPublisherStr + FILE_REPLICATION_CONFIG;
+                        org.uddi.repl_v3.ReplicationConfiguration replicationCfg = (org.uddi.repl_v3.ReplicationConfiguration)
buildInstallEntityAlt(fileReplicationConfig, org.uddi.repl_v3.ReplicationConfiguration.class,
config);
                         if (!alreadyInstalled) {
                                 log.info("Loading the root Publisher from file " + fileRootPublisher);
 
@@ -116,6 +125,7 @@ public class Install {
                                 installRootPublisherKeyGen(em, rootTModelKeyGen, rootPartition,
rootPublisher, nodeId);
                                 rootBusinessEntity.setBusinessKey(rootbizkey);
                                 installBusinessEntity(true, em, rootBusinessEntity, rootPublisher,
rootPartition, config, nodeId);
+                                installReplicationConfiguration(em, replicationCfg, config,
nodeId);
                         } else {
                                 log.debug("juddi.seed.always reapplies all seed files except
for the root data.");
                         }
@@ -164,7 +174,7 @@ public class Install {
         }
 
         protected static void uninstall() {
-		// Close the open emf, open a new one with Persistence.create...(String, Map) and overwrite
the property that handles the table 
+                // Close the open emf, open a new one with Persistence.create...(String,
Map) and overwrite the property that handles the table 
                 // generation. The persistence.xml file will have to be read in to determine
which property
                 // to overwrite.  The property will be specific to the provider.  
                 // Hibernate:  <property name="hibernate.hbm2ddl.auto" value="update"/>
->use "create-drop" or just "drop"?
@@ -228,7 +238,7 @@ public class Install {
                         throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey",
result));
                 }
 
-		// Must validate the root partition.  The first component should be a domain key and the
any following
+                // Must validate the root partition.  The first component should be a domain
key and the any following
                 // tokens should be a valid KSS.
                 result = result.trim();
                 if (result.endsWith(KeyGenerator.PARTITION_SEPARATOR) || result.startsWith(KeyGenerator.PARTITION_SEPARATOR))
{
@@ -269,8 +279,8 @@ public class Install {
         }
 
         private static String installBusinessEntity(boolean isRoot, EntityManager em, org.uddi.api_v3.BusinessEntity
rootBusinessEntity,
-             UddiEntityPublisher rootPublisher, String rootPartition, Configuration config,
String nodeId)
-             throws JAXBException, DispositionReportFaultMessage, IOException {
+                UddiEntityPublisher rootPublisher, String rootPartition, Configuration config,
String nodeId)
+                throws JAXBException, DispositionReportFaultMessage, IOException {
 
                 if (isRoot) {
                         validateRootBusinessEntity(rootBusinessEntity, rootPublisher, rootPartition,
config);
@@ -305,7 +315,7 @@ public class Install {
                                 binding.setCreated(now);
                                 binding.setModified(now);
                                 binding.setModifiedIncludingChildren(now);
-				//binding.setNodeId(modelBusinessEntity.getEntityKey());
+                                //binding.setNodeId(modelBusinessEntity.getEntityKey());
                                 //binding.setNodeId(config.getString(Property.JUDDI_NODE_ID,modelBusinessEntity.getEntityKey()));
                                 //JUDDI-645
 
@@ -321,18 +331,18 @@ public class Install {
 
         }
 
-	// A watered down version of ValidatePublish's validateBusinessEntity, designed for the
specific condition that this is run upon the initial
+        // A watered down version of ValidatePublish's validateBusinessEntity, designed for
the specific condition that this is run upon the initial
         // jUDDI install.
         private static void validateRootBusinessEntity(org.uddi.api_v3.BusinessEntity businessEntity,
UddiEntityPublisher rootPublisher,
-             String rootPartition, Configuration config)
-             throws DispositionReportFaultMessage {
+                String rootPartition, Configuration config)
+                throws DispositionReportFaultMessage {
 
                 // A supplied businessService can't be null
                 if (businessEntity == null) {
                         throw new ValueNotAllowedException(new ErrorMessage("errors.businessentity.NullInput"));
                 }
 
-		// The business key should already be set to the previously calculated and validated nodeId.
 This validation is unnecessary but kept for 
+                // The business key should already be set to the previously calculated and
validated nodeId.  This validation is unnecessary but kept for 
                 // symmetry with the other entity validations.
                 String entityKey = businessEntity.getBusinessKey();
                 if (entityKey == null || entityKey.length() == 0) {
@@ -372,11 +382,11 @@ public class Install {
 
         }
 
-	// A watered down version of ValidatePublish's validateBusinessService, designed for the
specific condition that this is run upon the initial
+        // A watered down version of ValidatePublish's validateBusinessService, designed
for the specific condition that this is run upon the initial
         // jUDDI install.
         private static void validateRootBusinessService(org.uddi.api_v3.BusinessService businessService,
org.uddi.api_v3.BusinessEntity parent,
-             UddiEntityPublisher rootPublisher, String rootPartition, Configuration config)
-             throws DispositionReportFaultMessage {
+                UddiEntityPublisher rootPublisher, String rootPartition, Configuration config)
+                throws DispositionReportFaultMessage {
 
                 // A supplied businessService can't be null
                 if (businessService == null) {
@@ -426,11 +436,11 @@ public class Install {
                 }
         }
 
-	// A watered down version of ValidatePublish's validatBindingTemplate, designed for the
specific condition that this is run upon the initial
+        // A watered down version of ValidatePublish's validatBindingTemplate, designed for
the specific condition that this is run upon the initial
         // jUDDI install.
         private static void validateRootBindingTemplate(org.uddi.api_v3.BindingTemplate bindingTemplate,
org.uddi.api_v3.BusinessService parent,
-             UddiEntityPublisher rootPublisher, String rootPartition, Configuration config)
-             throws DispositionReportFaultMessage {
+                UddiEntityPublisher rootPublisher, String rootPartition, Configuration config)
+                throws DispositionReportFaultMessage {
 
                 // A supplied businessService can't be null
                 if (bindingTemplate == null) {
@@ -491,7 +501,7 @@ public class Install {
                                         modelTModel.setNodeId(nodeId);
 
                                         em.persist(modelTModel);
-                                        
+
                                         SaveTModel stm = new SaveTModel();
                                         stm.getTModel().add(apiTModel);
                                         ReplicationNotifier.Enqueue(UDDIPublicationImpl.getChangeRecord(modelTModel,
apiTModel, nodeId));
@@ -503,7 +513,7 @@ public class Install {
         }
 
         private static void installRootPublisherKeyGen(EntityManager em, TModel rootTModelKeyGen,
String rootPartition, UddiEntityPublisher publisher, String nodeId)
-             throws DispositionReportFaultMessage {
+                throws DispositionReportFaultMessage {
 
                 rootTModelKeyGen.setTModelKey(rootPartition + KeyGenerator.PARTITION_SEPARATOR
+ KeyGenerator.KEYGENERATOR_SUFFIX);
 
@@ -605,6 +615,42 @@ public class Install {
                 return publishers;
         }
 
+        private static Object buildInstallEntityAlt(final String fileName, Class outputtype,
Configuration config) throws JAXBException, IOException, ConfigurationException {
+                InputStream resourceStream = null;
+
+                // First try the custom install directory
+                URL url = ClassUtil.getResource(JUDDI_CUSTOM_INSTALL_DATA_DIR + fileName,
Install.class);
+                if (url != null) {
+                        resourceStream = url.openStream();
+                }
+
+                // If the custom install directory doesn't exist, then use the standard install
directory where the resource is guaranteed to exist.
+                if (resourceStream == null) {
+                        url = ClassUtil.getResource(JUDDI_INSTALL_DATA_DIR + fileName, Install.class);
+                        if (url != null) {
+                                resourceStream = url.openStream();
+                        }
+                        // If file still does not exist then return null;
+                        if (url == null || resourceStream == null) {
+                                if (fileName.endsWith(FILE_PUBLISHER)) {
+                                        throw new ConfigurationException("Could not locate
" + JUDDI_INSTALL_DATA_DIR + fileName);
+                                } else {
+                                        log.debug("Could not locate: " + url);
+                                }
+                                return null;
+                        }
+                }
+                log.info("Loading the content of file: " + url);
+                StringBuilder xml = new StringBuilder();
+                byte[] b = new byte[4096];
+                for (int n; (n = resourceStream.read(b)) != -1;) {
+                        xml.append(new String(b, 0, n));
+                }
+                log.debug("inserting: " + xml.toString());
+                StringReader reader = new StringReader(xml.toString());
+                return JAXB.unmarshal(reader, outputtype);
+        }
+
         private static Object buildInstallEntity(final String fileName, String packageName,
Configuration config) throws JAXBException, IOException, ConfigurationException {
                 InputStream resourceStream = null;
 
@@ -685,7 +731,7 @@ public class Install {
          * @throws ConfigurationException
          */
         public static void installSaveTModel(EntityManager em, String fileName, UddiEntityPublisher
publisher, String nodeId, Configuration config)
-             throws JAXBException, DispositionReportFaultMessage, IOException, ConfigurationException
{
+                throws JAXBException, DispositionReportFaultMessage, IOException, ConfigurationException
{
 
                 SaveTModel apiSaveTModel = (SaveTModel) buildInstallEntity(fileName, "org.uddi.api_v3",
config);
                 if (apiSaveTModel != null) {
@@ -706,7 +752,7 @@ public class Install {
          * @throws ConfigurationException
          */
         public static UddiEntityPublisher installPublisher(EntityManager em, String fileName,
Configuration config)
-             throws JAXBException, DispositionReportFaultMessage, IOException, ConfigurationException
{
+                throws JAXBException, DispositionReportFaultMessage, IOException, ConfigurationException
{
 
                 org.apache.juddi.api_v3.Publisher apiPub = (org.apache.juddi.api_v3.Publisher)
buildInstallEntity(fileName, "org.apache.juddi.api_v3", config);
                 if (apiPub == null) {
@@ -718,4 +764,61 @@ public class Install {
                 return modelPub;
         }
 
+        public static org.uddi.repl_v3.ReplicationConfiguration applyReplicationTokenChanges(org.uddi.repl_v3.ReplicationConfiguration
replicationCfg, Configuration config, String thisnode) {
+                log.info("replacing tokens on repl config");
+                if (replicationCfg == null) {
+                        return null;
+                }
+                //apply any token replacements
+                for (Operator op : replicationCfg.getOperator()) {
+                        op.setOperatorNodeID(op.getOperatorNodeID().replace("${juddi.nodeId}",
thisnode));
+                        op.setSoapReplicationURL(op.getSoapReplicationURL().replace("${juddi.server.baseurlsecure}",
config.getString("juddi.server.baseurlsecure")));
+                        op.setSoapReplicationURL(op.getSoapReplicationURL().replace("${juddi.server.baseurl}",
config.getString("juddi.server.baseurl")));
+                }
+                if (replicationCfg.getCommunicationGraph() != null) {
+                        for (int i = 0; i < replicationCfg.getCommunicationGraph().getNode().size();
i++) {
+                                replicationCfg.getCommunicationGraph().getNode().set(i, replicationCfg.getCommunicationGraph().getNode().get(i).replace("${juddi.nodeId}",
thisnode));
+
+                        }
+                        for (int i = 0; i < replicationCfg.getCommunicationGraph().getEdge().size();
i++) {
+                                replicationCfg.getCommunicationGraph().getEdge().get(i).setMessageSender(replicationCfg.getCommunicationGraph().getEdge().get(i).getMessageSender().replace("${juddi.nodeId}",
thisnode));
+                                replicationCfg.getCommunicationGraph().getEdge().get(i).setMessageReceiver(replicationCfg.getCommunicationGraph().getEdge().get(i).getMessageReceiver().replace("${juddi.nodeId}",
thisnode));
+                                for (int k = 0; k < replicationCfg.getCommunicationGraph().getEdge().get(i).getMessageReceiverAlternate().size();
k++) {
+                                        replicationCfg.getCommunicationGraph().getEdge().get(i).getMessageReceiverAlternate().set(k,
replicationCfg.getCommunicationGraph().getEdge().get(i).getMessageReceiverAlternate().get(k).replace("${juddi.nodeId}",
thisnode));
+                                }
+                        }
+                }
+
+                for (Operator op : replicationCfg.getOperator()) {
+                        op.setOperatorNodeID(op.getOperatorNodeID().replace("${juddi.nodeId}",
thisnode));
+                }
+                log.info("replacing tokens on repl config, done");
+                return replicationCfg;
+        }
+
+        private static void installReplicationConfiguration(EntityManager em, org.uddi.repl_v3.ReplicationConfiguration
replicationCfg, Configuration config, String thisnode) throws DispositionReportFaultMessage,
ConfigurationException {
+                replicationCfg = applyReplicationTokenChanges(replicationCfg, config, thisnode);
+                new ValidateReplication(null, thisnode).validateSetReplicationNodes(replicationCfg,
em, thisnode, config);
+
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmZ");
+                replicationCfg.setTimeOfConfigurationUpdate(sdf.format(new Date()));
+
+                org.apache.juddi.model.ReplicationConfiguration model = new ReplicationConfiguration();
+
+                MappingApiToModel.mapReplicationConfiguration(replicationCfg, model, em);
+
+                model.setSerialNumber(System.currentTimeMillis());
+
+                org.apache.juddi.model.ReplicationConfiguration oldstuff = null;
+                // logger.info(publisher.getAuthorizedName() + " is setting the replication
config from " + getRequestorsIPAddress());// + " " + sw.toString());
+                try {
+                        oldstuff = (ReplicationConfiguration) em.createQuery("select c FROM
ReplicationConfiguration c order by c.serialNumber desc").getSingleResult();
+                } catch (Exception ex) {
+                }
+                if (oldstuff != null) {
+                        em.remove(oldstuff);
+                }
+                em.persist(model);
+        }
+
 }

http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java
b/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java
index 59d5b6a..e96459e 100644
--- a/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java
+++ b/juddi-core/src/main/java/org/apache/juddi/replication/ReplicationNotifier.java
@@ -221,7 +221,7 @@ public class ReplicationNotifier extends TimerTask {
 
                 UDDIReplicationPortType x = uddiService.getUDDIReplicationPort();
                 if (destinationUrls.isEmpty()) {
-                        log.fatal("Something is bizarre with the replication config. I should
have had at least one node to notify, but I have none!");
+                        log.debug("Something is bizarre with the replication config. I should
have had at least one node to notify, but I have none!");
                 }
                 for (Object s : destinationUrls) {
 

http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
b/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
index 521f47e..5d1a7c5 100644
--- a/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
+++ b/juddi-core/src/main/java/org/apache/juddi/subscription/notify/USERFRIENDLYSMTPNotifier.java
@@ -175,7 +175,8 @@ public class USERFRIENDLYSMTPNotifier extends SMTPNotifier {
                         Transport.send(message);
 
                 } catch (Throwable t) {
-                        log.error("Error sending email!" + t.getMessage(), t);
+                        log.warn("Error sending email!" + t.getMessage());
+                        log.debug("Error sending email!" + t.getMessage(),t);
                 }
         }
 
@@ -271,7 +272,8 @@ public class USERFRIENDLYSMTPNotifier extends SMTPNotifier {
                         Transport.send(message);
 
                 } catch (Throwable t) {
-                        log.error("Error sending email!" + t.getMessage(), t);
+                        log.warn("Error sending email!" + t.getMessage());
+                        log.debug("Error sending email!" + t.getMessage(), t);
                 }
         }
 

http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java
b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java
index 92bfa03..8fa247c 100644
--- a/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java
+++ b/juddi-core/src/main/java/org/apache/juddi/validation/ValidateReplication.java
@@ -17,11 +17,22 @@
 package org.apache.juddi.validation;
 
 import java.math.BigInteger;
+import java.security.cert.CertificateException;
 import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicReference;
 import javax.persistence.EntityManager;
 import javax.xml.ws.WebServiceContext;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.Property;
 import org.apache.juddi.model.Node;
 import org.apache.juddi.model.UddiEntityPublisher;
+import org.apache.juddi.v3.client.cryptor.CryptorFactory;
+import org.apache.juddi.v3.client.cryptor.DigSigUtil;
 import org.apache.juddi.v3.error.ErrorMessage;
 import org.apache.juddi.v3.error.FatalErrorException;
 import org.apache.juddi.v3.error.InvalidValueException;
@@ -45,9 +56,14 @@ import org.uddi.v3_service.DispositionReportFaultMessage;
  */
 public class ValidateReplication extends ValidateUDDIApi {
 
+        private final static Log log = LogFactory.getLog(ValidateReplication.class);
         public ValidateReplication(UddiEntityPublisher publisher) {
                 super(publisher);
         }
+        
+       public ValidateReplication(UddiEntityPublisher publisher, String nodeid) {
+		 super(publisher, nodeid);
+	}
 
         public void validateNotifyChangeRecordsAvailable(NotifyChangeRecordsAvailable body,
WebServiceContext ctx) throws DispositionReportFaultMessage {
                 //TODO
@@ -120,7 +136,7 @@ public class ValidateReplication extends ValidateUDDIApi {
                 return false;
         }
 
-        public void validateSetReplicationNodes(ReplicationConfiguration replicationConfiguration,
EntityManager em, String thisnode) throws DispositionReportFaultMessage {
+        public void validateSetReplicationNodes(ReplicationConfiguration replicationConfiguration,
EntityManager em, String thisnode, Configuration config) throws DispositionReportFaultMessage,
ConfigurationException {
                 if (replicationConfiguration == null) {
                         throw new InvalidValueException(new ErrorMessage("errors.replication.configNull"));
 
@@ -182,8 +198,71 @@ public class ValidateReplication extends ValidateUDDIApi {
 
                         }
                 }
+                boolean shouldcheck = config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_ENABLE,
false);
+                initDigSig(config);
+                if (shouldcheck && !replicationConfiguration.getSignature().isEmpty()
&& ds != null) {
+                        AtomicReference<String> outmsg = new AtomicReference<String>();
+                        boolean ok = ds.verifySignedUddiEntity(replicationConfiguration,
outmsg);
+                        if (!ok) {
+                                throw new FatalErrorException(new ErrorMessage("errors.digitalsignature.validationfailure"
+ " " + outmsg.get()));
+                        }
+
+                }
+        }
+        
+         private org.apache.juddi.v3.client.cryptor.DigSigUtil ds = null;
+
+        private synchronized void initDigSig(Configuration config) {
+                if (ds == null) {
+                        
+                        Properties p = new Properties();
+                        /**
+                         * <trustStorePath>truststore.jks</trustStorePath>
+                         * <trustStoreType>JKS</trustStoreType>
+                         * <trustStorePassword
+                         * isPasswordEncrypted="false"
+                         * cryptoProvider="org.apache.juddi.v3.client.crypto.AES128Cryptor">password</trustStorePassword>
+                         *
+                         * <checkTimestamps>true</checkTimestamps>
+                         * <checkTrust>true</checkTrust>
+                         * <checkRevocationCRL>true</checkRevocationCRL>
+                         */
+                        p.put(DigSigUtil.TRUSTSTORE_FILE, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX
+ "trustStorePath", ""));
+                        p.put(DigSigUtil.TRUSTSTORE_FILETYPE, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX
+ "trustStoreType", ""));
+
+                        String enc = config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX
+ "trustStorePassword", "");
+                        if (config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX
+ "trustStorePassword[@isPasswordEncrypted]", false)) {
+                                log.info("trust password is encrypted, decrypting...");
+                                
+                                String prov = config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX
+ "trustStorePassword[@cryptoProvider]", "");
+                                try {
+                                        p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD,
CryptorFactory.getCryptor(prov).decrypt(enc));
+                                } catch (Exception ex) {
+                                        log.warn("unable to decrypt trust store password
" + ex.getMessage());
+                                        log.debug("unable to decrypt trust store password
" + ex.getMessage(), ex);
+                                }
+
+                        } else if (!"".equals(enc)){
+                                log.warn("Hey, you should consider encrypting your trust
store password!");
+                                p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, enc);
+                        }
+
+                        p.put(DigSigUtil.CHECK_REVOCATION_STATUS_CRL, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX
+ "checkRevocationCRL", "true"));
+                        p.put(DigSigUtil.CHECK_TRUST_CHAIN, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX
+ "checkTrust", "true"));
+                        p.put(DigSigUtil.CHECK_TIMESTAMPS, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX
+ "checkTimestamps", "true"));
+
+                        try {
+                                ds = new DigSigUtil(p);
+                        } catch (CertificateException ex) {
+                                log.error("", ex);
+                        }
+                        //System.out.println("loaded from " + AppConfig.getConfigFileURL());
+                        //p.list(System.out);
+                }
         }
 
+      
+
         private boolean Contains(List<Operator> operator, String s) {
                 if (operator == null) {
                         return false;

http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/juddi-core/src/main/resources/juddi_install_data/root_replicationConfiguration.xml
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/resources/juddi_install_data/root_replicationConfiguration.xml
b/juddi-core/src/main/resources/juddi_install_data/root_replicationConfiguration.xml
new file mode 100644
index 0000000..cf950d0
--- /dev/null
+++ b/juddi-core/src/main/resources/juddi_install_data/root_replicationConfiguration.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright 2015 The Apache Software Foundation.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<replicationConfiguration xmlns="urn:uddi-org:repl_v3" xmlns:ns2="urn:uddi-org:api_v3"
xmlns:ns3="http://www.w3.org/2000/09/xmldsig#">
+    <serialNumber>0</serialNumber>
+    <timeOfConfigurationUpdate></timeOfConfigurationUpdate>
+    <registryContact>
+        <ns2:contact>
+            <ns2:personName>Unknown</ns2:personName>
+        </ns2:contact>
+    </registryContact>
+    <operator>
+        <operatorNodeID>${juddi.nodeId}</operatorNodeID>
+        <operatorStatus>normal</operatorStatus>
+        <ns2:contact>
+            <ns2:personName>Unknown</ns2:personName>
+        </ns2:contact>
+        <soapReplicationURL>${juddi.server.baseurl}/services/replication</soapReplicationURL>
+    </operator>
+    <communicationGraph>
+        <node>${juddi.nodeId}</node>
+        <controlledMessage>*</controlledMessage>
+    </communicationGraph>
+    <maximumTimeToSyncRegistry>1</maximumTimeToSyncRegistry>
+    <maximumTimeToGetChanges>1</maximumTimeToGetChanges>
+</replicationConfiguration>

http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/juddi-core/src/test/java/org/apache/juddi/config/InstallTest.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/test/java/org/apache/juddi/config/InstallTest.java b/juddi-core/src/test/java/org/apache/juddi/config/InstallTest.java
new file mode 100644
index 0000000..b88aab5
--- /dev/null
+++ b/juddi-core/src/test/java/org/apache/juddi/config/InstallTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2015 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.config;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.StringWriter;
+import java.util.Properties;
+import javax.persistence.EntityManager;
+import javax.xml.bind.JAXB;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.MapConfiguration;
+import org.apache.juddi.model.UddiEntityPublisher;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.uddi.api_v3.BusinessEntity;
+import org.uddi.api_v3.TModel;
+import org.uddi.repl_v3.ReplicationConfiguration;
+
+/**
+ *
+ * @author alex
+ */
+public class InstallTest {
+        
+        public InstallTest() {
+        }
+        
+        @BeforeClass
+        public static void setUpClass() {
+        }
+        
+        @AfterClass
+        public static void tearDownClass() {
+        }
+        
+        @Before
+        public void setUp() {
+        }
+        
+        @After
+        public void tearDown() {
+        }
+
+        /**
+         * Test of applyReplicationTokenChanges method, of class Install.
+         */
+        @Test
+        public void testApplyReplicationTokenChanges() throws Exception {
+                System.out.println("applyReplicationTokenChanges");
+                FileInputStream fis = new FileInputStream("./src/main/resources/juddi_install_data/root_replicationConfiguration.xml");
+                
+                ReplicationConfiguration replicationCfg = JAXB.unmarshal(fis, ReplicationConfiguration.class);
+                Properties props = new Properties();
+                props.put(Property.JUDDI_NODE_ID, "uddi:a_custom_node");
+                props.put(Property.JUDDI_BASE_URL, "http://juddi.apache.org");
+                props.put(Property.JUDDI_BASE_URL_SECURE, "https://juddi.apache.org");
+                
+                Configuration config = new MapConfiguration(props);
+                String thisnode = "uddi:a_custom_node";
+                
+                ReplicationConfiguration result = Install.applyReplicationTokenChanges(replicationCfg,
config, thisnode);
+                StringWriter sw = new StringWriter();
+                JAXB.marshal(result, sw);
+                Assert.assertFalse(sw.toString().contains("${juddi.nodeId}"));
+                Assert.assertFalse(sw.toString().contains("${juddi.server.baseurlsecure}"));
+                Assert.assertFalse(sw.toString().contains("${juddi.server.baseurl}"));
+                
+        }
+        
+}

http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/juddi-core/src/test/resources/juddiv3DisabledTModelKeybag.xml
----------------------------------------------------------------------
diff --git a/juddi-core/src/test/resources/juddiv3DisabledTModelKeybag.xml b/juddi-core/src/test/resources/juddiv3DisabledTModelKeybag.xml
index 66e3914..ff6ce9d 100644
--- a/juddi-core/src/test/resources/juddiv3DisabledTModelKeybag.xml
+++ b/juddi-core/src/test/resources/juddiv3DisabledTModelKeybag.xml
@@ -176,8 +176,9 @@
                             <trustStorePath>./src/test/resources/truststore.jks</trustStorePath>
                             <trustStoreType>JKS</trustStoreType>
                             <trustStorePassword
-                                    isPasswordEncrypted="false" 
-                                    cryptoProvider="org.apache.juddi.v3.client.crypto.AES128Cryptor">Test</trustStorePassword>
+                                    isPasswordEncrypted="true" 
+                                    cryptoProvider="org.apache.juddi.v3.client.crypto.AES128Cryptor">8133dcd169105875a711e4b8b3e03bce</trustStorePassword>
+                                    <!-- Test -->
 
                             <checkTimestamps>true</checkTimestamps>
                             <checkTrust>true</checkTrust>

http://git-wip-us.apache.org/repos/asf/juddi/blob/ac44bfd3/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
b/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
index 90b1f73..9a8c168 100644
--- a/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
+++ b/uddi-tck/src/test/java/org/apache/juddi/v3/tck/JUDDI_300_MultiNodeIntegrationTest.java
@@ -744,7 +744,9 @@ public class JUDDI_300_MultiNodeIntegrationTest {
 
                         resetBusinesses();
                         resetTmodels();
-
+                        try{
+                        samTModelNode2.saveTmodels(rootNode2Token);
+                        }catch (Exception ex){}
                         samTModelNode2.saveSamSyndicatorTmodel(samTokenNode2);
                         samBizNode2.saveSamSyndicatorBusiness(samTokenNode2);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org


Mime
View raw message