@Test()
  public void JUDDI_712_SaveServiceProjectionNoServiceKey2WithSignature()
      throws CertificateException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    Name n = new Name();
    n.setValue("JUDDI_712_SaveServiceProjectionNoServiceKey2WithSignature");
    be.getName().add(n);
    be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);

    BusinessService bs = new BusinessService();
    bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
    bs.setServiceKey(null);
    bs.getName().add(new Name("Joe's bs", null));
    DigSigUtil ds = GetDigSig();
    bs = ds.signUddiEntity(bs);

    be.setBusinessServices(new BusinessServices());
    be.getBusinessServices().getBusinessService().add(bs);

    sb.getBusinessEntity().add(be);
    try {
      BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
      Assert.fail("unexpected success");
    } catch (Exception ex) {
      logger.info("Expected failure: " + ex.getMessage());
    }
  }
  @Test()
  public void JUDDI_712_SaveService2WithSignature() throws CertificateException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    Name n = new Name();
    n.setValue("JUDDI_712_SaveService2WithSignature");
    be.getName().add(n);
    be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
    sb.getBusinessEntity().add(be);
    BusinessDetail saveBusiness = null;
    try {

      saveBusiness = publicationJoe.saveBusiness(sb);
    } catch (Exception ex) {
      logger.info("UnExpected failure: ", ex);
      Assert.fail();
    }

    SaveService ss = new SaveService();
    ss.setAuthInfo(authInfoJoe);
    BusinessService bs = new BusinessService();
    bs.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);
    bs.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
    bs.setBindingTemplates(new BindingTemplates());
    BindingTemplate bt = new BindingTemplate();
    bt.setBindingKey(null);
    bt.setServiceKey(TckBusinessService.JOE_SERVICE_KEY);
    bt.setAccessPoint(new AccessPoint("http://localhost", "wsdl"));
    bs.getBindingTemplates().getBindingTemplate().add(bt);
    bs.getName().add(new Name("Joe's bs", null));
    DigSigUtil ds = GetDigSig();
    bs = ds.signUddiEntity(bs);

    be.setBusinessServices(new BusinessServices());
    be.getBusinessServices().getBusinessService().add(bs);

    sb.getBusinessEntity().add(be);
    try {
      publicationJoe.saveService(ss);
      Assert.fail("unexpected success");
    } catch (Exception ex) {
      logger.info("Expected failure: " + ex.getMessage());
    } finally {
      DeleteBusinesses(
          saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
    }
  }
  public void JUDDI_712_SaveBusinessNoneDefined() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    Name n = new Name();
    n.setValue("JUDDI_712_SaveServiceWithSignature");
    be.getName().add(n);
    be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);

    try {
      BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
      Assert.fail("unexpected success");
    } catch (Exception ex) {
      logger.info("Expected failure: " + ex.getMessage());
      throw ex;
    }
  }
 @Test()
 public void JUDDI_712_SaveBusinessProjectionWithSignature() throws CertificateException {
   Assume.assumeTrue(TckPublisher.isEnabled());
   SaveBusiness sb = new SaveBusiness();
   sb.setAuthInfo(authInfoJoe);
   BusinessEntity be = new BusinessEntity();
   Name n = new Name();
   n.setValue("JUDDI_JUDDI_712_SaveBusinessProjectionWithSignature");
   be.getName().add(n);
   DigSigUtil ds = GetDigSig();
   be = ds.signUddiEntity(be);
   sb.getBusinessEntity().add(be);
   try {
     BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
     Assert.fail("unexpected success");
   } catch (Exception ex) {
     logger.info("Expected failure: " + ex.getMessage());
   }
 }
  // JUDDI-716
  @Test()
  public void JUDDI_716_SaveBusinessAllOptions() throws CertificateException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);

    Name n = new Name();
    n.setValue("JUDDI_716_SaveBusinessAllOptions");
    be.getName().add(n);
    DigSigUtil ds = GetDigSig();
    ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SERIAL, "true");
    ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SUBJECTDN, "true");
    be = ds.signUddiEntity(be);
    sb.getBusinessEntity().add(be);
    BusinessDetail saveBusiness = null;
    try {
      saveBusiness = publicationJoe.saveBusiness(sb);
      GetBusinessDetail gsb = new GetBusinessDetail();
      gsb.setAuthInfo(authInfoJoe);
      gsb.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
      BusinessDetail businessDetail = inquiryJoe.getBusinessDetail(gsb);
      PrintUDDI<BusinessEntity> printer = new PrintUDDI<BusinessEntity>();
      if (TckCommon.isDebug())
        System.out.println(printer.print(businessDetail.getBusinessEntity().get(0)));
      AtomicReference<String> msg = new AtomicReference<String>();
      boolean b = ds.verifySignedUddiEntity(businessDetail.getBusinessEntity().get(0), msg);
      Assert.assertTrue(msg.get(), b);
      Assert.assertTrue(msg.get() == null || msg.get().length() == 0);

    } catch (Exception ex) {
      logger.error("unExpected failure: ", ex);
      Assert.fail("unexpected failure");
    } finally {
      DeleteBusinesses(
          saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
    }
  }
  /**
   * This method loops through the business entities and fills in any pertinent detailed information
   * by calling the UDDI server get_businessDetail function. Note that this information was not
   * available in the find_business. In order to get it we have to do separate call.
   *
   * @param oEntities The businesses to retrieve the detail and the object where the details will be
   *     placed.
   */
  private void retrieveDetailedBusinessInfoFromUDDI(CMBusinessEntities oEntities)
      throws UDDIAccessorException {
    if ((oEntities == null)
        || (oEntities.getBusinessEntity() == null)
        || (oEntities.getBusinessEntity().size() <= 0)) {
      return; // we are done  there is nothing to retrieve.
    }

    BusinessDetail oResult = null;

    try {
      GetBusinessDetail oSearchParams = new GetBusinessDetail();

      // Load up the list of keys to retrieve the details of...
      // --------------------------------------------------------
      for (CMBusinessEntity oEntity : oEntities.getBusinessEntity()) {
        if ((oEntity.getBusinessKey() != null) && (oEntity.getBusinessKey().length() > 0)) {
          oSearchParams.getBusinessKey().add(oEntity.getBusinessKey());
        }
      } // for (CMBusinessEntity oEntity : oEntities.getBusinessEntity())

      UDDIInquiryPortType oPort = getUDDIInquiryWebService();
      oResult = oPort.getBusinessDetail(oSearchParams);
    } catch (Exception e) {
      String sErrorMessage =
          "Failed to call UDDI web service get_businessDetail method.  Error: " + e.getMessage();
      log.error(sErrorMessage, e);
      throw new UDDIAccessorException(sErrorMessage, e);
    }

    // Now let's process the results...
    // ---------------------------------
    if ((oResult != null)
        && (oResult.getBusinessEntity() != null)
        && (oResult.getBusinessEntity().size() > 0)) {
      // Now put the returned information back into our structure.
      // -----------------------------------------------------------
      for (BusinessEntity oUDDIEntity : oResult.getBusinessEntity()) {
        if ((oUDDIEntity.getBusinessKey() != null) && (oUDDIEntity.getBusinessKey().length() > 0)) {
          CMBusinessEntity oEntity =
              findSpecificBusiness(oEntities.getBusinessEntity(), oUDDIEntity.getBusinessKey());

          if (oEntity != null) {
            // Home community ID
            // ------------------
            if ((oUDDIEntity.getIdentifierBag() != null)
                && (oUDDIEntity.getIdentifierBag().getKeyedReference() != null)
                && (oUDDIEntity.getIdentifierBag().getKeyedReference().size() > 0)) {
              List<String> oValues =
                  findAndGetValueFromKeyedReference(
                      oUDDIEntity.getIdentifierBag().getKeyedReference(), HOME_COMMUNITY_ID_KEY);
              if (oValues != null && oValues.size() == 1) {
                for (String sValue : oValues) {
                  if ((sValue != null) && (sValue.length() > 0)) {
                    if (sValue.startsWith("urn:oid:")) {
                      sValue = sValue.substring("urn:oid:".length());
                    }
                    oEntity.setHomeCommunityId(sValue);
                  }
                }
              } else {
                log.debug(
                    "A single Home Community value is NOT detected for UDDI Entity "
                        + oUDDIEntity.getBusinessKey());
              }
            } // if ((oUDDIEntity.getIdentifierBag() != null) && ...

            if ((oUDDIEntity.getCategoryBag() != null)
                && (oUDDIEntity.getCategoryBag().getKeyedReference() != null)
                && (oUDDIEntity.getCategoryBag().getKeyedReference().size() > 0)) {
              // Public Key
              // -----------
              List<String> oPublicKeys =
                  findAndGetValueFromKeyedReference(
                      oUDDIEntity.getCategoryBag().getKeyedReference(), PUBLIC_KEY_ID_KEY);
              if (oPublicKeys != null && oPublicKeys.size() == 1) {
                for (String sValue : oPublicKeys) {
                  if ((sValue != null) && (sValue.length() > 0)) {
                    oEntity.setPublicKey(sValue);
                  }
                }
              } else {
                log.debug(
                    "A single Public Key value is NOT detected for UDDI Entity "
                        + oUDDIEntity.getBusinessKey());
              }
              // State names
              // ------------
              List<String> oStateNames =
                  findAndGetValueFromKeyedReference(
                      oUDDIEntity.getCategoryBag().getKeyedReference(), STATE_NAME_ID_KEY);
              if (oStateNames != null && oStateNames.size() > 0) {
                CMStates oStates = new CMStates();
                List<String> oStatesList = oStates.getState();
                for (String sValue : oStateNames) {
                  if ((sValue != null) && (sValue.length() > 0)) {
                    oStatesList.add(sValue);
                  }
                }
                oEntity.setStates(oStates);
              } else {
                log.debug(
                    "No State name is detected for UDDI Entity " + oUDDIEntity.getBusinessKey());
              }
            }
          } // if (oEntity != nulll)
        } // if ((oUDDIEntity.getBusinessKey() != null) && (oUDDIEntity.getBusinessKey().length() >
          // 0))
      } // for (BusinessEntity oUDDIEntity : oResult.getBusinessEntity())
    } // if ((oResult != null) &&
  }