示例#1
0
 public void setAnonymous(String anonymous) {
   if (anonymous.equals(AnonymousTypeConfig.REQUIRED.toString()))
     getConfig().setAnonymous(AnonymousTypeConfig.REQUIRED);
   else if (anonymous.equals(AnonymousTypeConfig.PROHIBITED.toString()))
     getConfig().setAnonymous(AnonymousTypeConfig.PROHIBITED);
   else getConfig().setAnonymous(AnonymousTypeConfig.OPTIONAL);
 }
示例#2
0
  /**
   * Method for processing policy on interface level it should include processing of all types of
   * policies, but for now there's only Addressing policy implemented
   *
   * @param policy
   * @return this interface changed in a proper way indicated by the policy
   */
  public void processPolicy(Policy policy) throws Exception {

    // default is optional
    // String anonymous = AnonymousTypeConfig.OPTIONAL.toString();
    // if (StringUtils.isNullOrEmpty(interfaceAnonymous) || policyFlag)
    // interfaceAnonymous = AnonymousTypeConfig.OPTIONAL.toString() ;
    // if (StringUtils.isNullOrEmpty(interfaceWsaVersion)|| policyFlag)
    // interfaceWsaVersion = WsaVersionTypeConfig.NONE.toString();
    if (!policyFlag) {
      interfaceAnonymous = AnonymousTypeConfig.OPTIONAL.toString();
      interfaceWsaVersion = WsaVersionTypeConfig.NONE.toString();
    }
    policyFlag = true;

    if (policy != null) {
      List<Addressing> addressingList = policy.getAddressingList();
      List<?> usingAddressingList = policy.getUsingAddressingList();
      for (Addressing addressing : addressingList) {
        policyFlag = true;
        String optional = addressing.getOptional().toString();
        if (StringUtils.isNullOrEmpty(optional)
            || optional.equals("false")
            || (optional.equals("true")
                && SoapUI.getSettings().getBoolean(WsaSettings.ENABLE_FOR_OPTIONAL))) {
          interfaceWsaVersion = WsaVersionTypeConfig.X_200508.toString();
        }
        Policy innerPolicy = addressing.getPolicy();
        if (innerPolicy != null) {
          List<AnonymousResponses> anonymousList = innerPolicy.getAnonymousResponsesList();
          List<NonAnonymousResponses> nonAnonymousList = innerPolicy.getNonAnonymousResponsesList();
          if (anonymousList.size() > 0 && nonAnonymousList.size() > 0) {
            throw new Exception(
                "Wrong addressing policy, anonymousResponses and nonAnonymousResponses can not be specified together");
          }
          if (anonymousList.size() > 0) {
            interfaceAnonymous = AnonymousTypeConfig.REQUIRED.toString();
          } else {
            if (nonAnonymousList.size() > 0) {
              interfaceAnonymous = AnonymousTypeConfig.PROHIBITED.toString();
            }
          }
        }
      }
      if (interfaceWsaVersion == WsaVersionTypeConfig.NONE.toString()
          && !usingAddressingList.isEmpty()) {
        /*
         * UsingAddressing can also be specified insde Policy check
         * http://www.w3.org/TR/ws-addr-wsdl/#id2263339
         */
        interfaceWsaVersion = WsaVersionTypeConfig.X_200508.toString();
      }
    }
    setAnonymous(interfaceAnonymous);
    // set wsaVersion to one from policy only if it was null from wsdl binding
    if (getConfig().getWsaVersion().equals(WsaVersionTypeConfig.NONE)) {
      setWsaVersion(interfaceWsaVersion);
    }
  }
示例#3
0
  public String getAnonymous() {
    // return WsdlUtils.getAnonymous(this);
    if (getConfig().isSetAnonymous()) {
      if (getConfig().getAnonymous().equals(AnonymousTypeConfig.PROHIBITED)) {
        return AnonymousTypeConfig.PROHIBITED.toString();
      } else if (getConfig().getAnonymous().equals(AnonymousTypeConfig.REQUIRED)) {
        return AnonymousTypeConfig.REQUIRED.toString();
      }
    }

    return AnonymousTypeConfig.OPTIONAL.toString();
  }