Ejemplo n.º 1
0
  public BusinessService readServiceAnnotations(String classWithAnnotations, Properties properties)
      throws ClassNotFoundException {

    BusinessService service = new BusinessService();
    Class<?> clazz = ClassUtil.forName(classWithAnnotations, this.getClass());
    UDDIService uddiService = (UDDIService) clazz.getAnnotation(UDDIService.class);
    WebService webServiceAnnotation = (WebService) clazz.getAnnotation(WebService.class);

    if (uddiService != null) {
      // service
      String lang = "en"; // default to english
      if (uddiService.lang() != null) {
        lang = uddiService.lang();
      }
      Name name = new Name();
      name.setLang(lang);
      service.setBusinessKey(TokenResolver.replaceTokens(uddiService.businessKey(), properties));
      service.setServiceKey(TokenResolver.replaceTokens(uddiService.serviceKey(), properties));
      if (!"".equals(uddiService.serviceName())) {
        name.setValue(TokenResolver.replaceTokens(uddiService.serviceName(), properties));
      } else if (webServiceAnnotation != null && !"".equals(webServiceAnnotation.serviceName())) {
        name.setValue(webServiceAnnotation.serviceName());
      } else {
        name.setValue(clazz.getSimpleName());
      }
      service.getName().add(name);
      Description description = new Description();
      description.setLang(lang);
      description.setValue(TokenResolver.replaceTokens(uddiService.description(), properties));
      service.getDescription().add(description);

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

      // bindingTemplate on service
      BindingTemplate bindingTemplate =
          parseServiceBinding(clazz, lang, webServiceAnnotation, properties);
      if (bindingTemplate != null) {
        bindingTemplate.setServiceKey(service.getServiceKey());
        if (service.getBindingTemplates() == null) {
          service.setBindingTemplates(new BindingTemplates());
        }
        service.getBindingTemplates().getBindingTemplate().add(bindingTemplate);
      }

    } else {
      log.error("Missing UDDIService annotation in class " + classWithAnnotations);
    }

    return service;
  }
  @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);
    }
  }