| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ValidatePublish.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">jUDDI Core - OpenJPA</a> > <a href="index.source.html" class="el_package">org.apache.juddi.validation</a> > <span class="el_source">ValidatePublish.java</span></div><h1>ValidatePublish.java</h1><pre class="source lang-java linenums">/* |
| * Copyright 2001-2008 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.validation; |
| |
| import java.net.MalformedURLException; |
| import java.net.URL; |
| import java.security.cert.CertificateException; |
| import java.util.ArrayList; |
| import java.util.HashMap; |
| import java.util.HashSet; |
| import java.util.List; |
| import java.util.Map; |
| import java.util.Properties; |
| import java.util.concurrent.atomic.AtomicReference; |
| |
| import javax.persistence.EntityManager; |
| import javax.persistence.EntityTransaction; |
| import javax.xml.ws.Holder; |
| |
| 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.api_v3.AccessPointType; |
| import org.apache.juddi.api_v3.DeleteClerk; |
| import org.apache.juddi.api_v3.DeleteNode; |
| import org.apache.juddi.api_v3.DeletePublisher; |
| import org.apache.juddi.api_v3.SavePublisher; |
| import org.apache.juddi.config.AppConfig; |
| import org.apache.juddi.config.Constants; |
| import org.apache.juddi.config.Install; |
| import org.apache.juddi.config.PersistenceManager; |
| import org.apache.juddi.config.Property; |
| import org.apache.juddi.keygen.KeyGenerator; |
| import org.apache.juddi.keygen.KeyGeneratorFactory; |
| import org.apache.juddi.mapping.MappingModelToApi; |
| import org.apache.juddi.model.Publisher; |
| import org.apache.juddi.model.Tmodel; |
| import org.apache.juddi.model.UddiEntity; |
| import org.apache.juddi.model.UddiEntityPublisher; |
| import org.apache.juddi.query.FindBusinessByPublisherQuery; |
| import org.apache.juddi.query.FindTModelByPublisherQuery; |
| import org.apache.juddi.v3.client.UDDIConstants; |
| import org.apache.juddi.v3.client.UDDIConstantsV2; |
| import org.apache.juddi.v3.client.config.TokenResolver; |
| import org.apache.juddi.v3.client.cryptor.CryptorFactory; |
| import org.apache.juddi.v3.client.cryptor.DigSigUtil; |
| import org.apache.juddi.v3.error.AssertionNotFoundException; |
| import org.apache.juddi.v3.error.ErrorMessage; |
| import org.apache.juddi.v3.error.FatalErrorException; |
| import org.apache.juddi.v3.error.InvalidKeyPassedException; |
| import org.apache.juddi.v3.error.InvalidProjectionException; |
| import org.apache.juddi.v3.error.KeyUnavailableException; |
| import org.apache.juddi.v3.error.MaxEntitiesExceededException; |
| import org.apache.juddi.v3.error.UserMismatchException; |
| import org.apache.juddi.v3.error.ValueNotAllowedException; |
| import org.uddi.api_v3.AccessPoint; |
| import org.uddi.api_v3.AddPublisherAssertions; |
| import org.uddi.api_v3.AddressLine; |
| import org.uddi.api_v3.BindingTemplate; |
| import org.uddi.api_v3.BusinessEntity; |
| import org.uddi.api_v3.BusinessService; |
| import org.uddi.api_v3.DeleteBinding; |
| import org.uddi.api_v3.DeleteBusiness; |
| import org.uddi.api_v3.DeletePublisherAssertions; |
| import org.uddi.api_v3.DeleteService; |
| import org.uddi.api_v3.DeleteTModel; |
| import org.uddi.api_v3.Description; |
| import org.uddi.api_v3.DiscoveryURL; |
| import org.uddi.api_v3.Email; |
| import org.uddi.api_v3.HostingRedirector; |
| import org.uddi.api_v3.KeyedReference; |
| import org.uddi.api_v3.KeyedReferenceGroup; |
| import org.uddi.api_v3.Name; |
| import org.uddi.api_v3.OverviewDoc; |
| import org.uddi.api_v3.OverviewURL; |
| import org.uddi.api_v3.Phone; |
| import org.uddi.api_v3.SaveBinding; |
| import org.uddi.api_v3.SaveBusiness; |
| import org.uddi.api_v3.SaveService; |
| import org.uddi.api_v3.SaveTModel; |
| import org.uddi.api_v3.TModel; |
| import org.uddi.repl_v3.ReplicationConfiguration; |
| import org.uddi.sub_v3.Subscription; |
| import org.uddi.v3_service.DispositionReportFaultMessage; |
| |
| /** |
| * Provides validation of publish requests to Juddi |
| * |
| * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a> |
| * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a> |
| * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a> Modified March |
| * 2013 to validate string length and ref integrity |
| * |
| * Advisory, be careful calling AppConfig.getConfiguration() from within |
| * validation functions, it may inadvertently cause infinite loops during the |
| * Install phase |
| * @see Install |
| */ |
| public class ValidatePublish extends ValidateUDDIApi { |
| |
| <span class="fc" id="L116"> private static final Log log = LogFactory.getLog(ValidatePublish.class);</span> |
| |
| /** |
| * used from Install class |
| * |
| * @param publisher |
| * @param nodeid |
| * @see Install |
| */ |
| public ValidatePublish(UddiEntityPublisher publisher, String nodeid) { |
| <span class="fc" id="L126"> super(publisher, nodeid);</span> |
| <span class="fc" id="L127"> }</span> |
| |
| public ValidatePublish(UddiEntityPublisher publisher) { |
| <span class="fc" id="L130"> super(publisher);</span> |
| <span class="fc" id="L131"> }</span> |
| |
| public void validateDeleteBusiness(EntityManager em, DeleteBusiness body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L136" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L137"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L141"> List<String> entityKeyList = body.getBusinessKey();</span> |
| <span class="pc bpc" id="L142" title="2 of 4 branches missed."> if (entityKeyList == null || entityKeyList.size() == 0) {</span> |
| <span class="nc" id="L143"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));</span> |
| } |
| |
| <span class="fc" id="L146"> HashSet<String> dupCheck = new HashSet<String>();</span> |
| <span class="fc" id="L147"> int i = 0;</span> |
| <span class="fc bfc" id="L148" title="All 2 branches covered."> for (String entityKey : entityKeyList) {</span> |
| |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L151"> entityKey = entityKey.toLowerCase();</span> |
| <span class="fc" id="L152"> entityKeyList.set(i, entityKey);</span> |
| |
| <span class="fc" id="L154"> boolean inserted = dupCheck.add(entityKey);</span> |
| <span class="pc bpc" id="L155" title="1 of 2 branches missed."> if (!inserted) {</span> |
| <span class="nc" id="L156"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));</span> |
| } |
| |
| <span class="fc" id="L159"> Object obj = em.find(org.apache.juddi.model.BusinessEntity.class, entityKey);</span> |
| <span class="pc bpc" id="L160" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L161"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", entityKey));</span> |
| } |
| |
| <span class="pc bpc" id="L164" title="3 of 4 branches missed."> if (!publisher.isOwner((UddiEntity) obj) && !((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L165"> throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey));</span> |
| } |
| |
| <span class="fc" id="L168"> i++;</span> |
| <span class="fc" id="L169"> }</span> |
| <span class="fc" id="L170"> }</span> |
| |
| public void validateDeleteService(EntityManager em, DeleteService body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L175" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L176"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L180"> List<String> entityKeyList = body.getServiceKey();</span> |
| <span class="pc bpc" id="L181" title="2 of 4 branches missed."> if (entityKeyList == null || entityKeyList.size() == 0) {</span> |
| <span class="nc" id="L182"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));</span> |
| } |
| |
| <span class="fc" id="L185"> HashSet<String> dupCheck = new HashSet<String>();</span> |
| <span class="fc" id="L186"> int i = 0;</span> |
| <span class="fc bfc" id="L187" title="All 2 branches covered."> for (String entityKey : entityKeyList) {</span> |
| |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L190"> entityKey = entityKey.toLowerCase();</span> |
| <span class="fc" id="L191"> entityKeyList.set(i, entityKey);</span> |
| |
| <span class="fc" id="L193"> boolean inserted = dupCheck.add(entityKey);</span> |
| <span class="pc bpc" id="L194" title="1 of 2 branches missed."> if (!inserted) {</span> |
| <span class="nc" id="L195"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));</span> |
| } |
| |
| <span class="fc" id="L198"> Object obj = em.find(org.apache.juddi.model.BusinessService.class, entityKey);</span> |
| <span class="pc bpc" id="L199" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L200"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound", entityKey));</span> |
| } |
| |
| //if you're are the owner, access granted |
| //if you are an admin && this item belongs to this node, access granted |
| //else denied |
| <span class="fc" id="L206"> AccessCheck(obj, entityKey);</span> |
| <span class="fc" id="L207"> i++;</span> |
| <span class="fc" id="L208"> }</span> |
| <span class="fc" id="L209"> }</span> |
| |
| public void validateDeleteBinding(EntityManager em, DeleteBinding body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L214" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L215"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L219"> List<String> entityKeyList = body.getBindingKey();</span> |
| <span class="pc bpc" id="L220" title="2 of 4 branches missed."> if (entityKeyList == null || entityKeyList.size() == 0) {</span> |
| <span class="nc" id="L221"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));</span> |
| } |
| |
| // Checking for duplicates and existence |
| <span class="fc" id="L225"> HashSet<String> dupCheck = new HashSet<String>();</span> |
| <span class="fc" id="L226"> int i = 0;</span> |
| <span class="fc bfc" id="L227" title="All 2 branches covered."> for (String entityKey : entityKeyList) {</span> |
| <span class="fc" id="L228"> validateKeyLength(entityKey);</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L230"> entityKey = entityKey.toLowerCase();</span> |
| <span class="fc" id="L231"> entityKeyList.set(i, entityKey);</span> |
| |
| <span class="fc" id="L233"> boolean inserted = dupCheck.add(entityKey);</span> |
| <span class="pc bpc" id="L234" title="1 of 2 branches missed."> if (!inserted) {</span> |
| <span class="nc" id="L235"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));</span> |
| } |
| |
| <span class="fc" id="L238"> Object obj = em.find(org.apache.juddi.model.BindingTemplate.class, entityKey);</span> |
| <span class="pc bpc" id="L239" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L240"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BindingTemplateNotFound", entityKey));</span> |
| } |
| |
| <span class="fc" id="L243"> AccessCheck(obj, entityKey);</span> |
| |
| <span class="fc" id="L245"> i++;</span> |
| <span class="fc" id="L246"> }</span> |
| <span class="fc" id="L247"> }</span> |
| |
| public void validateDeleteTModel(EntityManager em, DeleteTModel body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L252" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L253"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L257"> List<String> entityKeyList = body.getTModelKey();</span> |
| <span class="pc bpc" id="L258" title="2 of 4 branches missed."> if (entityKeyList == null || entityKeyList.size() == 0) {</span> |
| <span class="nc" id="L259"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));</span> |
| } |
| |
| <span class="fc" id="L262"> HashSet<String> dupCheck = new HashSet<String>();</span> |
| <span class="fc" id="L263"> int i = 0;</span> |
| <span class="fc bfc" id="L264" title="All 2 branches covered."> for (String entityKey : entityKeyList) {</span> |
| <span class="fc" id="L265"> validateKeyLength(entityKey);</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L267"> entityKey = entityKey.toLowerCase();</span> |
| <span class="fc" id="L268"> entityKeyList.set(i, entityKey);</span> |
| |
| <span class="fc" id="L270"> boolean inserted = dupCheck.add(entityKey);</span> |
| <span class="pc bpc" id="L271" title="1 of 2 branches missed."> if (!inserted) {</span> |
| <span class="nc" id="L272"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));</span> |
| } |
| |
| <span class="fc" id="L275"> Object obj = em.find(org.apache.juddi.model.Tmodel.class, entityKey);</span> |
| <span class="pc bpc" id="L276" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L277"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.TModelNotFound", entityKey));</span> |
| } |
| |
| <span class="fc" id="L280"> AccessCheck(obj, entityKey);</span> |
| |
| <span class="fc" id="L282"> i++;</span> |
| <span class="fc" id="L283"> }</span> |
| <span class="fc" id="L284"> }</span> |
| |
| private void AccessCheck(Object obj, String entityKey) throws UserMismatchException { |
| <span class="fc" id="L287"> boolean accessCheck = false; //assume access denied</span> |
| <span class="fc bfc" id="L288" title="All 2 branches covered."> if (!((UddiEntity) obj).getNodeId().equals(nodeID)) {</span> |
| //prevent changes to data owned by another node in a replicated environment |
| //even if you're the boss |
| <span class="fc" id="L291"> throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidNode", entityKey + " Owning Node: " + ((UddiEntity) obj).getNodeId()</span> |
| + ", this node: " + nodeID)); |
| } |
| |
| <span class="pc bpc" id="L295" title="1 of 4 branches missed."> if (publisher.isOwner((UddiEntity) obj) && nodeID.equals(((UddiEntity) obj).getNodeId())) {</span> |
| <span class="fc" id="L296"> accessCheck = true;</span> |
| |
| } |
| //if i'm an admin, let me edit stuff on this node, but only stuff that's owned by this node |
| <span class="fc bfc" id="L300" title="All 2 branches covered."> if (((Publisher) publisher).isAdmin()</span> |
| <span class="pc bpc" id="L301" title="1 of 2 branches missed."> && nodeID.equals(((UddiEntity) obj).getNodeId())) {</span> |
| <span class="fc" id="L302"> accessCheck = true;</span> |
| } |
| |
| <span class="pc bpc" id="L305" title="1 of 2 branches missed."> if (!accessCheck) {</span> |
| <span class="nc" id="L306"> throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey));</span> |
| } |
| |
| <span class="fc" id="L309"> }</span> |
| |
| public void validateDeletePublisherAssertions(EntityManager em, DeletePublisherAssertions body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L314" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L315"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L319"> List<org.uddi.api_v3.PublisherAssertion> entityList = body.getPublisherAssertion();</span> |
| <span class="pc bpc" id="L320" title="2 of 4 branches missed."> if (entityList == null || entityList.size() == 0) {</span> |
| <span class="nc" id="L321"> throw new AssertionNotFoundException(new ErrorMessage("errors.pubassertion.NoPubAssertions"));</span> |
| } |
| |
| <span class="fc bfc" id="L324" title="All 2 branches covered."> for (org.uddi.api_v3.PublisherAssertion entity : entityList) {</span> |
| <span class="fc" id="L325"> validateKeyLength(entity.getFromKey());</span> |
| <span class="fc" id="L326"> validateKeyLength(entity.getToKey());</span> |
| <span class="fc" id="L327"> validatePublisherAssertion(em, entity);</span> |
| |
| <span class="fc" id="L329"> org.apache.juddi.model.PublisherAssertionId pubAssertionId = new org.apache.juddi.model.PublisherAssertionId(entity.getFromKey(), entity.getToKey());</span> |
| <span class="fc" id="L330"> Object obj = em.find(org.apache.juddi.model.PublisherAssertion.class, pubAssertionId);</span> |
| <span class="pc bpc" id="L331" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L332"> throw new AssertionNotFoundException(new ErrorMessage("errors.pubassertion.AssertionNotFound", entity.getFromKey() + ", " + entity.getToKey()));</span> |
| } else { |
| <span class="fc" id="L334"> org.apache.juddi.model.PublisherAssertion pubAssertion = (org.apache.juddi.model.PublisherAssertion) obj;</span> |
| <span class="fc" id="L335"> org.uddi.api_v3.KeyedReference keyedRef = entity.getKeyedReference();</span> |
| <span class="pc bpc" id="L336" title="1 of 2 branches missed."> if (keyedRef == null) {</span> |
| <span class="nc" id="L337"> throw new AssertionNotFoundException(new ErrorMessage("errors.pubassertion.AssertionNotFound", entity.getFromKey() + ", " + entity.getToKey()));</span> |
| } |
| |
| <span class="pc bpc" id="L340" title="1 of 2 branches missed."> if (!pubAssertion.getTmodelKey().equalsIgnoreCase(keyedRef.getTModelKey())</span> |
| <span class="pc bpc" id="L341" title="1 of 2 branches missed."> || !pubAssertion.getKeyName().equalsIgnoreCase(keyedRef.getKeyName())</span> |
| <span class="pc bpc" id="L342" title="1 of 2 branches missed."> || !pubAssertion.getKeyValue().equalsIgnoreCase(keyedRef.getKeyValue())) {</span> |
| <span class="nc" id="L343"> throw new AssertionNotFoundException(new ErrorMessage("errors.pubassertion.AssertionNotFound", entity.getFromKey() + ", " + entity.getToKey()));</span> |
| } |
| //JUDDI-908 |
| <span class="fc bfc" id="L346" title="All 2 branches covered."> if (!publisher.isOwner(pubAssertion.getBusinessEntityByToKey())</span> |
| <span class="pc bpc" id="L347" title="1 of 2 branches missed."> && !publisher.isOwner(pubAssertion.getBusinessEntityByFromKey())) {</span> |
| <span class="nc" id="L348"> throw new UserMismatchException(new ErrorMessage("errors.usermismatch.assertion"));</span> |
| } |
| |
| } |
| |
| <span class="fc" id="L353"> }</span> |
| <span class="fc" id="L354"> }</span> |
| |
| public void validateSaveBusiness(EntityManager em, SaveBusiness body, Configuration config, UddiEntityPublisher publisher) throws DispositionReportFaultMessage { |
| |
| <span class="pc bpc" id="L358" title="1 of 2 branches missed."> if (config == null) {</span> |
| try { |
| <span class="fc" id="L360"> config = AppConfig.getConfiguration();</span> |
| <span class="nc" id="L361"> } catch (ConfigurationException ce) {</span> |
| <span class="nc" id="L362"> log.error("Could not optain config. " + ce.getMessage(), ce);</span> |
| <span class="fc" id="L363"> }</span> |
| } |
| // No null input |
| <span class="pc bpc" id="L366" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L367"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L371"> List<org.uddi.api_v3.BusinessEntity> entityList = body.getBusinessEntity();</span> |
| <span class="pc bpc" id="L372" title="1 of 4 branches missed."> if (entityList == null || entityList.size() == 0) {</span> |
| <span class="fc" id="L373"> throw new ValueNotAllowedException(new ErrorMessage("errors.savebusiness.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L376" title="All 2 branches covered."> for (org.uddi.api_v3.BusinessEntity entity : entityList) {</span> |
| <span class="fc" id="L377"> validateBusinessEntity(em, entity, config, publisher);</span> |
| |
| <span class="fc" id="L379"> }</span> |
| <span class="fc" id="L380"> validateCheckedTModelsBE(entityList, config);</span> |
| <span class="fc" id="L381"> }</span> |
| |
| public void validateSaveBusinessMax(EntityManager em) throws DispositionReportFaultMessage { |
| |
| //Obtain the maxSettings for this publisher or get the defaults |
| <span class="fc" id="L386"> Publisher publisher = em.find(Publisher.class, getPublisher().getAuthorizedName());</span> |
| <span class="fc" id="L387"> Integer maxBusinesses = publisher.getMaxBusinesses();</span> |
| try { |
| <span class="pc bpc" id="L389" title="1 of 2 branches missed."> if (maxBusinesses == null) {</span> |
| <span class="nc bnc" id="L390" title="All 2 branches missed."> if (AppConfig.getConfiguration().containsKey(Property.JUDDI_MAX_BUSINESSES_PER_PUBLISHER)) {</span> |
| <span class="nc" id="L391"> maxBusinesses = AppConfig.getConfiguration().getInteger(Property.JUDDI_MAX_BUSINESSES_PER_PUBLISHER, -1);</span> |
| } else { |
| <span class="nc" id="L393"> maxBusinesses = -1;</span> |
| } |
| } |
| <span class="nc" id="L396"> } catch (ConfigurationException e) {</span> |
| <span class="nc" id="L397"> log.error(e.getMessage(), e);</span> |
| <span class="nc" id="L398"> maxBusinesses = -1; //in case the configuration is not available</span> |
| <span class="fc" id="L399"> }</span> |
| //if we have the maxBusinesses set for this publisher then we need to make sure we did not exceed it. |
| <span class="pc bpc" id="L401" title="1 of 2 branches missed."> if (maxBusinesses > 0) {</span> |
| //get the businesses owned by this publisher |
| <span class="fc" id="L403"> List<?> businessKeysFound = FindBusinessByPublisherQuery.select(em, null, publisher, null);</span> |
| <span class="pc bpc" id="L404" title="2 of 4 branches missed."> if (businessKeysFound != null && businessKeysFound.size() > maxBusinesses) {</span> |
| <span class="nc" id="L405"> throw new MaxEntitiesExceededException(new ErrorMessage("errors.save.maxBusinessesExceeded"));</span> |
| } |
| } |
| |
| <span class="fc" id="L409"> }</span> |
| |
| public void validateSaveService(EntityManager em, SaveService body, Configuration config, UddiEntityPublisher publisher) throws DispositionReportFaultMessage { |
| |
| <span class="pc bpc" id="L413" title="1 of 2 branches missed."> if (config == null) {</span> |
| try { |
| <span class="fc" id="L415"> config = AppConfig.getConfiguration();</span> |
| <span class="nc" id="L416"> } catch (ConfigurationException ce) {</span> |
| <span class="nc" id="L417"> log.error("Could not optain config. " + ce.getMessage(), ce);</span> |
| <span class="fc" id="L418"> }</span> |
| } |
| // No null input |
| <span class="pc bpc" id="L421" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L422"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L426"> List<org.uddi.api_v3.BusinessService> entityList = body.getBusinessService();</span> |
| <span class="pc bpc" id="L427" title="1 of 4 branches missed."> if (entityList == null || entityList.size() == 0) {</span> |
| <span class="fc" id="L428"> throw new ValueNotAllowedException(new ErrorMessage("errors.saveservice.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L431" title="All 2 branches covered."> for (org.uddi.api_v3.BusinessService entity : entityList) {</span> |
| // Entity specific data validation |
| <span class="fc" id="L433"> validateBusinessService(em, entity, null, config, publisher);</span> |
| |
| <span class="fc" id="L435"> }</span> |
| <span class="fc" id="L436"> validateCheckedTModelsBS(entityList, config);</span> |
| <span class="fc" id="L437"> }</span> |
| |
| public void validateSaveServiceMax(EntityManager em, String businessKey) throws DispositionReportFaultMessage { |
| |
| //Obtain the maxSettings for this publisher or get the defaults |
| <span class="fc" id="L442"> Publisher publisher = em.find(Publisher.class, getPublisher().getAuthorizedName());</span> |
| <span class="fc" id="L443"> Integer maxServices = publisher.getMaxBusinesses();</span> |
| try { |
| <span class="pc bpc" id="L445" title="1 of 2 branches missed."> if (maxServices == null) {</span> |
| <span class="nc bnc" id="L446" title="All 2 branches missed."> if (AppConfig.getConfiguration().containsKey(Property.JUDDI_MAX_SERVICES_PER_BUSINESS)) {</span> |
| <span class="nc" id="L447"> maxServices = AppConfig.getConfiguration().getInteger(Property.JUDDI_MAX_SERVICES_PER_BUSINESS, -1);</span> |
| } else { |
| <span class="nc" id="L449"> maxServices = -1;</span> |
| } |
| } |
| <span class="nc" id="L452"> } catch (ConfigurationException e) {</span> |
| <span class="nc" id="L453"> log.error(e.getMessage(), e);</span> |
| <span class="nc" id="L454"> maxServices = -1; //incase the configuration isn't available</span> |
| <span class="fc" id="L455"> }</span> |
| //if we have the maxServices set for a business then we need to make sure we did not exceed it. |
| <span class="pc bpc" id="L457" title="1 of 2 branches missed."> if (maxServices > 0) {</span> |
| //get the businesses owned by this publisher |
| <span class="fc" id="L459"> org.apache.juddi.model.BusinessEntity modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class, businessKey);</span> |
| <span class="pc bpc" id="L460" title="2 of 4 branches missed."> if (modelBusinessEntity.getBusinessServices() != null && modelBusinessEntity.getBusinessServices().size() > maxServices) {</span> |
| <span class="nc" id="L461"> throw new MaxEntitiesExceededException(new ErrorMessage("errors.save.maxServicesExceeded"));</span> |
| } |
| } |
| <span class="fc" id="L464"> }</span> |
| |
| public void validateSaveBinding(EntityManager em, SaveBinding body, Configuration config, UddiEntityPublisher publisher) throws DispositionReportFaultMessage { |
| |
| <span class="pc bpc" id="L468" title="1 of 2 branches missed."> if (config == null) {</span> |
| try { |
| <span class="fc" id="L470"> config = AppConfig.getConfiguration();</span> |
| <span class="nc" id="L471"> } catch (ConfigurationException ce) {</span> |
| <span class="nc" id="L472"> log.error("Could not optain config. " + ce.getMessage(), ce);</span> |
| <span class="fc" id="L473"> }</span> |
| } |
| // No null input |
| <span class="pc bpc" id="L476" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L477"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L481"> List<org.uddi.api_v3.BindingTemplate> entityList = body.getBindingTemplate();</span> |
| <span class="pc bpc" id="L482" title="1 of 4 branches missed."> if (entityList == null || entityList.size() == 0) {</span> |
| <span class="fc" id="L483"> throw new ValueNotAllowedException(new ErrorMessage("errors.savebinding.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L486" title="All 2 branches covered."> for (org.uddi.api_v3.BindingTemplate entity : entityList) {</span> |
| <span class="fc" id="L487"> validateBindingTemplate(em, entity, null, config, publisher);</span> |
| |
| <span class="fc" id="L489"> }</span> |
| <span class="fc" id="L490"> validateCheckedTModelsBT(entityList, config);</span> |
| <span class="fc" id="L491"> }</span> |
| |
| public void validateSaveBindingMax(EntityManager em, String serviceKey) throws DispositionReportFaultMessage { |
| |
| //Obtain the maxSettings for this publisher or get the defaults |
| <span class="fc" id="L496"> Publisher publisher = em.find(Publisher.class, getPublisher().getAuthorizedName());</span> |
| <span class="fc" id="L497"> Integer maxBindings = publisher.getMaxBindingsPerService();</span> |
| try { |
| <span class="fc bfc" id="L499" title="All 2 branches covered."> if (maxBindings == null) {</span> |
| <span class="pc bpc" id="L500" title="1 of 2 branches missed."> if (AppConfig.getConfiguration().containsKey(Property.JUDDI_MAX_BINDINGS_PER_SERVICE)) {</span> |
| <span class="fc" id="L501"> maxBindings = AppConfig.getConfiguration().getInteger(Property.JUDDI_MAX_BINDINGS_PER_SERVICE, -1);</span> |
| } else { |
| <span class="nc" id="L503"> maxBindings = -1;</span> |
| } |
| } |
| <span class="nc" id="L506"> } catch (ConfigurationException e) {</span> |
| <span class="nc" id="L507"> log.error(e.getMessage(), e);</span> |
| <span class="nc" id="L508"> maxBindings = -1; //incase the config isn't available</span> |
| <span class="fc" id="L509"> }</span> |
| //if we have the maxBindings set for a service then we need to make sure we did not exceed it. |
| <span class="pc bpc" id="L511" title="1 of 2 branches missed."> if (maxBindings > 0) {</span> |
| //get the bindings owned by this service |
| <span class="fc" id="L513"> org.apache.juddi.model.BusinessService modelBusinessService = em.find(org.apache.juddi.model.BusinessService.class, serviceKey);</span> |
| <span class="pc bpc" id="L514" title="2 of 4 branches missed."> if (modelBusinessService.getBindingTemplates() != null && modelBusinessService.getBindingTemplates().size() > maxBindings) {</span> |
| <span class="nc" id="L515"> throw new MaxEntitiesExceededException(new ErrorMessage("errors.save.maxBindingsExceeded"));</span> |
| } |
| } |
| <span class="fc" id="L518"> }</span> |
| |
| public void validateSaveTModel(EntityManager em, SaveTModel body, Configuration config, UddiEntityPublisher publisher) throws DispositionReportFaultMessage { |
| |
| <span class="pc bpc" id="L522" title="1 of 2 branches missed."> if (config == null) {</span> |
| try { |
| <span class="fc" id="L524"> config = AppConfig.getConfiguration();</span> |
| <span class="nc" id="L525"> } catch (ConfigurationException ce) {</span> |
| <span class="nc" id="L526"> log.error("Could not optain config. " + ce.getMessage(), ce);</span> |
| <span class="fc" id="L527"> }</span> |
| } |
| // No null input |
| <span class="pc bpc" id="L530" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L531"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L535"> List<org.uddi.api_v3.TModel> entityList = body.getTModel();</span> |
| <span class="pc bpc" id="L536" title="2 of 4 branches missed."> if (entityList == null || entityList.size() == 0) {</span> |
| <span class="nc" id="L537"> throw new ValueNotAllowedException(new ErrorMessage("errors.savetmodel.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L540" title="All 2 branches covered."> for (org.uddi.api_v3.TModel entity : entityList) {</span> |
| <span class="fc" id="L541"> validateTModel(em, entity, config, publisher);</span> |
| |
| <span class="fc" id="L543"> }</span> |
| <span class="fc" id="L544"> validateCheckedTModelsTM(entityList, config);</span> |
| <span class="fc" id="L545"> }</span> |
| |
| public void validateSaveTModelMax(EntityManager em) throws DispositionReportFaultMessage { |
| |
| //Obtain the maxSettings for this publisher or get the defaults |
| <span class="nc" id="L550"> Publisher publisher = em.find(Publisher.class, getPublisher().getAuthorizedName());</span> |
| <span class="nc" id="L551"> Integer maxTModels = publisher.getMaxTmodels();</span> |
| try { |
| <span class="nc bnc" id="L553" title="All 2 branches missed."> if (maxTModels == null) {</span> |
| <span class="nc bnc" id="L554" title="All 2 branches missed."> if (AppConfig.getConfiguration().containsKey(Property.JUDDI_MAX_TMODELS_PER_PUBLISHER)) {</span> |
| <span class="nc" id="L555"> maxTModels = AppConfig.getConfiguration().getInteger(Property.JUDDI_MAX_TMODELS_PER_PUBLISHER, -1);</span> |
| } else { |
| <span class="nc" id="L557"> maxTModels = -1;</span> |
| } |
| } |
| <span class="nc" id="L560"> } catch (ConfigurationException e) {</span> |
| <span class="nc" id="L561"> log.error(e.getMessage(), e);</span> |
| <span class="nc" id="L562"> maxTModels = -1; //incase the config isn't available</span> |
| <span class="nc" id="L563"> }</span> |
| //if we have the TModels set for a publisher then we need to make sure we did not exceed it. |
| <span class="nc bnc" id="L565" title="All 2 branches missed."> if (maxTModels > 0) {</span> |
| //get the tmodels owned by this publisher |
| <span class="nc" id="L567"> List<?> tmodelKeysFound = FindTModelByPublisherQuery.select(em, null, publisher, null);</span> |
| <span class="nc bnc" id="L568" title="All 4 branches missed."> if (tmodelKeysFound != null && tmodelKeysFound.size() > maxTModels) {</span> |
| <span class="nc" id="L569"> throw new MaxEntitiesExceededException(new ErrorMessage("errors.save.maxTModelsExceeded"));</span> |
| } |
| } |
| <span class="nc" id="L572"> }</span> |
| |
| public void validateAddPublisherAssertions(EntityManager em, AddPublisherAssertions body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L577" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L578"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L582"> List<org.uddi.api_v3.PublisherAssertion> entityList = body.getPublisherAssertion();</span> |
| <span class="pc bpc" id="L583" title="2 of 4 branches missed."> if (entityList == null || entityList.size() == 0) {</span> |
| <span class="nc" id="L584"> throw new ValueNotAllowedException(new ErrorMessage("errors.addpublisherassertions.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L587" title="All 2 branches covered."> for (org.uddi.api_v3.PublisherAssertion entity : entityList) {</span> |
| <span class="fc" id="L588"> validatePublisherAssertion(em, entity);</span> |
| <span class="fc" id="L589"> }</span> |
| <span class="fc" id="L590"> }</span> |
| |
| public void validateSetPublisherAssertions(EntityManager em, Holder<List<org.uddi.api_v3.PublisherAssertion>> body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L595" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L596"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // Assertion list can be null or empty - it signifies that publisher is deleting all their assertions |
| <span class="fc" id="L600"> List<org.uddi.api_v3.PublisherAssertion> entityList = body.value;</span> |
| <span class="pc bpc" id="L601" title="1 of 4 branches missed."> if (entityList != null && entityList.size() > 0) {</span> |
| |
| <span class="fc bfc" id="L603" title="All 2 branches covered."> for (org.uddi.api_v3.PublisherAssertion entity : entityList) {</span> |
| <span class="fc" id="L604"> validatePublisherAssertion(em, entity);</span> |
| <span class="fc" id="L605"> }</span> |
| } |
| <span class="fc" id="L607"> }</span> |
| |
| void validateNotSigned(org.uddi.api_v3.BusinessEntity item) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L610" title="1 of 2 branches missed."> if (item == null) {</span> |
| <span class="nc" id="L611"> return;</span> |
| } |
| <span class="fc bfc" id="L613" title="All 4 branches covered."> if (item.getBusinessKey() == null && !item.getSignature().isEmpty()) {</span> |
| <span class="fc" id="L614"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "businessKey"));</span> |
| } |
| <span class="fc bfc" id="L616" title="All 4 branches covered."> if (item.getBusinessServices() != null && !item.getSignature().isEmpty()) {</span> |
| <span class="fc bfc" id="L617" title="All 2 branches covered."> for (int i = 0; i < item.getBusinessServices().getBusinessService().size(); i++) {</span> |
| <span class="fc bfc" id="L618" title="All 2 branches covered."> if (item.getBusinessServices().getBusinessService().get(i).getBusinessKey() == null</span> |
| <span class="pc bpc" id="L619" title="1 of 2 branches missed."> || item.getBusinessServices().getBusinessService().get(i).getBusinessKey().length() == 0) {</span> |
| <span class="fc" id="L620"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "business/Service(" + i + ")/businessKey"));</span> |
| } |
| <span class="fc bfc" id="L622" title="All 2 branches covered."> if (item.getBusinessServices().getBusinessService().get(i).getServiceKey() == null</span> |
| <span class="pc bpc" id="L623" title="1 of 2 branches missed."> || item.getBusinessServices().getBusinessService().get(i).getServiceKey().length() == 0) {</span> |
| <span class="fc" id="L624"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "business/Service(" + i + ")/serviceKey"));</span> |
| } |
| <span class="pc bpc" id="L626" title="1 of 2 branches missed."> if (item.getBusinessServices().getBusinessService().get(i).getBindingTemplates() != null) {</span> |
| <span class="fc bfc" id="L627" title="All 2 branches covered."> for (int k = 0; k < item.getBusinessServices().getBusinessService().get(i).getBindingTemplates().getBindingTemplate().size(); k++) {</span> |
| <span class="pc bpc" id="L628" title="1 of 2 branches missed."> if (item.getBusinessServices().getBusinessService().get(i).getBindingTemplates().getBindingTemplate().get(k).getBindingKey() == null</span> |
| <span class="pc bpc" id="L629" title="1 of 2 branches missed."> || item.getBusinessServices().getBusinessService().get(i).getBindingTemplates().getBindingTemplate().get(k).getBindingKey().length() == 0) {</span> |
| <span class="nc" id="L630"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "business/Service(" + i + ")/bindingTemplate)" + k + ")/bindingKey"));</span> |
| } |
| } |
| } |
| } |
| } |
| <span class="fc" id="L636"> }</span> |
| |
| void validateNotSigned(org.uddi.api_v3.BindingTemplate item) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L639" title="1 of 2 branches missed."> if (item == null) {</span> |
| <span class="nc" id="L640"> return;</span> |
| } |
| <span class="pc bpc" id="L642" title="1 of 4 branches missed."> if (item.getBindingKey() == null && !item.getSignature().isEmpty()) {</span> |
| <span class="fc" id="L643"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "bindingKey"));</span> |
| } |
| <span class="pc bpc" id="L645" title="1 of 4 branches missed."> if (item.getServiceKey() == null && !item.getSignature().isEmpty()) {</span> |
| <span class="nc" id="L646"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "serviceKey"));</span> |
| } |
| <span class="fc" id="L648"> }</span> |
| |
| void validateNotSigned(org.uddi.api_v3.TModel item) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L651" title="1 of 2 branches missed."> if (item == null) {</span> |
| <span class="nc" id="L652"> return;</span> |
| } |
| <span class="pc bpc" id="L654" title="1 of 4 branches missed."> if (item.getTModelKey() == null && !item.getSignature().isEmpty()) {</span> |
| <span class="fc" id="L655"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "tModelKey"));</span> |
| } |
| <span class="fc" id="L657"> }</span> |
| |
| void validateNotSigned(org.uddi.api_v3.BusinessService item) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L660" title="1 of 2 branches missed."> if (item == null) {</span> |
| <span class="nc" id="L661"> return;</span> |
| } |
| <span class="fc bfc" id="L663" title="All 4 branches covered."> if (item.getBusinessKey() == null && !item.getSignature().isEmpty()) {</span> |
| <span class="fc" id="L664"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "businessKey"));</span> |
| } |
| <span class="fc bfc" id="L666" title="All 4 branches covered."> if (item.getServiceKey() == null && !item.getSignature().isEmpty()) {</span> |
| <span class="fc" id="L667"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "serviceKey"));</span> |
| } |
| //if i'm signed and a key isn't defined in a bt |
| <span class="pc bpc" id="L670" title="1 of 4 branches missed."> if (item.getBindingTemplates() != null && !item.getSignature().isEmpty()) {</span> |
| <span class="nc bnc" id="L671" title="All 2 branches missed."> for (int i = 0; i < item.getBindingTemplates().getBindingTemplate().size(); i++) {</span> |
| <span class="nc bnc" id="L672" title="All 2 branches missed."> if (item.getBindingTemplates().getBindingTemplate().get(i).getBindingKey() == null</span> |
| <span class="nc bnc" id="L673" title="All 2 branches missed."> || item.getBindingTemplates().getBindingTemplate().get(i).getBindingKey().length() == 0) {</span> |
| <span class="nc" id="L674"> throw new ValueNotAllowedException(new ErrorMessage("errors.entity.SignedButNoKey", "businessService/bindingTemplate(" + i + ")/bindingKey"));</span> |
| } |
| } |
| } |
| <span class="fc" id="L678"> }</span> |
| |
| public void validateBusinessEntity(EntityManager em, org.uddi.api_v3.BusinessEntity businessEntity, |
| Configuration config, UddiEntityPublisher publisher) throws DispositionReportFaultMessage { |
| |
| // A supplied businessEntity can't be null |
| <span class="pc bpc" id="L684" title="1 of 2 branches missed."> if (businessEntity == null) {</span> |
| <span class="nc" id="L685"> throw new ValueNotAllowedException(new ErrorMessage("errors.businessentity.NullInput"));</span> |
| } |
| |
| <span class="fc" id="L688"> boolean entityExists = false;</span> |
| <span class="fc" id="L689"> validateNotSigned(businessEntity);</span> |
| <span class="fc" id="L690"> String entityKey = businessEntity.getBusinessKey();</span> |
| <span class="pc bpc" id="L691" title="1 of 4 branches missed."> if (entityKey == null || entityKey.length() == 0) {</span> |
| <span class="fc" id="L692"> KeyGenerator keyGen = KeyGeneratorFactory.getKeyGenerator();</span> |
| <span class="fc" id="L693"> entityKey = keyGen.generate(publisher);</span> |
| <span class="fc" id="L694"> businessEntity.setBusinessKey(entityKey);</span> |
| <span class="fc" id="L695"> } else {</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L697"> entityKey = entityKey.toLowerCase();</span> |
| <span class="fc" id="L698"> businessEntity.setBusinessKey(entityKey);</span> |
| <span class="fc" id="L699"> validateKeyLength(entityKey);</span> |
| <span class="fc" id="L700"> Object obj = em.find(org.apache.juddi.model.BusinessEntity.class, entityKey);</span> |
| <span class="fc bfc" id="L701" title="All 2 branches covered."> if (obj != null) {</span> |
| <span class="fc" id="L702"> entityExists = true;</span> |
| |
| // Make sure publisher owns this entity. |
| <span class="fc" id="L705"> AccessCheck(obj, entityKey);</span> |
| |
| } else { |
| // Inside this block, we have a key proposed by the publisher on a new entity |
| |
| // Validate key and then check to see that the proposed key is valid for this publisher |
| <span class="fc" id="L711"> ValidateUDDIKey.validateUDDIv3Key(entityKey);</span> |
| <span class="pc bpc" id="L712" title="1 of 2 branches missed."> if (!publisher.isValidPublisherKey(em, entityKey)) {</span> |
| <span class="nc" id="L713"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.BadPartition", entityKey));</span> |
| } |
| |
| } |
| } |
| |
| <span class="fc bfc" id="L719" title="All 2 branches covered."> if (!entityExists) {</span> |
| // Check to make sure key isn't used by another entity. |
| <span class="pc bpc" id="L721" title="1 of 2 branches missed."> if (!isUniqueKey(em, entityKey)) {</span> |
| <span class="nc" id="L722"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.KeyExists", entityKey));</span> |
| } |
| } |
| |
| // was TODO: validate "checked" categories or category groups (see section 5.2.3 of spec)? optional to support |
| //covered by ref integrity checks |
| <span class="fc" id="L728"> validateNames(businessEntity.getName());</span> |
| <span class="fc" id="L729"> validateDiscoveryUrls(businessEntity.getDiscoveryURLs());</span> |
| <span class="fc" id="L730"> validateContacts(businessEntity.getContacts(), config);</span> |
| <span class="fc" id="L731"> validateCategoryBag(businessEntity.getCategoryBag(), config, false);</span> |
| <span class="fc" id="L732"> validateIdentifierBag(businessEntity.getIdentifierBag(), config, false);</span> |
| <span class="fc" id="L733"> validateDescriptions(businessEntity.getDescription());</span> |
| <span class="fc" id="L734"> validateBusinessServices(em, businessEntity.getBusinessServices(), businessEntity, config, publisher);</span> |
| <span class="fc" id="L735"> validateSignaturesBusiness(businessEntity, config);</span> |
| |
| <span class="fc" id="L737"> }</span> |
| |
| public void validateBusinessServices(EntityManager em, org.uddi.api_v3.BusinessServices businessServices, |
| org.uddi.api_v3.BusinessEntity parent, Configuration config, UddiEntityPublisher publisher) |
| throws DispositionReportFaultMessage { |
| // Business services is optional |
| <span class="fc bfc" id="L743" title="All 2 branches covered."> if (businessServices == null) {</span> |
| <span class="fc" id="L744"> return;</span> |
| } |
| <span class="fc" id="L746"> List<org.uddi.api_v3.BusinessService> businessServiceList = businessServices.getBusinessService();</span> |
| <span class="pc bpc" id="L747" title="2 of 4 branches missed."> if (businessServiceList == null || businessServiceList.size() == 0) {</span> |
| <span class="nc" id="L748"> throw new ValueNotAllowedException(new ErrorMessage("errors.businessservices.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L751" title="All 2 branches covered."> for (org.uddi.api_v3.BusinessService businessService : businessServiceList) {</span> |
| <span class="fc" id="L752"> validateBusinessService(em, businessService, parent, config, publisher);</span> |
| <span class="fc" id="L753"> }</span> |
| |
| <span class="fc" id="L755"> }</span> |
| |
| public void validateBusinessService(EntityManager em, org.uddi.api_v3.BusinessService businessService, |
| org.uddi.api_v3.BusinessEntity parent, Configuration config, UddiEntityPublisher publisher) |
| throws DispositionReportFaultMessage { |
| |
| // A supplied businessService can't be null |
| <span class="pc bpc" id="L762" title="1 of 2 branches missed."> if (businessService == null) {</span> |
| <span class="nc" id="L763"> throw new ValueNotAllowedException(new ErrorMessage("errors.businessservice.NullInput"));</span> |
| } |
| |
| <span class="fc" id="L766"> validateNotSigned(businessService);</span> |
| // Retrieve the service's passed key |
| <span class="fc" id="L768"> String entityKey = businessService.getServiceKey();</span> |
| <span class="pc bpc" id="L769" title="1 of 4 branches missed."> if (entityKey != null && entityKey.length() > 0) {</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L771"> entityKey = entityKey.toLowerCase();</span> |
| <span class="fc" id="L772"> validateKeyLength(entityKey);</span> |
| <span class="fc" id="L773"> businessService.setServiceKey(entityKey);</span> |
| } |
| |
| // The parent key is either supplied or provided by the higher call to the parent entity save. If the passed-in parent's business key differs from |
| // the (non-null) business key retrieved from the service, then we have a possible service projection. |
| <span class="fc" id="L778"> String parentKey = businessService.getBusinessKey();</span> |
| <span class="pc bpc" id="L779" title="1 of 4 branches missed."> if (parentKey != null && parentKey.length() > 0) {</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L781"> parentKey = parentKey.toLowerCase();</span> |
| <span class="fc" id="L782"> businessService.setBusinessKey(parentKey);</span> |
| } |
| |
| <span class="fc" id="L785"> boolean isProjection = false;</span> |
| <span class="fc bfc" id="L786" title="All 2 branches covered."> if (parent != null) {</span> |
| <span class="pc bpc" id="L787" title="1 of 4 branches missed."> if (parentKey != null && parentKey.length() > 0) {</span> |
| <span class="fc bfc" id="L788" title="All 2 branches covered."> if (!parentKey.equalsIgnoreCase(parent.getBusinessKey())) {</span> |
| // Possible projected service - if we have differing parent businesses but a service key was not provided, this is an error as it is not possible |
| // for the business that doesn't "own" the service to generate the key for it. |
| <span class="pc bpc" id="L791" title="2 of 4 branches missed."> if (entityKey == null || entityKey.length() == 0) {</span> |
| <span class="nc" id="L792"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceKeyNotProvidedWithProjection", parentKey + ", " + parent.getBusinessKey()));</span> |
| } |
| |
| <span class="fc" id="L795"> isProjection = true;</span> |
| } |
| } else { |
| <span class="fc" id="L798"> parentKey = parent.getBusinessKey();</span> |
| } |
| } |
| |
| // Projections don't require as rigorous testing as only the projected service's business key and service key are examined for validity. |
| <span class="fc bfc" id="L803" title="All 2 branches covered."> if (isProjection) {</span> |
| |
| <span class="fc" id="L805"> Object obj = em.find(org.apache.juddi.model.BusinessService.class, entityKey);</span> |
| // Can't project a service that doesn't exist! |
| <span class="pc bpc" id="L807" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L808"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ProjectedServiceNotFound", parentKey + ", " + entityKey));</span> |
| } else { |
| // If the supplied business key doesn't match the existing service's business key, the projection is invalid. |
| <span class="fc" id="L811"> org.apache.juddi.model.BusinessService bs = (org.apache.juddi.model.BusinessService) obj;</span> |
| <span class="pc bpc" id="L812" title="1 of 2 branches missed."> if (!businessService.getBusinessKey().equalsIgnoreCase(bs.getBusinessEntity().getEntityKey())) {</span> |
| <span class="nc" id="L813"> throw new InvalidProjectionException(new ErrorMessage("errors.invalidprojection.ParentMismatch", businessService.getBusinessKey() + ", " + bs.getBusinessEntity().getEntityKey()));</span> |
| } |
| } |
| <span class="fc" id="L816"> obj = null;</span> |
| <span class="fc" id="L817"> } else {</span> |
| <span class="fc" id="L818"> boolean entityExists = false;</span> |
| <span class="pc bpc" id="L819" title="1 of 4 branches missed."> if (entityKey == null || entityKey.length() == 0) {</span> |
| <span class="fc" id="L820"> KeyGenerator keyGen = KeyGeneratorFactory.getKeyGenerator();</span> |
| <span class="fc" id="L821"> entityKey = keyGen.generate(publisher);</span> |
| <span class="fc" id="L822"> businessService.setServiceKey(entityKey);</span> |
| <span class="fc" id="L823"> } else {</span> |
| |
| <span class="fc" id="L825"> Object obj = em.find(org.apache.juddi.model.BusinessService.class, entityKey);</span> |
| <span class="fc bfc" id="L826" title="All 2 branches covered."> if (obj != null) {</span> |
| <span class="fc" id="L827"> entityExists = true;</span> |
| |
| <span class="fc" id="L829"> org.apache.juddi.model.BusinessService bs = (org.apache.juddi.model.BusinessService) obj;</span> |
| |
| // If the object exists, and the parentKey was not found to this point, then a save on an existing service with a blank |
| // business key has occurred. It is set here and added to the entity being saved - a necessary step for the object to be |
| // persisted properly. (This condition makes some validation tests below unnecessary as the parent is "verified" but it's OK to |
| // still run them). |
| <span class="pc bpc" id="L835" title="2 of 4 branches missed."> if (parentKey == null || parentKey.length() == 0) {</span> |
| <span class="nc" id="L836"> parentKey = bs.getBusinessEntity().getEntityKey();</span> |
| <span class="nc" id="L837"> businessService.setBusinessKey(parentKey);</span> |
| } |
| |
| // Make sure publisher owns this entity. |
| <span class="fc" id="L841"> AccessCheck(obj, entityKey);</span> |
| |
| // If existing service trying to be saved has a different parent key, then we have a problem |
| <span class="fc bfc" id="L844" title="All 2 branches covered."> if (!parentKey.equalsIgnoreCase(bs.getBusinessEntity().getEntityKey())) {</span> |
| // if both businesses are owned by this publisher then we allow it. |
| // we already check the current business is owned, lets see if the old one is too |
| <span class="pc bpc" id="L847" title="1 of 2 branches missed."> if (!publisher.isOwner(bs.getBusinessEntity())) {</span> |
| <span class="nc" id="L848"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.businessservice.ParentMismatch", parentKey + ", " + bs.getBusinessEntity().getEntityKey()));</span> |
| } else { |
| <span class="pc bpc" id="L850" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L851"> log.debug("Services moved from business " + bs.getBusinessEntity() + " to " + businessService.getBusinessKey());</span> |
| } |
| } |
| } |
| |
| <span class="fc" id="L856"> } else {</span> |
| // Inside this block, we have a key proposed by the publisher on a new entity |
| |
| // Validate key and then check to see that the proposed key is valid for this publisher |
| <span class="fc" id="L860"> ValidateUDDIKey.validateUDDIv3Key(entityKey);</span> |
| <span class="pc bpc" id="L861" title="1 of 2 branches missed."> if (!publisher.isValidPublisherKey(em, entityKey)) {</span> |
| <span class="nc" id="L862"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.BadPartition", entityKey));</span> |
| } |
| |
| } |
| |
| } |
| |
| // Parent key must be passed if this is a new entity |
| <span class="fc bfc" id="L870" title="All 2 branches covered."> if (!entityExists) {</span> |
| <span class="pc bpc" id="L871" title="2 of 4 branches missed."> if (parentKey == null || parentKey.length() == 0) {</span> |
| <span class="nc" id="L872"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ParentBusinessNotFound", parentKey));</span> |
| } |
| } |
| |
| // If parent key IS passed, whether new entity or not, it must be valid. Additionally, the current publisher must be the owner of the parent. Note that |
| // if a parent ENTITY was passed in, then we don't need to check for any of this since this is part of a higher call. |
| <span class="pc bpc" id="L878" title="1 of 2 branches missed."> if (parentKey != null) {</span> |
| <span class="fc bfc" id="L879" title="All 2 branches covered."> if (parent == null) {</span> |
| <span class="fc" id="L880"> Object parentTemp = em.find(org.apache.juddi.model.BusinessEntity.class, parentKey);</span> |
| <span class="pc bpc" id="L881" title="1 of 2 branches missed."> if (parentTemp == null) {</span> |
| <span class="nc" id="L882"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ParentBusinessNotFound", parentKey));</span> |
| } |
| |
| // Make sure publisher owns this parent entity. |
| <span class="fc" id="L886"> AccessCheck(parentTemp, parentKey);</span> |
| // if (!publisher.isOwner((UddiEntity) parentTemp)) { |
| // throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwnerParent", parentKey)); |
| //} |
| } |
| } |
| |
| <span class="fc bfc" id="L893" title="All 2 branches covered."> if (!entityExists) {</span> |
| // Check to make sure key isn't used by another entity. |
| <span class="pc bpc" id="L895" title="1 of 2 branches missed."> if (!isUniqueKey(em, entityKey)) {</span> |
| <span class="nc" id="L896"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.KeyExists", entityKey));</span> |
| } |
| } |
| |
| // TODO: validate "checked" categories or category groups (see section 5.2.3 of spec)? optional to support |
| <span class="fc" id="L901"> validateNames(businessService.getName());</span> |
| <span class="fc" id="L902"> validateCategoryBag(businessService.getCategoryBag(), config, false);</span> |
| <span class="fc" id="L903"> validateDescriptions(businessService.getDescription());</span> |
| <span class="fc" id="L904"> validateBindingTemplates(em, businessService.getBindingTemplates(), businessService, config, publisher);</span> |
| <span class="fc" id="L905"> validateSignaturesService(businessService, config);</span> |
| } |
| |
| <span class="fc" id="L908"> }</span> |
| |
| public void validateBindingTemplates(EntityManager em, org.uddi.api_v3.BindingTemplates bindingTemplates, |
| org.uddi.api_v3.BusinessService parent, Configuration config, UddiEntityPublisher publisher) |
| throws DispositionReportFaultMessage { |
| // Binding templates is optional |
| <span class="fc bfc" id="L914" title="All 2 branches covered."> if (bindingTemplates == null) {</span> |
| <span class="fc" id="L915"> return;</span> |
| } |
| |
| <span class="fc" id="L918"> List<org.uddi.api_v3.BindingTemplate> bindingTemplateList = bindingTemplates.getBindingTemplate();</span> |
| <span class="pc bpc" id="L919" title="2 of 4 branches missed."> if (bindingTemplateList == null || bindingTemplateList.size() == 0) {</span> |
| <span class="nc" id="L920"> throw new ValueNotAllowedException(new ErrorMessage("errors.bindingtemplates.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L923" title="All 2 branches covered."> for (org.uddi.api_v3.BindingTemplate bindingTemplate : bindingTemplateList) {</span> |
| <span class="fc" id="L924"> validateBindingTemplate(em, bindingTemplate, parent, config, publisher);</span> |
| <span class="fc" id="L925"> }</span> |
| |
| <span class="fc" id="L927"> }</span> |
| |
| public void validateBindingTemplate(EntityManager em, org.uddi.api_v3.BindingTemplate bindingTemplate, |
| org.uddi.api_v3.BusinessService parent, Configuration config, UddiEntityPublisher publisher) |
| throws DispositionReportFaultMessage { |
| |
| // A supplied bindingTemplate can't be null |
| <span class="pc bpc" id="L934" title="1 of 2 branches missed."> if (bindingTemplate == null) {</span> |
| <span class="nc" id="L935"> throw new ValueNotAllowedException(new ErrorMessage("errors.bindingtemplate.NullInput"));</span> |
| } |
| |
| // Retrieve the binding's passed key |
| <span class="fc" id="L939"> String entityKey = bindingTemplate.getBindingKey();</span> |
| <span class="pc bpc" id="L940" title="1 of 4 branches missed."> if (entityKey != null && entityKey.length() > 0) {</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L942"> entityKey = entityKey.toLowerCase();</span> |
| <span class="fc" id="L943"> bindingTemplate.setBindingKey(entityKey);</span> |
| <span class="fc" id="L944"> validateKeyLength(entityKey);</span> |
| } |
| |
| // The parent key is either supplied or provided by the higher call to the parent entity save. If it is provided in both instances, if they differ, an |
| // error occurs. |
| <span class="fc" id="L949"> String parentKey = bindingTemplate.getServiceKey();</span> |
| <span class="pc bpc" id="L950" title="1 of 4 branches missed."> if (parentKey != null && parentKey.length() > 0) {</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L952"> parentKey = parentKey.toLowerCase();</span> |
| <span class="fc" id="L953"> bindingTemplate.setServiceKey(parentKey);</span> |
| } |
| |
| <span class="fc bfc" id="L956" title="All 2 branches covered."> if (parent != null) {</span> |
| <span class="pc bpc" id="L957" title="1 of 4 branches missed."> if (parentKey != null && parentKey.length() > 0) {</span> |
| <span class="pc bpc" id="L958" title="1 of 2 branches missed."> if (!parentKey.equalsIgnoreCase(parent.getServiceKey())) {</span> |
| <span class="nc" id="L959"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.bindingtemplate.ParentMismatch", parentKey + ", " + parent.getBusinessKey()));</span> |
| } |
| } else { |
| <span class="fc" id="L962"> parentKey = parent.getServiceKey();</span> |
| } |
| } |
| |
| <span class="fc" id="L966"> boolean entityExists = false;</span> |
| <span class="pc bpc" id="L967" title="1 of 4 branches missed."> if (entityKey == null || entityKey.length() == 0) {</span> |
| <span class="fc" id="L968"> validateNotSigned(bindingTemplate);</span> |
| <span class="fc" id="L969"> KeyGenerator keyGen = KeyGeneratorFactory.getKeyGenerator();</span> |
| <span class="fc" id="L970"> entityKey = keyGen.generate(publisher);</span> |
| <span class="fc" id="L971"> bindingTemplate.setBindingKey(entityKey);</span> |
| <span class="fc" id="L972"> } else {</span> |
| |
| <span class="fc" id="L974"> Object obj = em.find(org.apache.juddi.model.BindingTemplate.class, entityKey);</span> |
| <span class="fc bfc" id="L975" title="All 2 branches covered."> if (obj != null) {</span> |
| <span class="fc" id="L976"> entityExists = true;</span> |
| |
| <span class="fc" id="L978"> org.apache.juddi.model.BindingTemplate bt = (org.apache.juddi.model.BindingTemplate) obj;</span> |
| |
| // If the object exists, and the parentKey was not found to this point, then a save on an existing binding with a blank |
| // service key has occurred. It is set here and added to the entity being saved - a necessary step for the object to be |
| // persisted properly. (This condition makes some validation tests below unnecessary as the parent is "verified" but it's OK to |
| // still run them). |
| <span class="pc bpc" id="L984" title="2 of 4 branches missed."> if (parentKey == null || parentKey.length() == 0) {</span> |
| <span class="nc" id="L985"> parentKey = bt.getBusinessService().getEntityKey();</span> |
| <span class="nc" id="L986"> bindingTemplate.setServiceKey(parentKey);</span> |
| } |
| |
| // If existing binding trying to be saved has a different parent key, then we have a problem |
| // TODO: moving bindings is allowed according to spec? |
| <span class="pc bpc" id="L991" title="1 of 2 branches missed."> if (!parentKey.equalsIgnoreCase(bt.getBusinessService().getEntityKey())) {</span> |
| <span class="nc" id="L992"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.bindingtemplate.ParentMismatch", parentKey + ", " + bt.getBusinessService().getEntityKey()));</span> |
| } |
| |
| // Make sure publisher owns this entity. |
| <span class="fc" id="L996"> AccessCheck(obj, entityKey);</span> |
| //if (!publisher.isOwner((UddiEntity) obj)&& !((Publisher) publisher).isAdmin()) { |
| // throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey)); |
| // } |
| |
| <span class="fc" id="L1001"> } else {</span> |
| // Inside this block, we have a key proposed by the publisher on a new entity |
| |
| // Validate key and then check to see that the proposed key is valid for this publisher |
| <span class="fc" id="L1005"> ValidateUDDIKey.validateUDDIv3Key(entityKey);</span> |
| <span class="pc bpc" id="L1006" title="1 of 2 branches missed."> if (!publisher.isValidPublisherKey(em, entityKey)) {</span> |
| <span class="nc" id="L1007"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.BadPartition", entityKey));</span> |
| } |
| |
| } |
| |
| } |
| |
| // Parent key must be passed if this is a new entity |
| <span class="fc bfc" id="L1015" title="All 2 branches covered."> if (!entityExists) {</span> |
| <span class="pc bpc" id="L1016" title="2 of 4 branches missed."> if (parentKey == null || parentKey.length() == 0) {</span> |
| <span class="nc" id="L1017"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ParentServiceNotFound", parentKey));</span> |
| } |
| } |
| |
| // If parent key IS passed, whether new entity or not, it must be valid. Additionally, the current publisher must be the owner of the parent. Note that |
| // if a parent ENTITY was passed in, then we don't need to check for any of this since this is part of a higher call. |
| <span class="pc bpc" id="L1023" title="1 of 2 branches missed."> if (parentKey != null) {</span> |
| <span class="fc bfc" id="L1024" title="All 2 branches covered."> if (parent == null) {</span> |
| <span class="fc" id="L1025"> Object parentTemp = em.find(org.apache.juddi.model.BusinessService.class, parentKey);</span> |
| <span class="pc bpc" id="L1026" title="1 of 2 branches missed."> if (parentTemp == null) {</span> |
| <span class="nc" id="L1027"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ParentBusinessNotFound", parentKey));</span> |
| <span class="pc bpc" id="L1028" title="1 of 2 branches missed."> } else if (!(parentTemp instanceof org.apache.juddi.model.BusinessService)) {</span> |
| //JUDDI-848 |
| <span class="nc" id="L1030"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ParentBusinessNotFound", parentKey));</span> |
| } |
| |
| // Make sure publisher owns this parent entity. |
| <span class="fc" id="L1034"> AccessCheck(parentTemp, parentKey);</span> |
| // if (!publisher.isOwner((UddiEntity) parentTemp)) { |
| // throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwnerParent", parentKey)); |
| // } |
| |
| } |
| } |
| |
| <span class="fc bfc" id="L1042" title="All 2 branches covered."> if (!entityExists) {</span> |
| // Check to make sure key isn't used by another entity. |
| <span class="pc bpc" id="L1044" title="1 of 2 branches missed."> if (!isUniqueKey(em, entityKey)) {</span> |
| <span class="nc" id="L1045"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.KeyExists", entityKey));</span> |
| } |
| } |
| |
| //was TODO validate "checked" categories or category groups (see section 5.2.3 of spec)? optional to support |
| //at least one must be defined |
| <span class="fc bfc" id="L1051" title="All 4 branches covered."> if (bindingTemplate.getAccessPoint() == null && bindingTemplate.getHostingRedirector() == null) {</span> |
| <span class="fc" id="L1052"> throw new ValueNotAllowedException(new ErrorMessage("errors.bindingtemplate.NoAccessPoint"));</span> |
| } |
| //but not both |
| <span class="fc bfc" id="L1055" title="All 4 branches covered."> if (bindingTemplate.getAccessPoint() != null && bindingTemplate.getHostingRedirector() != null) {</span> |
| <span class="fc" id="L1056"> throw new ValueNotAllowedException(new ErrorMessage("errors.bindingtemplate.NoAccessPoint"));</span> |
| } |
| <span class="fc" id="L1058"> validateCategoryBag(bindingTemplate.getCategoryBag(), config, false);</span> |
| <span class="fc" id="L1059"> validateTModelInstanceDetails(bindingTemplate.getTModelInstanceDetails(), config, false);</span> |
| <span class="fc" id="L1060"> validateAccessPoint(em, bindingTemplate.getAccessPoint(), config);</span> |
| <span class="fc" id="L1061"> validateDescriptions(bindingTemplate.getDescription());</span> |
| <span class="fc" id="L1062"> validateHostingRedirector(em, bindingTemplate.getHostingRedirector(), config);</span> |
| |
| <span class="fc" id="L1064"> validateSignaturesBinding(bindingTemplate, config);</span> |
| //validateCheckedTModels(bindingTemplate, config); |
| <span class="fc" id="L1066"> }</span> |
| |
| public void validateTModel(EntityManager em, org.uddi.api_v3.TModel tModel, Configuration config, UddiEntityPublisher publisher) throws DispositionReportFaultMessage { |
| // A supplied tModel can't be null |
| <span class="pc bpc" id="L1070" title="1 of 2 branches missed."> if (tModel == null) {</span> |
| <span class="nc" id="L1071"> throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.NullInput"));</span> |
| } |
| |
| <span class="fc" id="L1074"> boolean entityExists = false;</span> |
| <span class="fc" id="L1075"> String entityKey = tModel.getTModelKey();</span> |
| <span class="pc bpc" id="L1076" title="1 of 4 branches missed."> if (entityKey == null || entityKey.length() == 0) {</span> |
| <span class="fc" id="L1077"> KeyGenerator keyGen = KeyGeneratorFactory.getKeyGenerator();</span> |
| <span class="fc" id="L1078"> entityKey = keyGen.generate(publisher);</span> |
| <span class="fc" id="L1079"> validateNotSigned(tModel);</span> |
| <span class="fc" id="L1080"> tModel.setTModelKey(entityKey);</span> |
| <span class="fc" id="L1081"> } else {</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L1083"> entityKey = entityKey.toLowerCase();</span> |
| <span class="fc" id="L1084"> tModel.setTModelKey(entityKey);</span> |
| |
| <span class="fc" id="L1086"> Object obj = em.find(org.apache.juddi.model.Tmodel.class, entityKey);</span> |
| <span class="fc bfc" id="L1087" title="All 2 branches covered."> if (obj != null) {</span> |
| <span class="fc" id="L1088"> entityExists = true;</span> |
| |
| // Make sure publisher owns this entity. |
| <span class="fc" id="L1091"> AccessCheck(obj, entityKey);</span> |
| //if (!publisher.isOwner((UddiEntity) obj)&& !((Publisher) publisher).isAdmin()) { |
| // throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey)); |
| // } |
| } else { |
| // Inside this block, we have a key proposed by the publisher on a new entity |
| |
| // First test to see if this is a Key Generator tModel. The keyGenerator suffix appearing in the key is the indicator, since this is not |
| // allowed *unless* it's a key generator. |
| <span class="fc bfc" id="L1100" title="All 2 branches covered."> if (entityKey.toUpperCase().contains(KeyGenerator.KEYGENERATOR_SUFFIX.toUpperCase())) {</span> |
| <span class="fc" id="L1101"> ValidateUDDIKey.validateUDDIv3KeyGeneratorTModel(tModel);</span> |
| |
| // The root publisher is only allowed one key generator. This is published in the installation. |
| <span class="fc" id="L1104"> String rootPublisherStr = "root";</span> |
| try { |
| <span class="fc" id="L1106"> rootPublisherStr = AppConfig.getConfiguration().getString(Property.JUDDI_ROOT_PUBLISHER);</span> |
| <span class="nc" id="L1107"> } catch (ConfigurationException ce) {</span> |
| <span class="nc" id="L1108"> log.error("Could not read the root publisher setting in the configuration.");</span> |
| <span class="fc" id="L1109"> }</span> |
| <span class="pc bpc" id="L1110" title="1 of 2 branches missed."> if (publisher.getAuthorizedName().equals(rootPublisherStr)) {</span> |
| <span class="nc" id="L1111"> throw new FatalErrorException(new ErrorMessage("errors.tmodel.keygenerator.RootKeyGen"));</span> |
| } |
| |
| // It's a valid Key Generator, but is it available for this publisher? |
| <span class="pc bpc" id="L1115" title="1 of 2 branches missed."> if (!publisher.isKeyGeneratorAvailable(em, entityKey)) {</span> |
| <span class="nc" id="L1116"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.BadPartition", entityKey));</span> |
| } |
| |
| <span class="fc" id="L1119"> } else {</span> |
| // If not a key generator, then simply validate key and then check to see that the proposed key is valid for this publisher |
| <span class="fc" id="L1121"> ValidateUDDIKey.validateUDDIv3Key(entityKey);</span> |
| //fix for JUDDI-851 |
| <span class="pc bpc" id="L1123" title="1 of 2 branches missed."> if (!entityKey.toUpperCase().startsWith("UUID:")) {</span> |
| <span class="pc bpc" id="L1124" title="1 of 2 branches missed."> if (!publisher.isValidPublisherKey(em, entityKey)) {</span> |
| <span class="nc" id="L1125"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.BadPartition", entityKey));</span> |
| } |
| } |
| } |
| } |
| } |
| |
| <span class="fc bfc" id="L1132" title="All 2 branches covered."> if (!entityExists) {</span> |
| // Check to make sure key isn't used by another entity. |
| <span class="pc bpc" id="L1134" title="1 of 2 branches missed."> if (!isUniqueKey(em, entityKey)) {</span> |
| <span class="nc" id="L1135"> throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.KeyExists", entityKey));</span> |
| } |
| } |
| <span class="fc" id="L1138"> validateKeyLength(entityKey);</span> |
| |
| // TODO: validate "checked" categories or category groups (see section 5.2.3 of spec)? optional to support |
| <span class="pc bpc" id="L1141" title="2 of 4 branches missed."> if (tModel.getName() == null || tModel.getName().getValue() == null</span> |
| <span class="pc bpc" id="L1142" title="1 of 2 branches missed."> || tModel.getName().getValue().equals("")) {</span> |
| <span class="nc" id="L1143"> throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.NoName"));</span> |
| } |
| |
| <span class="fc" id="L1146"> validateCategoryBag(tModel.getCategoryBag(), config, false);</span> |
| <span class="fc" id="L1147"> validateIdentifierBag(tModel.getIdentifierBag(), config, false);</span> |
| <span class="fc" id="L1148"> validateDescriptions(tModel.getDescription());</span> |
| <span class="fc" id="L1149"> validateNameLength(tModel.getName().getValue());</span> |
| <span class="fc" id="L1150"> validateLang(tModel.getName().getLang());</span> |
| <span class="fc" id="L1151"> List<org.uddi.api_v3.OverviewDoc> overviewDocList = tModel.getOverviewDoc();</span> |
| <span class="pc bpc" id="L1152" title="1 of 2 branches missed."> if (overviewDocList != null) {</span> |
| <span class="fc bfc" id="L1153" title="All 2 branches covered."> for (org.uddi.api_v3.OverviewDoc overviewDoc : overviewDocList) {</span> |
| <span class="fc" id="L1154"> validateOverviewDoc(overviewDoc);</span> |
| <span class="fc" id="L1155"> }</span> |
| } |
| <span class="fc" id="L1157"> validateSignaturesTModel(tModel, config);</span> |
| |
| <span class="fc" id="L1159"> }</span> |
| |
| public void validatePublisherAssertion(EntityManager em, org.uddi.api_v3.PublisherAssertion pubAssertion) throws DispositionReportFaultMessage { |
| // A supplied publisher assertion can't be null |
| <span class="pc bpc" id="L1163" title="1 of 2 branches missed."> if (pubAssertion == null) {</span> |
| <span class="nc" id="L1164"> throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.NullInput"));</span> |
| } |
| |
| // The keyedRef must not be blank and every field must contain data. |
| <span class="fc" id="L1168"> org.uddi.api_v3.KeyedReference keyedRef = pubAssertion.getKeyedReference();</span> |
| <span class="pc bpc" id="L1169" title="1 of 2 branches missed."> if (keyedRef == null</span> |
| <span class="pc bpc" id="L1170" title="2 of 4 branches missed."> || keyedRef.getTModelKey() == null || keyedRef.getTModelKey().length() == 0</span> |
| <span class="pc bpc" id="L1171" title="2 of 4 branches missed."> || keyedRef.getKeyName() == null || keyedRef.getKeyName().length() == 0</span> |
| <span class="pc bpc" id="L1172" title="2 of 4 branches missed."> || keyedRef.getKeyValue() == null || keyedRef.getKeyValue().length() == 0) {</span> |
| <span class="nc" id="L1173"> throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.BlankKeyedRef"));</span> |
| } |
| |
| <span class="fc" id="L1176"> String fromKey = pubAssertion.getFromKey();</span> |
| <span class="pc bpc" id="L1177" title="2 of 4 branches missed."> if (fromKey == null || fromKey.length() == 0) {</span> |
| <span class="nc" id="L1178"> throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.BlankFromKey"));</span> |
| } |
| |
| <span class="fc" id="L1181"> String toKey = pubAssertion.getToKey();</span> |
| <span class="pc bpc" id="L1182" title="2 of 4 branches missed."> if (toKey == null || toKey.length() == 0) {</span> |
| <span class="nc" id="L1183"> throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.BlankToKey"));</span> |
| } |
| |
| <span class="pc bpc" id="L1186" title="1 of 2 branches missed."> if (fromKey.equalsIgnoreCase(toKey)) {</span> |
| <span class="nc" id="L1187"> throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.SameBusinessKey"));</span> |
| } |
| |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L1191"> fromKey = fromKey.toLowerCase();</span> |
| <span class="fc" id="L1192"> pubAssertion.setFromKey(fromKey);</span> |
| <span class="fc" id="L1193"> toKey = toKey.toLowerCase();</span> |
| <span class="fc" id="L1194"> pubAssertion.setToKey(toKey);</span> |
| <span class="fc" id="L1195"> validateKeyLength(toKey);</span> |
| <span class="fc" id="L1196"> validateKeyLength(fromKey);</span> |
| <span class="fc" id="L1197"> Object fromObj = em.find(org.apache.juddi.model.BusinessEntity.class, fromKey);</span> |
| <span class="pc bpc" id="L1198" title="1 of 2 branches missed."> if (fromObj == null) {</span> |
| <span class="nc" id="L1199"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", fromKey));</span> |
| } |
| |
| <span class="fc" id="L1202"> Object toObj = em.find(org.apache.juddi.model.BusinessEntity.class, pubAssertion.getToKey());</span> |
| <span class="pc bpc" id="L1203" title="1 of 2 branches missed."> if (toObj == null) {</span> |
| <span class="nc" id="L1204"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", toKey));</span> |
| } |
| |
| <span class="fc bfc" id="L1207" title="All 4 branches covered."> if (!publisher.isOwner((UddiEntity) fromObj) && !publisher.isOwner((UddiEntity) toObj)) {</span> |
| <span class="fc" id="L1208"> throw new UserMismatchException(new ErrorMessage("errors.pubassertion.UserMismatch", fromKey + " & " + toKey));</span> |
| } |
| |
| try { |
| <span class="fc" id="L1212"> validateKeyedReference(pubAssertion.getKeyedReference(), AppConfig.getConfiguration(), false);</span> |
| <span class="nc" id="L1213"> } catch (ConfigurationException ce) {</span> |
| <span class="nc" id="L1214"> log.error("Could not optain config. " + ce.getMessage(), ce);</span> |
| <span class="fc" id="L1215"> }</span> |
| <span class="fc" id="L1216"> }</span> |
| |
| public void validateNames(List<org.uddi.api_v3.Name> names) throws DispositionReportFaultMessage { |
| // At least one name is required |
| <span class="pc bpc" id="L1220" title="2 of 4 branches missed."> if (names == null || names.size() == 0) {</span> |
| <span class="nc" id="L1221"> throw new ValueNotAllowedException(new ErrorMessage("errors.names.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L1224" title="All 2 branches covered."> for (Name n : names) {</span> |
| <span class="pc bpc" id="L1225" title="1 of 4 branches missed."> if (n.getValue() == null || n.getValue().length() == 0) {</span> |
| <span class="fc" id="L1226"> throw new ValueNotAllowedException(new ErrorMessage("errors.names.NoValue"));</span> |
| } |
| <span class="fc" id="L1228"> validateNameLength(n.getValue());</span> |
| <span class="fc" id="L1229"> validateLang(n.getLang());</span> |
| <span class="fc" id="L1230"> }</span> |
| |
| <span class="fc" id="L1232"> }</span> |
| |
| public void validateContacts(org.uddi.api_v3.Contacts contacts, Configuration config) throws DispositionReportFaultMessage { |
| // Contacts is optional |
| <span class="fc bfc" id="L1236" title="All 2 branches covered."> if (contacts == null) {</span> |
| <span class="fc" id="L1237"> return;</span> |
| } |
| |
| // If contacts do exist, at least one contact is required |
| <span class="fc" id="L1241"> List<org.uddi.api_v3.Contact> contactList = contacts.getContact();</span> |
| <span class="pc bpc" id="L1242" title="2 of 4 branches missed."> if (contactList == null || contactList.size() == 0) {</span> |
| <span class="nc" id="L1243"> throw new ValueNotAllowedException(new ErrorMessage("errors.contacts.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L1246" title="All 2 branches covered."> for (org.uddi.api_v3.Contact contact : contactList) {</span> |
| <span class="fc" id="L1247"> validateContact(contact, config);</span> |
| <span class="fc" id="L1248"> }</span> |
| |
| <span class="fc" id="L1250"> }</span> |
| |
| public void validateContact(org.uddi.api_v3.Contact contact, Configuration config) throws DispositionReportFaultMessage { |
| <span class="pc bpc" id="L1253" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1254"> log.debug("validateContact");</span> |
| } |
| // A supplied contact can't be null |
| <span class="pc bpc" id="L1257" title="1 of 2 branches missed."> if (contact == null) {</span> |
| <span class="nc" id="L1258"> throw new ValueNotAllowedException(new ErrorMessage("errors.contact.NullInput"));</span> |
| } |
| |
| // At least one personName is required |
| <span class="fc" id="L1262"> List<org.uddi.api_v3.PersonName> pnameList = contact.getPersonName();</span> |
| <span class="pc bpc" id="L1263" title="2 of 4 branches missed."> if (pnameList == null || pnameList.size() == 0) {</span> |
| <span class="nc" id="L1264"> throw new ValueNotAllowedException(new ErrorMessage("errors.contact.NoPersonName"));</span> |
| } |
| <span class="fc bfc" id="L1266" title="All 2 branches covered."> for (org.uddi.api_v3.PersonName pn : pnameList) {</span> |
| <span class="pc bpc" id="L1267" title="2 of 4 branches missed."> if (pn.getValue() == null || pn.getValue().length() == 0) {</span> |
| <span class="nc" id="L1268"> throw new ValueNotAllowedException(new ErrorMessage("errors.contacts.NoPersonName"));</span> |
| } |
| <span class="fc" id="L1270"> validateNameLength(pn.getValue());</span> |
| <span class="fc" id="L1271"> validateLang(pn.getLang());</span> |
| <span class="fc" id="L1272"> }</span> |
| |
| <span class="fc" id="L1274"> List<org.uddi.api_v3.Address> addressList = contact.getAddress();</span> |
| <span class="pc bpc" id="L1275" title="1 of 2 branches missed."> if (addressList != null) {</span> |
| <span class="fc bfc" id="L1276" title="All 2 branches covered."> for (org.uddi.api_v3.Address address : addressList) {</span> |
| <span class="pc bpc" id="L1277" title="1 of 2 branches missed."> if (address != null) {</span> |
| <span class="fc" id="L1278"> validateSortCode(address.getSortCode());</span> |
| <span class="fc" id="L1279"> validateKeyLength(address.getTModelKey());</span> |
| <span class="fc" id="L1280"> validateLang(address.getLang());</span> |
| <span class="fc" id="L1281"> validateUseType(address.getUseType());</span> |
| <span class="fc" id="L1282"> boolean checked = true;</span> |
| // Per section 4.4: keys must be case-folded |
| <span class="pc bpc" id="L1284" title="1 of 2 branches missed."> if (address.getTModelKey() != null) {</span> |
| <span class="fc" id="L1285"> address.setTModelKey(address.getTModelKey().toLowerCase());</span> |
| <span class="fc" id="L1286"> validatedAddressLinesIfKeyDefined(address.getAddressLine());</span> |
| |
| <span class="fc" id="L1288"> checked = verifyTModelKeyExistsAndChecked(address.getTModelKey(), config);</span> |
| |
| } |
| <span class="pc bpc" id="L1291" title="2 of 4 branches missed."> if (address.getAddressLine() == null || address.getAddressLine().size() == 0) {</span> |
| <span class="nc" id="L1292"> throw new ValueNotAllowedException(new ErrorMessage("errors.contact.NoAddressLine"));</span> |
| } |
| |
| <span class="fc bfc" id="L1295" title="All 2 branches covered."> if (checked) {</span> |
| <span class="fc" id="L1296"> validateAddressLines(address.getAddressLine(), config);</span> |
| } |
| } |
| <span class="fc" id="L1299"> }</span> |
| } |
| <span class="fc" id="L1301"> validateEmailAddress(contact.getEmail());</span> |
| <span class="fc" id="L1302"> validatePhone(contact.getPhone());</span> |
| <span class="fc" id="L1303"> validateDescriptions(contact.getDescription());</span> |
| <span class="fc" id="L1304"> validateUseType(contact.getUseType());</span> |
| <span class="fc" id="L1305"> }</span> |
| |
| public void validateDiscoveryUrls(org.uddi.api_v3.DiscoveryURLs discUrls) throws DispositionReportFaultMessage { |
| // Discovery Urls is optional |
| <span class="fc bfc" id="L1309" title="All 2 branches covered."> if (discUrls == null) {</span> |
| <span class="fc" id="L1310"> return;</span> |
| } |
| |
| // If discUrls does exist, it must have at least one element |
| <span class="fc" id="L1314"> List<org.uddi.api_v3.DiscoveryURL> discUrlList = discUrls.getDiscoveryURL();</span> |
| <span class="pc bpc" id="L1315" title="2 of 4 branches missed."> if (discUrlList == null || discUrlList.size() == 0) {</span> |
| <span class="nc" id="L1316"> throw new ValueNotAllowedException(new ErrorMessage("errors.discurls.NoInput"));</span> |
| } |
| <span class="fc bfc" id="L1318" title="All 2 branches covered."> for (org.uddi.api_v3.DiscoveryURL url : discUrlList) {</span> |
| <span class="pc bpc" id="L1319" title="2 of 4 branches missed."> if (url.getValue() == null || url.getValue().length() == 0) {</span> |
| <span class="nc" id="L1320"> throw new ValueNotAllowedException(new ErrorMessage("errors.discurls.NoInput"));</span> |
| } |
| <span class="fc" id="L1322"> validateDiscoveryUrlLength(url);</span> |
| <span class="fc" id="L1323"> }</span> |
| <span class="fc" id="L1324"> }</span> |
| |
| public void validateCategoryBag(org.uddi.api_v3.CategoryBag categories, Configuration config, boolean isRoot) throws DispositionReportFaultMessage { |
| |
| // Category bag is optional |
| <span class="fc bfc" id="L1329" title="All 2 branches covered."> if (categories == null) {</span> |
| <span class="fc" id="L1330"> return;</span> |
| } |
| |
| // If category bag does exist, it must have at least one element |
| <span class="fc" id="L1334"> List<KeyedReference> elems = categories.getKeyedReference();</span> |
| <span class="fc" id="L1335"> List<KeyedReferenceGroup> groups = categories.getKeyedReferenceGroup();</span> |
| <span class="fc bfc" id="L1336" title="All 4 branches covered."> if (groups.size() == 0 && elems.size() == 0) {</span> |
| <span class="fc" id="L1337"> throw new ValueNotAllowedException(new ErrorMessage("errors.categorybag.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L1340" title="All 2 branches covered."> for (KeyedReferenceGroup group : groups) {</span> |
| <span class="fc" id="L1341"> validateKeyedReferenceGroup(group, config, isRoot);</span> |
| <span class="fc" id="L1342"> }</span> |
| |
| <span class="fc bfc" id="L1344" title="All 2 branches covered."> for (KeyedReference elem : elems) {</span> |
| <span class="fc" id="L1345"> validateKeyedReference(elem, config, isRoot);</span> |
| <span class="fc" id="L1346"> }</span> |
| <span class="fc" id="L1347"> }</span> |
| |
| public void validateIdentifierBag(org.uddi.api_v3.IdentifierBag identifiers, Configuration config, boolean isRoot) throws DispositionReportFaultMessage { |
| |
| // Identifier bag is optional |
| <span class="fc bfc" id="L1352" title="All 2 branches covered."> if (identifiers == null) {</span> |
| <span class="fc" id="L1353"> return;</span> |
| } |
| |
| // If category bag does exist, it must have at least one element |
| <span class="fc" id="L1357"> List<org.uddi.api_v3.KeyedReference> keyedRefList = identifiers.getKeyedReference();</span> |
| <span class="pc bpc" id="L1358" title="2 of 4 branches missed."> if (keyedRefList == null || keyedRefList.size() == 0) {</span> |
| <span class="nc" id="L1359"> throw new ValueNotAllowedException(new ErrorMessage("errors.identifierbag.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L1362" title="All 2 branches covered."> for (org.uddi.api_v3.KeyedReference keyedRef : keyedRefList) {</span> |
| <span class="fc" id="L1363"> validateKeyedReference(keyedRef, config, isRoot);</span> |
| <span class="fc" id="L1364"> }</span> |
| <span class="fc" id="L1365"> }</span> |
| |
| public void validateKeyedReferenceGroup(KeyedReferenceGroup krg, Configuration config, boolean isRoot) throws DispositionReportFaultMessage { |
| // Keyed reference groups must contain a tModelKey |
| <span class="pc bpc" id="L1369" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1370"> log.debug("validateKeyedReferenceGroup");</span> |
| } |
| <span class="pc bpc" id="L1372" title="2 of 4 branches missed."> if (krg.getTModelKey() == null || krg.getTModelKey().length() == 0) {</span> |
| <span class="nc" id="L1373"> throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoTModelKey"));</span> |
| } |
| |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L1377"> String tmodelKey = krg.getTModelKey().toLowerCase();</span> |
| <span class="fc" id="L1378"> krg.setTModelKey(tmodelKey);</span> |
| <span class="fc" id="L1379"> validateKeyLength(tmodelKey);</span> |
| |
| <span class="fc" id="L1381"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L1383"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L1384"> } catch (Exception ex) {</span> |
| <span class="nc" id="L1385"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L1386"> }</span> |
| <span class="pc bpc" id="L1387" title="2 of 4 branches missed."> if (checkRef && !isRoot) {</span> |
| <span class="fc" id="L1388"> this.verifyTModelKeyExists(tmodelKey);</span> |
| } |
| |
| <span class="fc" id="L1391"> boolean checked = verifyTModelKeyExistsAndChecked(tmodelKey, config);</span> |
| |
| <span class="fc bfc" id="L1393" title="All 2 branches covered."> if (checked) {</span> |
| <span class="fc" id="L1394"> List<KeyedReference> keyedRefs = krg.getKeyedReference();</span> |
| // Should being empty raise an error? |
| <span class="pc bpc" id="L1396" title="2 of 4 branches missed."> if (keyedRefs != null && keyedRefs.size() > 0) {</span> |
| <span class="fc bfc" id="L1397" title="All 2 branches covered."> for (KeyedReference keyedRef : keyedRefs) {</span> |
| <span class="fc" id="L1398"> validateKeyedReference(keyedRef, config, isRoot);</span> |
| <span class="fc" id="L1399"> }</span> |
| } |
| } |
| <span class="fc" id="L1402"> }</span> |
| |
| /** |
| * |
| * @param kr |
| * @param config |
| * @param isRoot true during install time, otherwise false |
| * @throws DispositionReportFaultMessage |
| */ |
| public void validateKeyedReference(KeyedReference kr, Configuration config, boolean isRoot) throws DispositionReportFaultMessage { |
| <span class="pc bpc" id="L1412" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1413"> log.debug("validateKeyedReference");</span> |
| } |
| <span class="fc" id="L1415"> String tmodelKey = kr.getTModelKey();</span> |
| |
| <span class="pc bpc" id="L1417" title="2 of 4 branches missed."> if (tmodelKey == null || tmodelKey.length() == 0) {</span> |
| <span class="nc" id="L1418"> throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoTModelKey"));</span> |
| } |
| |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L1422"> tmodelKey = tmodelKey.toLowerCase();</span> |
| <span class="fc" id="L1423"> kr.setTModelKey(tmodelKey);</span> |
| <span class="fc" id="L1424"> validateKeyLength(tmodelKey);</span> |
| |
| <span class="pc bpc" id="L1426" title="2 of 4 branches missed."> if (kr.getKeyValue() == null || kr.getKeyValue().length() == 0) {</span> |
| <span class="nc" id="L1427"> throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoKeyValue"));</span> |
| } |
| <span class="fc" id="L1429"> validateKeyValue(kr.getKeyValue());</span> |
| <span class="fc" id="L1430"> validateKeyName(kr.getKeyName());</span> |
| |
| <span class="fc" id="L1432"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L1434"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L1435"> } catch (Exception ex) {</span> |
| <span class="nc" id="L1436"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L1437"> }</span> |
| <span class="pc bpc" id="L1438" title="1 of 4 branches missed."> if (checkRef && !isRoot) {</span> |
| <span class="fc" id="L1439"> this.verifyTModelKeyExists(tmodelKey);</span> |
| |
| } |
| |
| <span class="fc" id="L1443"> String rootPublisherStr = config.getString(Property.JUDDI_ROOT_PUBLISHER);</span> |
| // Per section 6.2.2.1 of the specification, no publishers (except the root) are allowed to use the node categorization tmodelKey |
| <span class="fc bfc" id="L1445" title="All 2 branches covered."> if (Constants.NODE_CATEGORY_TMODEL.equalsIgnoreCase(kr.getTModelKey())) {</span> |
| <span class="pc bpc" id="L1446" title="1 of 2 branches missed."> if (!rootPublisherStr.equals(publisher.getAuthorizedName())) {</span> |
| <span class="nc" id="L1447"> throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NodeCategoryTModel", Constants.NODE_CATEGORY_TMODEL));</span> |
| } |
| } |
| <span class="fc" id="L1450"> }</span> |
| |
| public void validateTModelInstanceDetails(org.uddi.api_v3.TModelInstanceDetails tmodelInstDetails, Configuration config, boolean isRoot) throws DispositionReportFaultMessage { |
| <span class="pc bpc" id="L1453" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1454"> log.debug("validateTModelInstanceDetails");</span> |
| } |
| // tModel Instance Details is optional |
| <span class="fc bfc" id="L1457" title="All 2 branches covered."> if (tmodelInstDetails == null) {</span> |
| <span class="fc" id="L1458"> return;</span> |
| } |
| |
| // If tmodelInstDetails does exist, it must have at least one element |
| <span class="fc" id="L1462"> List<org.uddi.api_v3.TModelInstanceInfo> tmodelInstInfoList = tmodelInstDetails.getTModelInstanceInfo();</span> |
| <span class="pc bpc" id="L1463" title="2 of 4 branches missed."> if (tmodelInstInfoList == null || tmodelInstInfoList.size() == 0) {</span> |
| <span class="nc" id="L1464"> throw new ValueNotAllowedException(new ErrorMessage("errors.tmodelinstdetails.NoInput"));</span> |
| } |
| |
| <span class="fc bfc" id="L1467" title="All 2 branches covered."> for (org.uddi.api_v3.TModelInstanceInfo tmodelInstInfo : tmodelInstInfoList) {</span> |
| <span class="fc" id="L1468"> validateTModelInstanceInfo(tmodelInstInfo, config, isRoot);</span> |
| <span class="fc" id="L1469"> }</span> |
| <span class="fc" id="L1470"> }</span> |
| |
| public void validateTModelInstanceInfo(org.uddi.api_v3.TModelInstanceInfo tmodelInstInfo, Configuration config, boolean isRoot) throws DispositionReportFaultMessage { |
| // tModel Instance Info can't be null |
| <span class="pc bpc" id="L1474" title="1 of 2 branches missed."> if (tmodelInstInfo == null) {</span> |
| <span class="nc" id="L1475"> throw new ValueNotAllowedException(new ErrorMessage("errors.tmodelinstinfo.NullInput"));</span> |
| } |
| |
| // TModel key is required |
| <span class="pc bpc" id="L1479" title="2 of 4 branches missed."> if (tmodelInstInfo.getTModelKey() == null || tmodelInstInfo.getTModelKey().length() == 0) {</span> |
| <span class="nc" id="L1480"> throw new ValueNotAllowedException(new ErrorMessage("errors.tmodelinstinfo.NoTModelKey"));</span> |
| } |
| |
| // Per section 4.4: keys must be case-folded |
| <span class="fc" id="L1484"> tmodelInstInfo.setTModelKey((tmodelInstInfo.getTModelKey().toLowerCase()));</span> |
| |
| <span class="fc" id="L1486"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L1488"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L1489"> } catch (Exception ex) {</span> |
| <span class="nc" id="L1490"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L1491"> }</span> |
| <span class="pc bpc" id="L1492" title="1 of 4 branches missed."> if (checkRef && !isRoot) {</span> |
| <span class="fc" id="L1493"> this.verifyTModelKeyExists(tmodelInstInfo.getTModelKey());</span> |
| } |
| |
| <span class="fc" id="L1496"> validateInstanceDetails(tmodelInstInfo.getInstanceDetails());</span> |
| <span class="pc bpc" id="L1497" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1498"> log.debug("validateTModelInstanceInfo");</span> |
| } |
| |
| <span class="fc" id="L1501"> validateKeyLength(tmodelInstInfo.getTModelKey());</span> |
| <span class="fc" id="L1502"> validateDescriptions(tmodelInstInfo.getDescription());</span> |
| |
| <span class="fc" id="L1504"> }</span> |
| |
| public void validateInstanceDetails(org.uddi.api_v3.InstanceDetails instDetails) throws DispositionReportFaultMessage { |
| // Instance Details is optional |
| <span class="fc bfc" id="L1508" title="All 2 branches covered."> if (instDetails == null) {</span> |
| <span class="fc" id="L1509"> return;</span> |
| } |
| |
| // At least one OverviewDoc or instanceParms must be supplied |
| <span class="fc" id="L1513"> List<OverviewDoc> elems = instDetails.getOverviewDoc();</span> |
| <span class="pc bpc" id="L1514" title="3 of 4 branches missed."> if (instDetails.getInstanceParms() == null && elems.size() == 0) {</span> |
| <span class="nc" id="L1515"> throw new ValueNotAllowedException(new ErrorMessage("errors.instdetails.NoOverviewOrParms"));</span> |
| } |
| <span class="fc bfc" id="L1517" title="All 2 branches covered."> for (int i = 0; i < elems.size(); i++) {</span> |
| <span class="fc" id="L1518"> validateDescriptions(elems.get(i).getDescription());</span> |
| <span class="fc" id="L1519"> validateOverviewURL(elems.get(i).getOverviewURL());</span> |
| } |
| <span class="pc bpc" id="L1521" title="1 of 2 branches missed."> if (instDetails.getInstanceParms()!=null){</span> |
| <span class="fc bfc" id="L1522" title="All 2 branches covered."> if (instDetails.getInstanceParms().length()>8192){</span> |
| <span class="fc" id="L1523"> throw new ValueNotAllowedException(new ErrorMessage("errors.instdetails.MaxLength",instDetails.getInstanceParms().length()+""));</span> |
| } |
| } |
| <span class="fc" id="L1526"> }</span> |
| |
| public void validateOverviewDoc(org.uddi.api_v3.OverviewDoc overviewDoc) throws DispositionReportFaultMessage { |
| // OverviewDoc can't be null |
| <span class="pc bpc" id="L1530" title="1 of 2 branches missed."> if (overviewDoc == null) {</span> |
| <span class="nc" id="L1531"> throw new ValueNotAllowedException(new ErrorMessage("errors.overviewdoc.NullInput"));</span> |
| } |
| |
| // At least one description or overview URL must be supplied |
| <span class="fc" id="L1535"> List<org.uddi.api_v3.Description> elems = overviewDoc.getDescription();</span> |
| <span class="pc bpc" id="L1536" title="3 of 6 branches missed."> if ((elems == null || elems.size() == 0) && overviewDoc.getOverviewURL() == null) {</span> |
| <span class="nc" id="L1537"> throw new ValueNotAllowedException(new ErrorMessage("errors.overviewdoc.NoDescOrUrl"));</span> |
| } |
| <span class="pc bpc" id="L1539" title="1 of 2 branches missed."> for (int i = 0; i < elems.size(); i++) {</span> |
| <span class="nc" id="L1540"> validateLang(elems.get(i).getLang());</span> |
| <span class="nc" id="L1541"> validateURL(elems.get(i).getValue());</span> |
| } |
| <span class="fc" id="L1543"> }</span> |
| |
| public void validateRegisteredInfo(org.uddi.api_v3.GetRegisteredInfo body) throws DispositionReportFaultMessage { |
| // No null input |
| <span class="pc bpc" id="L1547" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L1548"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // infoSelection is required |
| <span class="pc bpc" id="L1552" title="1 of 2 branches missed."> if (body.getInfoSelection() == null) {</span> |
| <span class="nc" id="L1553"> throw new ValueNotAllowedException(new ErrorMessage("errors.getregisteredinfo.NoInfoSelection"));</span> |
| } |
| |
| <span class="fc" id="L1556"> }</span> |
| |
| /** |
| * Publishing API functions are specific to jUDDI. Requires |
| * administrative privilege |
| * |
| * @param em |
| * @param body |
| * @throws DispositionReportFaultMessage |
| */ |
| public void validateDeletePublisher(EntityManager em, DeletePublisher body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L1569" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L1570"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L1574"> List<String> entityKeyList = body.getPublisherId();</span> |
| <span class="pc bpc" id="L1575" title="2 of 4 branches missed."> if (entityKeyList == null || entityKeyList.size() == 0) {</span> |
| <span class="nc" id="L1576"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));</span> |
| } |
| |
| <span class="pc bpc" id="L1579" title="1 of 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L1580"> throw new UserMismatchException(new ErrorMessage("errors.deletepublisher.AdminReqd"));</span> |
| } |
| |
| <span class="fc" id="L1583"> HashSet<String> dupCheck = new HashSet<String>();</span> |
| <span class="fc bfc" id="L1584" title="All 2 branches covered."> for (String entityKey : entityKeyList) {</span> |
| <span class="fc" id="L1585"> validateKeyLength(entityKey);</span> |
| <span class="fc" id="L1586"> boolean inserted = dupCheck.add(entityKey);</span> |
| <span class="pc bpc" id="L1587" title="1 of 2 branches missed."> if (!inserted) {</span> |
| <span class="nc" id="L1588"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));</span> |
| } |
| |
| <span class="fc" id="L1591"> Object obj = em.find(org.apache.juddi.model.Publisher.class, entityKey);</span> |
| <span class="pc bpc" id="L1592" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L1593"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.PublisherNotFound", entityKey));</span> |
| } |
| |
| <span class="fc" id="L1596"> }</span> |
| <span class="fc" id="L1597"> }</span> |
| |
| public void validateSaveSubscriptionAdmin(EntityManager em, String publisherOrUsername, List<Subscription> subscriptions) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="nc bnc" id="L1602" title="All 4 branches missed."> if (subscriptions == null || subscriptions.isEmpty()) {</span> |
| <span class="nc" id="L1603"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| <span class="nc bnc" id="L1606" title="All 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L1607"> throw new UserMismatchException(new ErrorMessage("errors.deletepublisher.AdminReqd"));</span> |
| } |
| <span class="nc" id="L1609"> UddiEntityPublisher user = new UddiEntityPublisher(publisherOrUsername);</span> |
| <span class="nc" id="L1610"> ValidateSubscription vsub = new ValidateSubscription(user);</span> |
| <span class="nc bnc" id="L1611" title="All 2 branches missed."> for (int i = 0; i < subscriptions.size(); i++) {</span> |
| <span class="nc" id="L1612"> vsub.validateSubscriptions(em, subscriptions, user);</span> |
| } |
| <span class="nc" id="L1614"> }</span> |
| |
| public void validateSavePublisher(EntityManager em, SavePublisher body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L1619" title="1 of 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L1620"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="fc" id="L1624"> List<org.apache.juddi.api_v3.Publisher> entityList = body.getPublisher();</span> |
| <span class="pc bpc" id="L1625" title="2 of 4 branches missed."> if (entityList == null || entityList.size() == 0) {</span> |
| <span class="nc" id="L1626"> throw new ValueNotAllowedException(new ErrorMessage("errors.savepublisher.NoInput"));</span> |
| } |
| |
| <span class="pc bpc" id="L1629" title="1 of 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L1630"> throw new UserMismatchException(new ErrorMessage("errors.savepublisher.AdminReqd", publisher.getAuthorizedName()));</span> |
| } |
| |
| <span class="fc bfc" id="L1633" title="All 2 branches covered."> for (org.apache.juddi.api_v3.Publisher entity : entityList) {</span> |
| <span class="fc" id="L1634"> validatePublisher(em, entity);</span> |
| <span class="fc" id="L1635"> }</span> |
| <span class="fc" id="L1636"> }</span> |
| |
| public void validatePublisher(EntityManager em, org.apache.juddi.api_v3.Publisher publisher) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="pc bpc" id="L1641" title="1 of 2 branches missed."> if (publisher == null) {</span> |
| <span class="nc" id="L1642"> throw new ValueNotAllowedException(new ErrorMessage("errors.publisher.NullInput"));</span> |
| } |
| |
| <span class="fc" id="L1645"> String authorizedName = publisher.getAuthorizedName();</span> |
| <span class="pc bpc" id="L1646" title="2 of 4 branches missed."> if (authorizedName == null || authorizedName.length() == 0) {</span> |
| <span class="nc" id="L1647"> throw new ValueNotAllowedException(new ErrorMessage("errors.publisher.NoAuthorizedName"));</span> |
| } |
| |
| <span class="fc" id="L1650"> String publisherName = publisher.getPublisherName();</span> |
| <span class="pc bpc" id="L1651" title="2 of 4 branches missed."> if (publisherName == null || publisherName.length() == 0) {</span> |
| <span class="nc" id="L1652"> throw new ValueNotAllowedException(new ErrorMessage("errors.publisher.NoPublisherName"));</span> |
| } |
| //TODO identify JUDDI restrictions on publisher name |
| <span class="fc" id="L1655"> }</span> |
| |
| public void validateAdminDeleteTModel(EntityManager em, DeleteTModel body) throws DispositionReportFaultMessage { |
| |
| // No null input |
| <span class="nc bnc" id="L1660" title="All 2 branches missed."> if (body == null) {</span> |
| <span class="nc" id="L1661"> throw new FatalErrorException(new ErrorMessage("errors.NullInput"));</span> |
| } |
| |
| // No null or empty list |
| <span class="nc" id="L1665"> List<String> entityKeyList = body.getTModelKey();</span> |
| <span class="nc bnc" id="L1666" title="All 4 branches missed."> if (entityKeyList == null || entityKeyList.size() == 0) {</span> |
| <span class="nc" id="L1667"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));</span> |
| } |
| |
| <span class="nc bnc" id="L1670" title="All 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L1671"> throw new UserMismatchException(new ErrorMessage("errors.AdminReqd"));</span> |
| } |
| |
| <span class="nc" id="L1674"> HashSet<String> dupCheck = new HashSet<String>();</span> |
| <span class="nc bnc" id="L1675" title="All 2 branches missed."> for (String entityKey : entityKeyList) {</span> |
| <span class="nc" id="L1676"> validateKeyLength(entityKey);</span> |
| <span class="nc" id="L1677"> boolean inserted = dupCheck.add(entityKey);</span> |
| <span class="nc bnc" id="L1678" title="All 2 branches missed."> if (!inserted) {</span> |
| <span class="nc" id="L1679"> throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));</span> |
| } |
| |
| //removed a check for checking if the entity exists which was moved to the juddi api class |
| //why? because we were looking up the same object twice in the database and its just not efficient |
| <span class="nc" id="L1684"> }</span> |
| <span class="nc" id="L1685"> }</span> |
| //////////////////////////////////////////////////////////////////// |
| ////////////////////////// begin validation code |
| //////////////////////////////////////////////////////////////////// |
| |
| private static void validateDescription(String value) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1691" title="1 of 4 branches missed."> if (value != null && value.length() > ValidationConstants.MAX_description) {</span> |
| <span class="fc" id="L1692"> throw new ValueNotAllowedException(new ErrorMessage("errors.DescriptionTooLong"));</span> |
| } |
| <span class="fc" id="L1694"> }</span> |
| |
| public static void validateLang(String lang) throws ValueNotAllowedException { |
| <span class="fc bfc" id="L1697" title="All 4 branches covered."> if (lang != null && lang.length() > ValidationConstants.MAX_xml_lang) {</span> |
| <span class="fc" id="L1698"> throw new ValueNotAllowedException(new ErrorMessage("errors.names.LangTooLong"));</span> |
| } |
| <span class="fc" id="L1700"> }</span> |
| |
| private static void validateUseType(String useType) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1703" title="1 of 4 branches missed."> if (useType != null && useType.length() > ValidationConstants.MAX_useType) {</span> |
| <span class="fc" id="L1704"> throw new ValueNotAllowedException(new ErrorMessage("errors.names.UseTypeTooLong"));</span> |
| } |
| <span class="fc" id="L1706"> }</span> |
| |
| public static void validateKeyLength(String value) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1709" title="1 of 4 branches missed."> if (value != null && value.length() > ValidationConstants.MAX_Key) {</span> |
| <span class="fc" id="L1710"> throw new ValueNotAllowedException(new ErrorMessage("errors.keys.TooLong"));</span> |
| } |
| <span class="fc" id="L1712"> }</span> |
| |
| private void validateAccessPoint(EntityManager em, AccessPoint value, Configuration config) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1715" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1716"> log.debug("validateAccessPoint");</span> |
| } |
| |
| <span class="fc bfc" id="L1719" title="All 2 branches covered."> if (value != null) {</span> |
| <span class="fc bfc" id="L1720" title="All 2 branches covered."> if (value.getValue().length() > ValidationConstants.MAX_accessPoint) {</span> |
| <span class="fc" id="L1721"> throw new ValueNotAllowedException(new ErrorMessage("errors.accessPoint.TooLong"));</span> |
| } |
| |
| <span class="fc" id="L1724"> validateUseType(value.getUseType());</span> |
| <span class="pc bpc" id="L1725" title="1 of 2 branches missed."> if (value.getUseType() != null) {</span> |
| <span class="fc bfc" id="L1726" title="All 2 branches covered."> if (value.getUseType().equalsIgnoreCase(AccessPointType.BINDING_TEMPLATE.toString())) {</span> |
| //validate that the referenced binding key exists already |
| <span class="fc" id="L1728"> Object obj = em.find(org.apache.juddi.model.BindingTemplate.class, value.getValue());</span> |
| <span class="fc bfc" id="L1729" title="All 2 branches covered."> if (obj == null) {</span> |
| <span class="fc" id="L1730"> throw new ValueNotAllowedException(new ErrorMessage("errors.accessPoint.bindingtemplateRedirect.keynotexist"));</span> |
| } |
| |
| <span class="pc bpc" id="L1733" title="1 of 2 branches missed."> } else if (value.getUseType().equalsIgnoreCase(AccessPointType.HOSTING_REDIRECTOR.toString())) {</span> |
| try { |
| //no validation necessary other than confirm that it's a URL |
| <span class="nc" id="L1736"> new URL(value.getValue());</span> |
| <span class="nc" id="L1737"> } catch (MalformedURLException ex) {</span> |
| <span class="nc" id="L1738"> throw new ValueNotAllowedException(new ErrorMessage("errors.accessPoint.hostingRedirector.notaurl"));</span> |
| <span class="nc" id="L1739"> }</span> |
| } |
| //TODO determine if additional validation is required. |
| //potentials, if its a wsdl deployment, is the Value a valid URI |
| //if endpoint, is it a valid URI? |
| } |
| } |
| <span class="fc" id="L1746"> }</span> |
| |
| private void validateHostingRedirector(EntityManager em, HostingRedirector hostingRedirector, Configuration config) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1749" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1750"> log.debug("validateHostingRedirector");</span> |
| } |
| <span class="fc bfc" id="L1752" title="All 2 branches covered."> if (hostingRedirector == null) {</span> |
| <span class="fc" id="L1753"> return;</span> |
| } |
| |
| <span class="pc bpc" id="L1756" title="2 of 4 branches missed."> if (hostingRedirector.getBindingKey() == null || hostingRedirector.getBindingKey().length() == 0) {</span> |
| <span class="nc" id="L1757"> throw new ValueNotAllowedException(new ErrorMessage("errors.hostingredirector.noinput"));</span> |
| } |
| <span class="fc bfc" id="L1759" title="All 2 branches covered."> if (hostingRedirector.getBindingKey().length() > ValidationConstants.MAX_Key) {</span> |
| <span class="fc" id="L1760"> throw new ValueNotAllowedException(new ErrorMessage("errors.hostingredirector.TooLong"));</span> |
| } |
| <span class="fc" id="L1762"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L1764"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L1765"> } catch (Exception ex) {</span> |
| <span class="nc" id="L1766"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L1767"> }</span> |
| <span class="pc bpc" id="L1768" title="1 of 2 branches missed."> if (checkRef) {</span> |
| //TODO check the spec to confirm this is logically correct |
| /*Object obj = em.find(org.apache.juddi.model.BindingTemplate.class, hostingRedirector.getBindingKey()); |
| if (obj == null) { |
| throw new ValueNotAllowedException(new ErrorMessage("errors.hostingredirector.keynotexist")); |
| }*/ |
| } |
| |
| <span class="fc" id="L1776"> }</span> |
| |
| private void validateNameLength(String value) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1779" title="2 of 4 branches missed."> if (value == null || value.length() == 0) {</span> |
| <span class="nc" id="L1780"> throw new ValueNotAllowedException(new ErrorMessage("errors.names.NoInput"));</span> |
| } |
| <span class="fc bfc" id="L1782" title="All 2 branches covered."> if (value.length() > ValidationConstants.MAX_name) {</span> |
| <span class="fc" id="L1783"> throw new ValueNotAllowedException(new ErrorMessage("errors.names.TooLong"));</span> |
| } |
| |
| <span class="fc" id="L1786"> }</span> |
| |
| private void validateSortCode(String value) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1789" title="1 of 4 branches missed."> if (value != null && value.length() > ValidationConstants.MAX_sortCode) {</span> |
| <span class="fc" id="L1790"> throw new ValueNotAllowedException(new ErrorMessage("errors.sortCode.TooLong"));</span> |
| } |
| <span class="fc" id="L1792"> }</span> |
| |
| private void validateAddressLines(List<AddressLine> addressLine, Configuration config) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1795" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1796"> log.debug("validateAddressLines");</span> |
| } |
| <span class="pc bpc" id="L1798" title="1 of 2 branches missed."> if (addressLine != null) {</span> |
| <span class="fc bfc" id="L1799" title="All 2 branches covered."> for (int i = 0; i < addressLine.size(); i++) {</span> |
| <span class="fc" id="L1800"> validateKeyName(addressLine.get(i).getKeyName());</span> |
| <span class="fc" id="L1801"> verifyTModelKeyExistsAndChecked(addressLine.get(i).getKeyName(), config);</span> |
| |
| <span class="fc" id="L1803"> validateKeyValue(addressLine.get(i).getKeyValue());</span> |
| <span class="pc bpc" id="L1804" title="2 of 4 branches missed."> if (addressLine.get(i).getValue() == null || addressLine.get(i).getValue().length() == 0) {</span> |
| <span class="nc" id="L1805"> throw new ValueNotAllowedException(new ErrorMessage("errors.addressline.noinput"));</span> |
| } |
| <span class="fc bfc" id="L1807" title="All 2 branches covered."> if (addressLine.get(i).getValue().length() > ValidationConstants.MAX_addressLine) {</span> |
| <span class="fc" id="L1808"> throw new ValueNotAllowedException(new ErrorMessage("errors.addressline.TooLong"));</span> |
| } |
| } |
| } |
| <span class="fc" id="L1812"> }</span> |
| |
| private void validateEmailAddress(List<Email> email) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1815" title="1 of 2 branches missed."> if (email != null) {</span> |
| <span class="fc bfc" id="L1816" title="All 2 branches covered."> for (int i = 0; i < email.size(); i++) {</span> |
| <span class="fc" id="L1817"> validateUseType(email.get(i).getUseType());</span> |
| <span class="pc bpc" id="L1818" title="2 of 4 branches missed."> if (email.get(i).getValue() == null || email.get(i).getValue().length() == 0) {</span> |
| <span class="nc" id="L1819"> throw new ValueNotAllowedException(new ErrorMessage("errors.email.noinput"));</span> |
| } |
| <span class="fc bfc" id="L1821" title="All 2 branches covered."> if (email.get(i).getValue().length() > ValidationConstants.MAX_email) {</span> |
| <span class="fc" id="L1822"> throw new ValueNotAllowedException(new ErrorMessage("errors.email.TooLong"));</span> |
| } |
| } |
| } |
| <span class="fc" id="L1826"> }</span> |
| |
| private void validatePhone(List<Phone> phone) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1829" title="1 of 2 branches missed."> if (phone != null) {</span> |
| <span class="fc bfc" id="L1830" title="All 2 branches covered."> for (int i = 0; i < phone.size(); i++) {</span> |
| <span class="fc" id="L1831"> validateUseType(phone.get(i).getUseType());</span> |
| <span class="pc bpc" id="L1832" title="1 of 2 branches missed."> if (phone.get(i).getValue() == null</span> |
| <span class="pc bpc" id="L1833" title="1 of 2 branches missed."> || phone.get(i).getValue().length() == 0) {</span> |
| <span class="nc" id="L1834"> throw new ValueNotAllowedException(new ErrorMessage("errors.phone.noinput"));</span> |
| } |
| <span class="fc bfc" id="L1836" title="All 2 branches covered."> if (phone.get(i).getValue().length() > ValidationConstants.MAX_phone) {</span> |
| <span class="fc" id="L1837"> throw new ValueNotAllowedException(new ErrorMessage("errors.phone.TooLong"));</span> |
| } |
| } |
| } |
| <span class="fc" id="L1841"> }</span> |
| |
| private void validateDiscoveryUrlLength(DiscoveryURL url) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1844" title="1 of 2 branches missed."> if (url != null) {</span> |
| <span class="fc" id="L1845"> validateUseType(url.getUseType());</span> |
| <span class="fc" id="L1846"> validateURL(url.getValue());</span> |
| } |
| <span class="fc" id="L1848"> }</span> |
| |
| private void validateKeyValue(String value) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1851" title="1 of 4 branches missed."> if (value != null && value.length() > ValidationConstants.MAX_keyValue) {</span> |
| <span class="fc" id="L1852"> throw new ValueNotAllowedException(new ErrorMessage("errors.keyvalue.TooLong"));</span> |
| } |
| <span class="fc" id="L1854"> }</span> |
| |
| private void validateKeyName(String value) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1857" title="1 of 4 branches missed."> if (value != null && value.length() > ValidationConstants.MAX_keyValue) {</span> |
| <span class="fc" id="L1858"> throw new ValueNotAllowedException(new ErrorMessage("errors.keyname.TooLong"));</span> |
| } |
| |
| <span class="fc" id="L1861"> }</span> |
| |
| private void validateDescriptions(List<Description> description) throws ValueNotAllowedException { |
| <span class="fc bfc" id="L1864" title="All 2 branches covered."> for (int i = 0; i < description.size(); i++) {</span> |
| <span class="pc bpc" id="L1865" title="1 of 2 branches missed."> if (description.get(i).getValue() == null) {</span> |
| <span class="nc" id="L1866"> throw new ValueNotAllowedException(new ErrorMessage("errors.contact.EmptyDescription"));</span> |
| } |
| |
| <span class="fc" id="L1869"> validateLang(description.get(i).getLang());</span> |
| <span class="fc" id="L1870"> validateDescription(description.get(i).getValue());</span> |
| } |
| <span class="fc" id="L1872"> }</span> |
| |
| private void validateOverviewURL(OverviewURL overviewURL) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1875" title="1 of 2 branches missed."> if (overviewURL != null) {</span> |
| <span class="fc" id="L1876"> validateUseType(overviewURL.getUseType());</span> |
| <span class="fc" id="L1877"> validateURL(overviewURL.getValue());</span> |
| } |
| <span class="fc" id="L1879"> }</span> |
| |
| private void validateURL(String value) throws ValueNotAllowedException { |
| <span class="pc bpc" id="L1882" title="1 of 4 branches missed."> if (value != null && value.length() > ValidationConstants.MAX_overviewURL) {</span> |
| <span class="fc" id="L1883"> throw new ValueNotAllowedException(new ErrorMessage("errors.url.overviewTooLong"));</span> |
| } |
| <span class="fc" id="L1885"> }</span> |
| |
| /** |
| * Validates that a tmodel key is registered Alex O'Ree |
| * |
| * @param tmodelKey |
| * @param em |
| * @throws ValueNotAllowedException |
| * @see org.apache.juddi.config.Install |
| * @since 3.1.5 |
| */ |
| private boolean verifyTModelKeyExistsAndChecked(String tmodelKey, Configuration config) throws ValueNotAllowedException { |
| <span class="fc" id="L1897"> boolean checked = true;</span> |
| <span class="pc bpc" id="L1898" title="2 of 4 branches missed."> if (tmodelKey == null || tmodelKey.length() == 0) {</span> |
| <span class="nc" id="L1899"> return false;</span> |
| } |
| <span class="fc bfc" id="L1901" title="All 2 branches covered."> if (tmodelKey.equalsIgnoreCase("uddi:uddi.org:categorization:types")) {</span> |
| <span class="fc" id="L1902"> return false;</span> |
| } |
| <span class="pc bpc" id="L1904" title="1 of 2 branches missed."> if (tmodelKey.equalsIgnoreCase("uddi:uddi.org:categorization:nodes")) {</span> |
| <span class="nc" id="L1905"> return false;</span> |
| } |
| <span class="pc bpc" id="L1907" title="1 of 2 branches missed."> if (tmodelKey.equalsIgnoreCase("uddi:uddi.org:v3_inquiry")) {</span> |
| <span class="nc" id="L1908"> return false;</span> |
| } |
| <span class="pc bpc" id="L1910" title="1 of 2 branches missed."> if (tmodelKey.equalsIgnoreCase("uddi:uddi.org:v3_publication")) {</span> |
| <span class="nc" id="L1911"> return false;</span> |
| } |
| <span class="pc bpc" id="L1913" title="1 of 2 branches missed."> if (tmodelKey.equalsIgnoreCase("uddi:uddi.org:v3_security")) {</span> |
| <span class="nc" id="L1914"> return false;</span> |
| } |
| <span class="pc bpc" id="L1916" title="1 of 2 branches missed."> if (tmodelKey.equalsIgnoreCase("uddi:uddi.org:v3_ownership_transfer")) {</span> |
| <span class="nc" id="L1917"> return false;</span> |
| } |
| <span class="pc bpc" id="L1919" title="1 of 2 branches missed."> if (tmodelKey.equalsIgnoreCase("uddi:uddi.org:v3_subscription")) {</span> |
| <span class="nc" id="L1920"> return false;</span> |
| } |
| <span class="pc bpc" id="L1922" title="1 of 2 branches missed."> if (tmodelKey.equalsIgnoreCase("uddi:uddi.org:v3_subscriptionlistener")) {</span> |
| <span class="nc" id="L1923"> return false;</span> |
| } |
| |
| <span class="pc bpc" id="L1926" title="1 of 2 branches missed."> if (config == null) {</span> |
| <span class="nc" id="L1927"> log.warn(new ErrorMessage("errors.tmodel.ReferentialIntegrityNullConfig"));</span> |
| <span class="nc" id="L1928"> return false;</span> |
| } |
| <span class="fc" id="L1930"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L1932"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L1933"> } catch (Exception ex) {</span> |
| <span class="nc" id="L1934"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L1935"> }</span> |
| <span class="pc bpc" id="L1936" title="1 of 2 branches missed."> if (checkRef) {</span> |
| <span class="pc bpc" id="L1937" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> |
| <span class="nc" id="L1938"> log.debug("verifyTModelKeyExists " + tmodelKey);</span> |
| } |
| <span class="fc" id="L1940"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| |
| <span class="pc bpc" id="L1942" title="1 of 2 branches missed."> if (em == null) {</span> |
| //this is normally the Install class firing up |
| <span class="nc" id="L1944"> log.warn(new ErrorMessage("errors.tmodel.ReferentialIntegrityNullEM"));</span> |
| } else { |
| //Collections.sort(buildInTmodels); |
| //if ((buildInTmodels, tmodelKey) == -1) |
| <span class="fc" id="L1948"> Tmodel modelTModel = null;</span> |
| { |
| <span class="fc" id="L1950"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| |
| <span class="fc" id="L1953"> tx.begin();</span> |
| <span class="fc" id="L1954"> modelTModel = em.find(org.apache.juddi.model.Tmodel.class, tmodelKey);</span> |
| |
| <span class="pc bpc" id="L1956" title="1 of 2 branches missed."> if (modelTModel == null) {</span> |
| <span class="nc" id="L1957"> checked = false;</span> |
| } else { |
| <span class="pc bpc" id="L1959" title="1 of 2 branches missed."> if (modelTModel.getCategoryBag()!=null)</span> |
| <span class="fc bfc" id="L1960" title="All 2 branches covered."> for (org.apache.juddi.model.KeyedReference ref : modelTModel.getCategoryBag().getKeyedReferences()) {</span> |
| <span class="fc bfc" id="L1961" title="All 2 branches covered."> if ("uddi-org:types:unchecked".equalsIgnoreCase(ref.getKeyName())) {</span> |
| <span class="fc" id="L1962"> checked = false;</span> |
| <span class="fc" id="L1963"> break;</span> |
| } |
| <span class="fc" id="L1965"> }</span> |
| } |
| |
| <span class="fc" id="L1968"> tx.commit();</span> |
| |
| } finally { |
| <span class="pc bpc" id="L1971" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L1972"> tx.rollback();</span> |
| } |
| <span class="pc" id="L1974"> em.close();</span> |
| <span class="fc" id="L1975"> }</span> |
| <span class="pc bpc" id="L1976" title="1 of 2 branches missed."> if (modelTModel == null) {</span> |
| <span class="nc" id="L1977"> throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.ReferencedKeyDoesNotExist", tmodelKey));</span> |
| } |
| } |
| } |
| } |
| <span class="fc" id="L1982"> return checked;</span> |
| } |
| |
| private boolean verifyTModelKeyChecked(Tmodel modelTModel) { |
| <span class="nc" id="L1986"> boolean checked = true;</span> |
| <span class="nc bnc" id="L1987" title="All 2 branches missed."> if (modelTModel == null) {</span> |
| <span class="nc" id="L1988"> checked = false;</span> |
| } else { |
| <span class="nc bnc" id="L1990" title="All 2 branches missed."> for (org.apache.juddi.model.KeyedReference ref : modelTModel.getCategoryBag().getKeyedReferences()) {</span> |
| <span class="nc bnc" id="L1991" title="All 2 branches missed."> if ("uddi-org:types:unchecked".equalsIgnoreCase(ref.getTmodelKeyRef())) {</span> |
| <span class="nc" id="L1992"> checked = false;</span> |
| <span class="nc" id="L1993"> break;</span> |
| } |
| <span class="nc" id="L1995"> }</span> |
| } |
| <span class="nc" id="L1997"> return checked;</span> |
| } |
| |
| /** |
| * throws if it doesn't exist, returns it if it does |
| * |
| * @param tmodelKey |
| * @return null, or a TModel object |
| * @throws ValueNotAllowedException |
| * @since 3.3 |
| */ |
| private TModel verifyTModelKeyExists(String tmodelKey) throws ValueNotAllowedException, DispositionReportFaultMessage { |
| <span class="fc" id="L2009"> TModel api = null;</span> |
| <span class="fc" id="L2010"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L2011"> boolean found = false;</span> |
| <span class="pc bpc" id="L2012" title="1 of 2 branches missed."> if (em == null) {</span> |
| <span class="nc" id="L2013"> log.warn(new ErrorMessage("errors.tmodel.ReferentialIntegrityNullEM"));</span> |
| } else { |
| <span class="fc" id="L2015"> Tmodel modelTModel = null;</span> |
| { |
| <span class="fc" id="L2017"> EntityTransaction tx = em.getTransaction();</span> |
| try { |
| |
| <span class="fc" id="L2020"> tx.begin();</span> |
| <span class="fc" id="L2021"> modelTModel = em.find(org.apache.juddi.model.Tmodel.class, tmodelKey);</span> |
| |
| <span class="pc bpc" id="L2023" title="1 of 2 branches missed."> if (modelTModel != null) {</span> |
| <span class="fc" id="L2024"> found = true;</span> |
| <span class="fc" id="L2025"> api = new TModel();</span> |
| <span class="fc" id="L2026"> MappingModelToApi.mapTModel(modelTModel, api);</span> |
| } |
| <span class="fc" id="L2028"> tx.commit();</span> |
| |
| } finally { |
| <span class="pc bpc" id="L2031" title="3 of 4 branches missed."> if (tx.isActive()) {</span> |
| <span class="nc" id="L2032"> tx.rollback();</span> |
| } |
| <span class="pc" id="L2034"> em.close();</span> |
| <span class="fc" id="L2035"> }</span> |
| |
| } |
| } |
| <span class="pc bpc" id="L2039" title="1 of 2 branches missed."> if (!found) {</span> |
| <span class="nc" id="L2040"> throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.ReferencedKeyDoesNotExist", tmodelKey));</span> |
| } |
| <span class="fc" id="L2042"> return api;</span> |
| } |
| |
| private List<String> GetBindingKeysCheckedTModelKeyedReferenceBT(Map<String, TModel> cache, List<BindingTemplate> obj) { |
| <span class="fc" id="L2046"> List<String> ret = new ArrayList<String>();</span> |
| |
| <span class="pc bpc" id="L2048" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L2049"> return ret;</span> |
| } |
| <span class="fc bfc" id="L2051" title="All 2 branches covered."> for (BindingTemplate bt : obj) {</span> |
| <span class="fc bfc" id="L2052" title="All 2 branches covered."> if (bt.getCategoryBag() != null) {</span> |
| <span class="fc bfc" id="L2053" title="All 2 branches covered."> for (int i = 0; i < bt.getCategoryBag().getKeyedReference().size(); i++) {</span> |
| <span class="fc" id="L2054"> ret.addAll(GetBindingKeysCheckedTModelKeyedReference(cache, bt.getCategoryBag().getKeyedReference().get(i)));</span> |
| } |
| } |
| <span class="fc" id="L2057"> }</span> |
| |
| <span class="fc" id="L2059"> return ret;</span> |
| } |
| |
| private List<String> GetBindingKeysCheckedTModelKeyedReferenceBS(Map<String, TModel> cache, List<BusinessService> obj) { |
| <span class="fc" id="L2063"> List<String> ret = new ArrayList<String>();</span> |
| |
| <span class="pc bpc" id="L2065" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L2066"> return ret;</span> |
| } |
| <span class="fc bfc" id="L2068" title="All 2 branches covered."> for (BusinessService bt : obj) {</span> |
| <span class="fc bfc" id="L2069" title="All 2 branches covered."> if (bt.getCategoryBag() != null) {</span> |
| <span class="fc bfc" id="L2070" title="All 2 branches covered."> for (int i = 0; i < bt.getCategoryBag().getKeyedReference().size(); i++) {</span> |
| <span class="fc" id="L2071"> ret.addAll(GetBindingKeysCheckedTModelKeyedReference(cache, bt.getCategoryBag().getKeyedReference().get(i)));</span> |
| } |
| } |
| <span class="fc bfc" id="L2074" title="All 2 branches covered."> if (bt.getBindingTemplates() != null) {</span> |
| <span class="fc" id="L2075"> ret.addAll(GetBindingKeysCheckedTModelKeyedReferenceBT(cache, bt.getBindingTemplates().getBindingTemplate()));</span> |
| } |
| <span class="fc" id="L2077"> }</span> |
| |
| <span class="fc" id="L2079"> return ret;</span> |
| } |
| |
| private List<String> GetBindingKeysCheckedTModelKeyedReferenceBE(Map<String, TModel> cache, List<BusinessEntity> obj) { |
| <span class="fc" id="L2083"> List<String> ret = new ArrayList<String>();</span> |
| |
| <span class="pc bpc" id="L2085" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L2086"> return ret;</span> |
| } |
| <span class="fc bfc" id="L2088" title="All 2 branches covered."> for (BusinessEntity bt : obj) {</span> |
| <span class="fc bfc" id="L2089" title="All 2 branches covered."> if (bt.getCategoryBag() != null) {</span> |
| <span class="fc bfc" id="L2090" title="All 2 branches covered."> for (int i = 0; i < bt.getCategoryBag().getKeyedReference().size(); i++) {</span> |
| <span class="fc" id="L2091"> ret.addAll(GetBindingKeysCheckedTModelKeyedReference(cache, bt.getCategoryBag().getKeyedReference().get(i)));</span> |
| } |
| } |
| <span class="fc bfc" id="L2094" title="All 2 branches covered."> if (bt.getIdentifierBag() != null) {</span> |
| <span class="fc bfc" id="L2095" title="All 2 branches covered."> for (int i = 0; i < bt.getIdentifierBag().getKeyedReference().size(); i++) {</span> |
| <span class="fc" id="L2096"> ret.addAll(GetBindingKeysCheckedTModelKeyedReference(cache, bt.getIdentifierBag().getKeyedReference().get(i)));</span> |
| } |
| } |
| |
| <span class="fc bfc" id="L2100" title="All 2 branches covered."> if (bt.getBusinessServices() != null) {</span> |
| <span class="fc" id="L2101"> ret.addAll(GetBindingKeysCheckedTModelKeyedReferenceBS(cache, bt.getBusinessServices().getBusinessService()));</span> |
| } |
| <span class="fc" id="L2103"> }</span> |
| <span class="fc" id="L2104"> return ret;</span> |
| } |
| |
| private List<String> GetBindingKeysCheckedTModelKeyedReferenceTM(Map<String, TModel> cache, List<TModel> obj) { |
| <span class="fc" id="L2108"> List<String> ret = new ArrayList<String>();</span> |
| |
| <span class="pc bpc" id="L2110" title="1 of 2 branches missed."> if (obj == null) {</span> |
| <span class="nc" id="L2111"> return ret;</span> |
| } |
| <span class="fc bfc" id="L2113" title="All 2 branches covered."> for (TModel bt : obj) {</span> |
| <span class="fc bfc" id="L2114" title="All 2 branches covered."> if (bt.getCategoryBag() != null) {</span> |
| <span class="fc bfc" id="L2115" title="All 2 branches covered."> for (int i = 0; i < bt.getCategoryBag().getKeyedReference().size(); i++) {</span> |
| <span class="fc" id="L2116"> ret.addAll(GetBindingKeysCheckedTModelKeyedReference(cache, bt.getCategoryBag().getKeyedReference().get(i)));</span> |
| } |
| } |
| <span class="fc bfc" id="L2119" title="All 2 branches covered."> if (bt.getIdentifierBag() != null) {</span> |
| <span class="fc bfc" id="L2120" title="All 2 branches covered."> for (int i = 0; i < bt.getIdentifierBag().getKeyedReference().size(); i++) {</span> |
| <span class="fc" id="L2121"> ret.addAll(GetBindingKeysCheckedTModelKeyedReference(cache, bt.getIdentifierBag().getKeyedReference().get(i)));</span> |
| } |
| } |
| <span class="fc" id="L2124"> }</span> |
| <span class="fc" id="L2125"> return ret;</span> |
| } |
| |
| /** |
| * this should return a list of binding keys, only if the referenced kr |
| * contains is validated by |
| * |
| * @param cache |
| * @param get |
| * @return |
| */ |
| private List<String> GetBindingKeysCheckedTModelKeyedReference(Map<String, TModel> cache, KeyedReference get) { |
| <span class="fc" id="L2137"> List<String> ret = new ArrayList<String>();</span> |
| <span class="fc" id="L2138"> TModel ref = null;</span> |
| <span class="fc" id="L2139"> log.debug("looking for is validated by for keyedref " + get.getTModelKey());</span> |
| <span class="fc bfc" id="L2140" title="All 2 branches covered."> if (cache.containsKey(get.getTModelKey())) {</span> |
| <span class="fc" id="L2141"> ref = cache.get(get.getTModelKey());</span> |
| } |
| <span class="fc bfc" id="L2143" title="All 2 branches covered."> if (ref == null) {</span> |
| try { |
| <span class="fc" id="L2145"> ref = verifyTModelKeyExists(get.getTModelKey());</span> |
| <span class="fc" id="L2146"> cache.put(get.getTModelKey(), ref);</span> |
| <span class="nc" id="L2147"> } catch (Exception ex) {</span> |
| <span class="nc" id="L2148"> log.error("unexpected error loading tmodel " + get.getTModelKey(), ex);</span> |
| <span class="fc" id="L2149"> }</span> |
| } |
| <span class="pc bpc" id="L2151" title="1 of 2 branches missed."> if (ref != null) {</span> |
| |
| <span class="fc" id="L2153"> ret.addAll(TModelContains(UDDIConstants.IS_VALIDATED_BY, ref));</span> |
| <span class="fc" id="L2154"> ret.addAll(TModelContains(UDDIConstantsV2.IS_VALIDATED_BY, ref));</span> |
| |
| } |
| <span class="fc" id="L2157"> return ret;</span> |
| } |
| |
| /** |
| * returns all keyvalues from ref.catbag and identbag where the tmodel |
| * key matches |
| * |
| * @param key |
| * @param ref |
| * @return |
| */ |
| private List<String> TModelContains(String key, TModel ref) { |
| |
| <span class="pc bpc" id="L2170" title="1 of 2 branches missed."> if (key == null) {</span> |
| <span class="nc" id="L2171"> return null;</span> |
| } |
| <span class="pc bpc" id="L2173" title="2 of 4 branches missed."> if (ref == null || ref.getTModelKey()==null) {</span> |
| <span class="nc" id="L2174"> return null;</span> |
| } |
| <span class="fc" id="L2176"> log.debug("looking for key=" + key + " from tModel " + ref.getTModelKey());</span> |
| <span class="fc" id="L2177"> List<String> ret = new ArrayList<String>();</span> |
| |
| <span class="fc bfc" id="L2179" title="All 2 branches covered."> if (ref.getCategoryBag() != null) {</span> |
| <span class="fc bfc" id="L2180" title="All 2 branches covered."> for (int i = 0; i < ref.getCategoryBag().getKeyedReference().size(); i++) {</span> |
| <span class="fc bfc" id="L2181" title="All 2 branches covered."> if (ref.getCategoryBag().getKeyedReference().get(i).getTModelKey().equalsIgnoreCase(key)) {</span> |
| <span class="fc" id="L2182"> log.debug("found reference for key=" + key + " from tModel " + ref.getTModelKey() + " validation endpoint " + ref.getCategoryBag().getKeyedReference().get(i).getKeyValue());</span> |
| <span class="fc" id="L2183"> ret.add(ref.getCategoryBag().getKeyedReference().get(i).getKeyValue());</span> |
| } |
| } |
| <span class="pc bpc" id="L2186" title="1 of 2 branches missed."> for (int i = 0; i < ref.getCategoryBag().getKeyedReferenceGroup().size(); i++) {</span> |
| <span class="nc bnc" id="L2187" title="All 2 branches missed."> for (int k = 0; k < ref.getCategoryBag().getKeyedReferenceGroup().get(i).getKeyedReference().size(); k++) {</span> |
| <span class="nc bnc" id="L2188" title="All 2 branches missed."> if (ref.getCategoryBag().getKeyedReferenceGroup().get(i).getKeyedReference().get(k).getTModelKey().equalsIgnoreCase(key)) {</span> |
| <span class="nc" id="L2189"> log.debug("found reference for key=" + key + " from tModel " + ref.getTModelKey() + " validation endpoint " + ref.getCategoryBag().getKeyedReferenceGroup().get(i).getKeyedReference().get(k).getKeyValue());</span> |
| <span class="nc" id="L2190"> ret.add(ref.getCategoryBag().getKeyedReferenceGroup().get(i).getKeyedReference().get(k).getKeyValue());</span> |
| } |
| } |
| } |
| } |
| <span class="pc bpc" id="L2195" title="1 of 2 branches missed."> if (ref.getIdentifierBag() != null) {</span> |
| <span class="nc bnc" id="L2196" title="All 2 branches missed."> for (int i = 0; i < ref.getIdentifierBag().getKeyedReference().size(); i++) {</span> |
| <span class="nc bnc" id="L2197" title="All 2 branches missed."> if (ref.getIdentifierBag().getKeyedReference().get(i).getTModelKey().equalsIgnoreCase(key)) {</span> |
| <span class="nc" id="L2198"> log.debug("found reference for key=" + key + " from tModel " + ref.getTModelKey() + " validation endpoint " + ref.getIdentifierBag().getKeyedReference().get(i).getKeyValue());</span> |
| <span class="nc" id="L2199"> ret.add(ref.getIdentifierBag().getKeyedReference().get(i).getKeyValue());</span> |
| } |
| } |
| } |
| <span class="fc" id="L2203"> return ret;</span> |
| } |
| |
| /** |
| * JUDDI-849 Each addressLine element MAY be adorned with two optional |
| * descriptive attributes, keyName and keyValue. Both attributes MUST be |
| * present in each address line if a tModelKey is specified in the |
| * address structure. When no tModelKey is provided for the address |
| * structure, the keyName and keyValue attributes have no defined |
| * meaning. |
| * |
| * @param addressLine |
| */ |
| private void validatedAddressLinesIfKeyDefined(List<AddressLine> addressLine) throws ValueNotAllowedException { |
| <span class="fc" id="L2217"> StringBuilder err = new StringBuilder();</span> |
| <span class="fc bfc" id="L2218" title="All 2 branches covered."> for (int i = 0; i < addressLine.size(); i++) {</span> |
| |
| <span class="pc bpc" id="L2220" title="1 of 2 branches missed."> if (addressLine.get(i).getKeyName() == null</span> |
| <span class="pc bpc" id="L2221" title="1 of 2 branches missed."> || addressLine.get(i).getKeyName().trim().length() == 0) {</span> |
| <span class="nc" id="L2222"> err.append("addressLine(").append(i).append(").keyName,");</span> |
| } |
| <span class="pc bpc" id="L2224" title="1 of 2 branches missed."> if (addressLine.get(i).getKeyValue() == null</span> |
| <span class="pc bpc" id="L2225" title="1 of 2 branches missed."> || addressLine.get(i).getKeyValue().trim().length() == 0) {</span> |
| <span class="nc" id="L2226"> err.append("addressLine(").append(i).append(").keyValue,");</span> |
| } |
| <span class="pc bpc" id="L2228" title="1 of 2 branches missed."> if (addressLine.get(i).getValue() == null</span> |
| <span class="pc bpc" id="L2229" title="1 of 2 branches missed."> || addressLine.get(i).getValue().trim().length() == 0) {</span> |
| <span class="nc" id="L2230"> err.append("addressLine(").append(i).append(").value,");</span> |
| } |
| } |
| <span class="pc bpc" id="L2233" title="1 of 2 branches missed."> if (err.length() > 0) {</span> |
| <span class="nc" id="L2234"> throw new ValueNotAllowedException(new ErrorMessage("E_invalidValueAddressLine", err.toString()));</span> |
| } |
| <span class="fc" id="L2236"> }</span> |
| |
| private void validateCheckedTModelsBT(List<BindingTemplate> bindingTemplate, Configuration config) throws ValueNotAllowedException { |
| |
| <span class="fc" id="L2240"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L2242"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L2243"> } catch (Exception ex) {</span> |
| <span class="nc" id="L2244"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L2245"> }</span> |
| |
| <span class="pc bpc" id="L2247" title="1 of 2 branches missed."> if (!checkRef) {</span> |
| <span class="nc" id="L2248"> return;</span> |
| } |
| <span class="fc" id="L2250"> Map<String, TModel> cache = new HashMap<String, TModel>();</span> |
| <span class="fc" id="L2251"> List<String> bindings = GetBindingKeysCheckedTModelKeyedReferenceBT(cache, bindingTemplate);</span> |
| |
| <span class="pc bpc" id="L2253" title="1 of 2 branches missed."> if (!bindings.isEmpty()) {</span> |
| //get a unique list |
| <span class="fc" id="L2255"> bindings = new ArrayList(new HashSet(bindings));</span> |
| <span class="fc bfc" id="L2256" title="All 2 branches covered."> for (int i = 0; i < bindings.size(); i++) {</span> |
| //load binding from database |
| <span class="fc" id="L2258"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L2259"> org.apache.juddi.model.BindingTemplate find = em.find(org.apache.juddi.model.BindingTemplate.class, bindings.get(i));</span> |
| <span class="pc bpc" id="L2260" title="1 of 2 branches missed."> if (find != null) {</span> |
| //parse endpoint |
| <span class="fc" id="L2262"> String url = find.getAccessPointUrl();</span> |
| <span class="pc bpc" id="L2263" title="1 of 2 branches missed."> if (url == null) {</span> |
| <span class="nc" id="L2264"> url = find.getHostingRedirector();</span> |
| } |
| <span class="pc bpc" id="L2266" title="1 of 2 branches missed."> if (url != null) {</span> |
| //call ValidateValuesFromWebService |
| //optimization for localhost? |
| <span class="fc" id="L2269"> ValidateValuesFromWebService.ValidateBinding(Rectify(url, config), bindingTemplate);</span> |
| } |
| |
| } |
| } |
| } |
| <span class="fc" id="L2275"> }</span> |
| |
| private void validateCheckedTModelsBS(List<BusinessService> bizlist, Configuration config) throws ValueNotAllowedException { |
| <span class="fc" id="L2278"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L2280"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L2281"> } catch (Exception ex) {</span> |
| <span class="nc" id="L2282"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L2283"> }</span> |
| <span class="pc bpc" id="L2284" title="1 of 2 branches missed."> if (!checkRef) {</span> |
| <span class="nc" id="L2285"> return;</span> |
| } |
| <span class="fc" id="L2287"> Map<String, TModel> cache = new HashMap<String, TModel>();</span> |
| <span class="fc" id="L2288"> List<String> bindings = GetBindingKeysCheckedTModelKeyedReferenceBS(cache, bizlist);</span> |
| |
| <span class="pc bpc" id="L2290" title="1 of 2 branches missed."> if (!bindings.isEmpty()) {</span> |
| //get a unique list |
| <span class="nc" id="L2292"> bindings = new ArrayList(new HashSet(bindings));</span> |
| <span class="nc bnc" id="L2293" title="All 2 branches missed."> for (int i = 0; i < bindings.size(); i++) {</span> |
| //load binding from database |
| <span class="nc" id="L2295"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="nc" id="L2296"> org.apache.juddi.model.BindingTemplate find = em.find(org.apache.juddi.model.BindingTemplate.class, bindings.get(i));</span> |
| <span class="nc bnc" id="L2297" title="All 2 branches missed."> if (find != null) {</span> |
| //parse endpoint |
| <span class="nc" id="L2299"> String url = find.getAccessPointUrl();</span> |
| <span class="nc bnc" id="L2300" title="All 2 branches missed."> if (url == null) {</span> |
| <span class="nc" id="L2301"> url = find.getHostingRedirector();</span> |
| } |
| <span class="nc bnc" id="L2303" title="All 2 branches missed."> if (url != null) {</span> |
| //call ValidateValuesFromWebService |
| //optimization for localhost? |
| <span class="nc" id="L2306"> ValidateValuesFromWebService.ValidateService(Rectify(url, config), bizlist);</span> |
| } |
| |
| } |
| } |
| } |
| <span class="fc" id="L2312"> }</span> |
| |
| private void validateCheckedTModelsBE(List<BusinessEntity> entity, Configuration config) throws ValueNotAllowedException { |
| <span class="fc" id="L2315"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L2317"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L2318"> } catch (Exception ex) {</span> |
| <span class="nc" id="L2319"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L2320"> }</span> |
| <span class="pc bpc" id="L2321" title="1 of 2 branches missed."> if (!checkRef) {</span> |
| <span class="nc" id="L2322"> return;</span> |
| } |
| <span class="fc" id="L2324"> Map<String, TModel> cache = new HashMap<String, TModel>();</span> |
| <span class="fc" id="L2325"> List<String> bindings = GetBindingKeysCheckedTModelKeyedReferenceBE(cache, entity);</span> |
| |
| <span class="fc bfc" id="L2327" title="All 2 branches covered."> if (!bindings.isEmpty()) {</span> |
| //get a unique list |
| <span class="fc" id="L2329"> bindings = new ArrayList(new HashSet(bindings));</span> |
| <span class="fc bfc" id="L2330" title="All 2 branches covered."> for (int i = 0; i < bindings.size(); i++) {</span> |
| //load binding from database |
| <span class="fc" id="L2332"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L2333"> org.apache.juddi.model.BindingTemplate find = em.find(org.apache.juddi.model.BindingTemplate.class, bindings.get(i));</span> |
| <span class="pc bpc" id="L2334" title="1 of 2 branches missed."> if (find != null) {</span> |
| //parse endpoint |
| <span class="fc" id="L2336"> String url = find.getAccessPointUrl();</span> |
| <span class="pc bpc" id="L2337" title="1 of 2 branches missed."> if (url == null) {</span> |
| <span class="nc" id="L2338"> url = find.getHostingRedirector();</span> |
| } |
| <span class="pc bpc" id="L2340" title="1 of 2 branches missed."> if (url != null) {</span> |
| //call ValidateValuesFromWebService |
| //optimization for localhost? |
| <span class="fc" id="L2343"> ValidateValuesFromWebService.ValidateBusiness(Rectify(url, config), entity);</span> |
| } |
| |
| } |
| } |
| } |
| <span class="fc" id="L2349"> }</span> |
| |
| private void validateCheckedTModelsTM(List<TModel> entity, Configuration config) throws ValueNotAllowedException { |
| <span class="fc" id="L2352"> boolean checkRef = false;</span> |
| try { |
| <span class="fc" id="L2354"> checkRef = config.getBoolean(Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY, false);</span> |
| <span class="nc" id="L2355"> } catch (Exception ex) {</span> |
| <span class="nc" id="L2356"> log.warn("Error caught reading " + Property.JUDDI_ENFORCE_REFERENTIAL_INTEGRITY + " from config file", ex);</span> |
| <span class="fc" id="L2357"> }</span> |
| <span class="pc bpc" id="L2358" title="1 of 2 branches missed."> if (!checkRef) {</span> |
| <span class="nc" id="L2359"> return;</span> |
| } |
| <span class="fc" id="L2361"> Map<String, TModel> cache = new HashMap<String, TModel>();</span> |
| <span class="fc" id="L2362"> List<String> bindings = GetBindingKeysCheckedTModelKeyedReferenceTM(cache, entity);</span> |
| |
| <span class="fc bfc" id="L2364" title="All 2 branches covered."> if (!bindings.isEmpty()) {</span> |
| //get a unique list |
| <span class="fc" id="L2366"> bindings = new ArrayList(new HashSet(bindings));</span> |
| <span class="fc bfc" id="L2367" title="All 2 branches covered."> for (int i = 0; i < bindings.size(); i++) {</span> |
| //load binding from database |
| <span class="fc" id="L2369"> EntityManager em = PersistenceManager.getEntityManager();</span> |
| <span class="fc" id="L2370"> org.apache.juddi.model.BindingTemplate find = em.find(org.apache.juddi.model.BindingTemplate.class, bindings.get(i));</span> |
| <span class="pc bpc" id="L2371" title="1 of 2 branches missed."> if (find != null) {</span> |
| //parse endpoint |
| <span class="fc" id="L2373"> String url = find.getAccessPointUrl();</span> |
| <span class="pc bpc" id="L2374" title="1 of 2 branches missed."> if (url == null) {</span> |
| <span class="nc" id="L2375"> url = find.getHostingRedirector();</span> |
| } |
| <span class="pc bpc" id="L2377" title="1 of 2 branches missed."> if (url != null) {</span> |
| <span class="fc" id="L2378"> log.debug("attempting vsv from " + url);</span> |
| //call ValidateValuesFromWebService |
| //optimization for localhost? |
| <span class="fc" id="L2381"> ValidateValuesFromWebService.ValidateTModel(Rectify(url, config), entity);</span> |
| } |
| |
| } |
| } |
| } |
| <span class="fc" id="L2387"> }</span> |
| |
| private String Rectify(String url, Configuration config) { |
| //${juddi.server.baseurl} |
| <span class="fc" id="L2391"> Properties p = new Properties();</span> |
| <span class="fc" id="L2392"> p.put("juddi.server.baseurl", config.getString("juddi.server.baseurl", Property.DEFAULT_BASE_URL));</span> |
| |
| <span class="fc" id="L2394"> return TokenResolver.replaceTokens(url, p);</span> |
| } |
| |
| public void validateDeleteNode(EntityManager em, DeleteNode nodeID, ReplicationConfiguration cfg) throws DispositionReportFaultMessage { |
| <span class="pc bpc" id="L2398" title="1 of 2 branches missed."> if (nodeID == null) {</span> |
| <span class="nc" id="L2399"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteClerk.NoInput"));</span> |
| } |
| <span class="pc bpc" id="L2401" title="1 of 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L2402"> throw new UserMismatchException(new ErrorMessage("errors.deletepublisher.AdminReqd"));</span> |
| } |
| <span class="pc bpc" id="L2404" title="2 of 4 branches missed."> if (nodeID.getNodeID() == null || nodeID.getNodeID().trim().equalsIgnoreCase("")) {</span> |
| <span class="nc" id="L2405"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteNode.NoInput"));</span> |
| } |
| //get the latest replication config |
| <span class="pc bpc" id="L2408" title="1 of 2 branches missed."> if (cfg != null) {</span> |
| <span class="pc bpc" id="L2409" title="1 of 2 branches missed."> if (cfg.getCommunicationGraph() != null) {</span> |
| <span class="fc bfc" id="L2410" title="All 2 branches covered."> for (String node : cfg.getCommunicationGraph().getNode()) {</span> |
| <span class="pc bpc" id="L2411" title="1 of 2 branches missed."> if (node.equals(nodeID.getNodeID())) {</span> |
| <span class="nc" id="L2412"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteNode.InReplicationConfig", nodeID.getNodeID()));</span> |
| } |
| <span class="fc" id="L2414"> }</span> |
| <span class="pc bpc" id="L2415" title="1 of 2 branches missed."> for (int i = 0; i < cfg.getCommunicationGraph().getEdge().size(); i++) {</span> |
| <span class="nc bnc" id="L2416" title="All 2 branches missed."> if (nodeID.getNodeID().equals(cfg.getCommunicationGraph().getEdge().get(i).getMessageReceiver())) {</span> |
| <span class="nc" id="L2417"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteNode.InReplicationConfig", nodeID.getNodeID()));</span> |
| } |
| <span class="nc bnc" id="L2419" title="All 2 branches missed."> if (nodeID.getNodeID().equals(cfg.getCommunicationGraph().getEdge().get(i).getMessageSender())) {</span> |
| <span class="nc" id="L2420"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteNode.InReplicationConfig", nodeID.getNodeID()));</span> |
| } |
| |
| } |
| } |
| } |
| |
| <span class="fc" id="L2427"> }</span> |
| |
| public void validateDeleteClerk(EntityManager em, DeleteClerk clerkID) throws DispositionReportFaultMessage { |
| <span class="pc bpc" id="L2430" title="1 of 2 branches missed."> if (clerkID == null) {</span> |
| <span class="nc" id="L2431"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteClerk.NoInput"));</span> |
| } |
| <span class="pc bpc" id="L2433" title="1 of 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L2434"> throw new UserMismatchException(new ErrorMessage("errors.deletepublisher.AdminReqd"));</span> |
| } |
| <span class="pc bpc" id="L2436" title="2 of 4 branches missed."> if (clerkID.getClerkID() == null || clerkID.getClerkID().trim().equalsIgnoreCase("")) {</span> |
| <span class="nc" id="L2437"> throw new InvalidKeyPassedException(new ErrorMessage("errors.deleteClerk.NoInput"));</span> |
| } |
| |
| <span class="fc" id="L2440"> }</span> |
| |
| public void validateGetAllNodes() throws DispositionReportFaultMessage { |
| <span class="pc bpc" id="L2443" title="1 of 2 branches missed."> if (!((Publisher) publisher).isAdmin()) {</span> |
| <span class="nc" id="L2444"> throw new UserMismatchException(new ErrorMessage("errors.deletepublisher.AdminReqd"));</span> |
| } |
| <span class="fc" id="L2446"> }</span> |
| |
| <span class="fc" id="L2448"> private org.apache.juddi.v3.client.cryptor.DigSigUtil ds = null;</span> |
| |
| private synchronized void initDigSig(Configuration config) { |
| <span class="fc bfc" id="L2451" title="All 2 branches covered."> if (ds == null) {</span> |
| |
| <span class="fc" id="L2453"> Properties p = new Properties();</span> |
| /** |
| * <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> |
| */ |
| <span class="fc" id="L2465"> p.put(DigSigUtil.TRUSTSTORE_FILE, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStorePath", ""));</span> |
| <span class="fc" id="L2466"> p.put(DigSigUtil.TRUSTSTORE_FILETYPE, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStoreType", ""));</span> |
| |
| <span class="fc" id="L2468"> String enc = config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStorePassword", "");</span> |
| <span class="pc bpc" id="L2469" title="1 of 2 branches missed."> if (config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStorePassword[@isPasswordEncrypted]", false)) {</span> |
| <span class="nc" id="L2470"> log.debug("trust password is encrypted, decrypting...");</span> |
| |
| <span class="nc" id="L2472"> String prov = config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "trustStorePassword[@cryptoProvider]", "");</span> |
| try { |
| <span class="nc" id="L2474"> p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, CryptorFactory.getCryptor(prov).decrypt(enc));</span> |
| <span class="nc" id="L2475"> } catch (Exception ex) {</span> |
| <span class="nc" id="L2476"> log.warn("unable to decrypt trust store password " + ex.getMessage());</span> |
| <span class="nc" id="L2477"> log.debug("unable to decrypt trust store password " + ex.getMessage(), ex);</span> |
| <span class="nc" id="L2478"> }</span> |
| |
| <span class="pc bpc" id="L2480" title="1 of 2 branches missed."> } else if (!"".equals(enc)){</span> |
| <span class="nc" id="L2481"> log.warn("Hey, you should consider encrypting your trust store password!");</span> |
| <span class="nc" id="L2482"> p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, enc);</span> |
| } |
| |
| <span class="fc" id="L2485"> p.put(DigSigUtil.CHECK_REVOCATION_STATUS_CRL, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "checkRevocationCRL", "true"));</span> |
| <span class="fc" id="L2486"> p.put(DigSigUtil.CHECK_TRUST_CHAIN, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "checkTrust", "true"));</span> |
| <span class="fc" id="L2487"> p.put(DigSigUtil.CHECK_TIMESTAMPS, config.getString(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_PREFIX + "checkTimestamps", "true"));</span> |
| |
| try { |
| <span class="fc" id="L2490"> ds = new DigSigUtil(p);</span> |
| <span class="nc" id="L2491"> } catch (CertificateException ex) {</span> |
| <span class="nc" id="L2492"> log.error("", ex);</span> |
| <span class="fc" id="L2493"> }</span> |
| //System.out.println("loaded from " + AppConfig.getConfigFileURL()); |
| //p.list(System.out); |
| } |
| <span class="fc" id="L2497"> }</span> |
| |
| private void validateSignaturesBinding(BindingTemplate bindingTemplate, Configuration config) throws FatalErrorException { |
| <span class="fc" id="L2500"> boolean shouldcheck = config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_ENABLE, false);</span> |
| <span class="fc" id="L2501"> initDigSig(config);</span> |
| <span class="pc bpc" id="L2502" title="5 of 6 branches missed."> if (shouldcheck && !bindingTemplate.getSignature().isEmpty() && ds != null) {</span> |
| <span class="nc" id="L2503"> AtomicReference<String> outmsg = new AtomicReference<String>();</span> |
| <span class="nc" id="L2504"> boolean ok = ds.verifySignedUddiEntity(bindingTemplate, outmsg);</span> |
| <span class="nc bnc" id="L2505" title="All 2 branches missed."> if (!ok) {</span> |
| <span class="nc" id="L2506"> throw new FatalErrorException(new ErrorMessage("errors.digitalsignature.validationfailure", bindingTemplate.getBindingKey() + " " + outmsg.get()));</span> |
| } |
| |
| } |
| <span class="fc" id="L2510"> }</span> |
| |
| private void validateSignaturesService(BusinessService businessService, Configuration config) throws FatalErrorException { |
| <span class="fc" id="L2513"> boolean shouldcheck = config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_ENABLE, false);</span> |
| <span class="fc" id="L2514"> initDigSig(config);</span> |
| <span class="pc bpc" id="L2515" title="5 of 6 branches missed."> if (shouldcheck && !businessService.getSignature().isEmpty() && ds != null) {</span> |
| <span class="nc" id="L2516"> AtomicReference<String> outmsg = new AtomicReference<String>();</span> |
| <span class="nc" id="L2517"> boolean ok = ds.verifySignedUddiEntity(businessService, outmsg);</span> |
| <span class="nc bnc" id="L2518" title="All 2 branches missed."> if (!ok) {</span> |
| <span class="nc" id="L2519"> throw new FatalErrorException(new ErrorMessage("errors.digitalsignature.validationfailure", businessService.getServiceKey() + " " + outmsg.get()));</span> |
| } |
| |
| } |
| <span class="fc" id="L2523"> }</span> |
| |
| private void validateSignaturesTModel(TModel tModel, Configuration config) throws FatalErrorException { |
| <span class="fc" id="L2526"> boolean shouldcheck = config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_ENABLE, false);</span> |
| <span class="fc" id="L2527"> initDigSig(config);</span> |
| <span class="pc bpc" id="L2528" title="5 of 6 branches missed."> if (shouldcheck && !tModel.getSignature().isEmpty() && ds != null) {</span> |
| <span class="nc" id="L2529"> AtomicReference<String> outmsg = new AtomicReference<String>();</span> |
| <span class="nc" id="L2530"> boolean ok = ds.verifySignedUddiEntity(tModel, outmsg);</span> |
| <span class="nc bnc" id="L2531" title="All 2 branches missed."> if (!ok) {</span> |
| <span class="nc" id="L2532"> throw new FatalErrorException(new ErrorMessage("errors.digitalsignature.validationfailure", tModel.getTModelKey() + " " + outmsg.get()));</span> |
| } |
| |
| } |
| <span class="fc" id="L2536"> }</span> |
| |
| private void validateSignaturesBusiness(BusinessEntity businessEntity, Configuration config) throws FatalErrorException { |
| <span class="fc" id="L2539"> boolean shouldcheck = config.getBoolean(Property.JUDDI_REJECT_ENTITIES_WITH_INVALID_SIG_ENABLE, false);</span> |
| <span class="fc" id="L2540"> initDigSig(config);</span> |
| <span class="pc bpc" id="L2541" title="5 of 6 branches missed."> if (shouldcheck && !businessEntity.getSignature().isEmpty() && ds != null) {</span> |
| <span class="nc" id="L2542"> AtomicReference<String> outmsg = new AtomicReference<String>();</span> |
| <span class="nc" id="L2543"> boolean ok = ds.verifySignedUddiEntity(businessEntity, outmsg);</span> |
| <span class="nc bnc" id="L2544" title="All 2 branches missed."> if (!ok) {</span> |
| <span class="nc" id="L2545"> throw new FatalErrorException(new ErrorMessage("errors.digitalsignature.validationfailure", businessEntity.getBusinessKey() + " " + outmsg.get()));</span> |
| } |
| |
| } |
| <span class="fc" id="L2549"> }</span> |
| |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html> |