Пример #1
1
 public static OMElement serializeHandlerConfiguration(HandlerConfigurationBean bean) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMElement handler = factory.createOMElement("handler", null);
   handler.addAttribute(factory.createOMAttribute("class", null, bean.getHandlerClass()));
   if (bean.getTenant() != null) {
     handler.addAttribute(factory.createOMAttribute("tenant", null, bean.getTenant()));
   }
   StringBuilder sb = new StringBuilder();
   for (String method : bean.getMethods()) {
     if (method != null && method.length() > 0) {
       sb.append(method).append(",");
     }
   }
   // Remove last ","
   if (sb.length() > 0) {
     sb.deleteCharAt(sb.length() - 1);
     handler.addAttribute(factory.createOMAttribute("methods", null, sb.toString()));
   }
   for (String property : bean.getPropertyList()) {
     OMElement temp = factory.createOMElement("property", null);
     temp.addAttribute(factory.createOMAttribute("name", null, property));
     OMElement xmlProperty = bean.getXmlProperties().get(property);
     if (xmlProperty != null) {
       //                The serialization happens by adding the whole XML property value to the
       // bean.
       //                Therefore if it is a XML property, we take that whole element.
       handler.addChild(xmlProperty);
     } else {
       String nonXMLProperty = bean.getNonXmlProperties().get(property);
       if (nonXMLProperty != null) {
         temp.setText(nonXMLProperty);
         handler.addChild(temp);
       }
     }
   }
   OMElement filter = factory.createOMElement("filter", null);
   filter.addAttribute(
       factory.createOMAttribute("class", null, bean.getFilter().getFilterClass()));
   for (String property : bean.getFilter().getPropertyList()) {
     OMElement temp = factory.createOMElement("property", null);
     temp.addAttribute(factory.createOMAttribute("name", null, property));
     OMElement xmlProperty = bean.getFilter().getXmlProperties().get(property);
     if (xmlProperty != null) {
       temp.addAttribute(factory.createOMAttribute("type", null, "xml"));
       temp.addChild(xmlProperty);
       filter.addChild(temp);
     } else {
       String nonXMLProperty = bean.getFilter().getNonXmlProperties().get(property);
       if (nonXMLProperty != null) {
         temp.setText(nonXMLProperty);
         filter.addChild(temp);
       }
     }
   }
   handler.addChild(filter);
   return handler;
 }
  public void sendUsingMTOM(String fileName, String targetEPR) throws IOException {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
    OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
    OMElement request = factory.createOMElement("request", ns);
    OMElement image = factory.createOMElement("image", ns);

    FileDataSource fileDataSource = new FileDataSource(new File(fileName));
    DataHandler dataHandler = new DataHandler(fileDataSource);
    OMText textData = factory.createOMText(dataHandler, true);
    image.addChild(textData);
    request.addChild(image);
    payload.addChild(request);

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(targetEPR));
    options.setAction("urn:uploadFileUsingMTOM");
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    options.setCallTransportCleanup(true);
    serviceClient.setOptions(options);
    OMElement response = serviceClient.sendReceive(payload);
    Assert.assertTrue(
        response
            .toString()
            .contains(
                "<m:testMTOM xmlns:m=\"http://services.samples/xsd\">"
                    + "<m:test1>testMTOM</m:test1></m:testMTOM>"));
  }
  private OMElement handleSLORequest(MessageContext messageContext, LogoutRequest logoutRequest) {

    // Get the session index from the SLORequest and remove the relevant session.
    String sessionIndex = logoutRequest.getSessionIndexes().get(0).getSessionIndex();

    String sessionId = CacheManager.getInstance().getSessionIndexMappingCache().get(sessionIndex);

    if (sessionId != null) {
      GatewayUtils.logWithRequestInfo(
          log,
          messageContext,
          String.format(
              "Found a session id (md5 : '%s')for the given session index in the SLO request: '%s'. Clearing the session",
              GatewayUtils.getMD5Hash(sessionId), sessionIndex));
      SessionStore.getInstance().removeSession(sessionId);
      CacheManager.getInstance().getSessionIndexMappingCache().remove(sessionIndex);
    } else {
      GatewayUtils.logWithRequestInfo(
          log,
          messageContext,
          String.format(
              "Couldn't find a session id for the given session index : '%s'", sessionIndex));
    }

    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace ns = fac.createOMNamespace("http://wso2.org/appm", "appm");
    OMElement payload = fac.createOMElement("SLOResponse", ns);

    OMElement errorMessage = fac.createOMElement("message", ns);
    errorMessage.setText("SLORequest has been successfully processed by WSO2 App Manager");

    payload.addChild(errorMessage);

    return payload;
  }
Пример #4
0
  /**
   * Contains the logic to create URITemplate XML Element from the swagger 2.0 resource.
   *
   * @param swaggerDocObject swagger document
   * @return URITemplate element.
   */
  private static List<OMElement> createURITemplateFromSwagger2(JsonObject swaggerDocObject) {

    List<OMElement> uriTemplates = new ArrayList<>();

    JsonObject paths = swaggerDocObject.get(SwaggerConstants.PATHS).getAsJsonObject();
    Set<Map.Entry<String, JsonElement>> pathSet = paths.entrySet();

    for (Map.Entry path : pathSet) {
      JsonObject urlPattern = ((JsonElement) path.getValue()).getAsJsonObject();
      String pathText = path.getKey().toString();
      Set<Map.Entry<String, JsonElement>> operationSet = urlPattern.entrySet();

      for (Map.Entry operationEntry : operationSet) {
        OMElement uriTemplateElement = factory.createOMElement(URI_TEMPLATE, namespace);
        OMElement urlPatternElement = factory.createOMElement(URL_PATTERN, namespace);
        OMElement httpVerbElement = factory.createOMElement(HTTP_VERB, namespace);
        OMElement authTypeElement = factory.createOMElement(AUTH_TYPE, namespace);

        urlPatternElement.setText(pathText);
        httpVerbElement.setText(operationEntry.getKey().toString());

        uriTemplateElement.addChild(urlPatternElement);
        uriTemplateElement.addChild(httpVerbElement);
        uriTemplateElement.addChild(authTypeElement);
        uriTemplates.add(uriTemplateElement);
      }
    }
    return uriTemplates;
  }
Пример #5
0
  private static boolean JARServiceTest() {
    boolean JARServiceStatus = false;
    OMElement result;
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2", "ns1");
    OMElement payload = fac.createOMElement("echo", omNs);
    OMElement value = fac.createOMElement("args0", omNs);
    value.addChild(fac.createOMText(value, "Hello-World"));
    payload.addChild(value);

    ServiceClient serviceclient;
    try {
      serviceclient = new ServiceClient();
      Options opts = new Options();

      opts.setTo(new EndpointReference(HTTP_APPSERVER_STRATOSLIVE_URL + "/SimpleJarService"));
      opts.setAction("echo");
      // bypass http protocol exception
      opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);

      serviceclient.setOptions(opts);

      result = serviceclient.sendReceive(payload);

      if ((result.toString().indexOf("Hello-World")) > 0) {
        JARServiceStatus = true;
      }
      assertTrue("Jar service invocation failed", JARServiceStatus);

    } catch (AxisFault axisFault) {
      log.error("Jar service invocation failed:" + axisFault.getMessage());
      fail("Jar service invocation failed:" + axisFault.getMessage());
    }
    return JARServiceStatus;
  }
Пример #6
0
 public static OMElement queryToOM(Query query) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMElement queryChild =
       factory.createOMElement(
           new QName(
               CEPConstants.CEP_CONF_NAMESPACE,
               CEPConstants.CEP_CONF_ELE_QUERY,
               CEPConstants.CEP_CONF_CEP_NAME_SPACE_PREFIX));
   Expression queryExpression = query.getExpression();
   String queryName = query.getName();
   OMElement queryIP = null;
   List<String> ipList = query.getIpList();
   for (String ip : ipList) {
     queryIP = factory.createOMElement(new QName(CEPConstants.CEP_CONF_QUERY_IP));
     queryIP.setText(ip);
     queryChild.addChild(queryIP);
   }
   queryChild.addAttribute(CEPConstants.CEP_CONF_ATTR_NAME, queryName, null);
   OMElement omQueryExpression = ExpressionHelper.expressionToOM(queryExpression);
   queryChild.addChild(omQueryExpression);
   if (query.getOutput() != null) {
     OMElement queryOutput = OutputHelper.outputToOM(query.getOutput());
     queryChild.addChild(queryOutput);
   }
   return queryChild;
 }
Пример #7
0
  public void doGet(HttpServletRequest req, HttpServletResponse res) {
    res.setContentType("application/download-xml-file");

    String messageId = req.getParameter("message");

    OMElement report = null;

    try {
      Message m = new Message(messageId);
      m.readMessage();

      report = buildReport(m);

    } catch (LoggerException e) {
      report = omFactory.createOMElement(new QName("NoReportAvailable"));
      report.setText(e.getMessage().replaceAll("<", "&lt;"));
    } catch (ServletException e) {
      report = omFactory.createOMElement(new QName("NoReportAvailable"));
      report.setText(e.getMessage().replaceAll("<", "&lt;"));
    }

    try {
      res.getWriter().write(report.toString());
    } catch (IOException e) {
    }
  }
Пример #8
0
  OMElement buildReport(Message m) throws ServletException {
    if (!verifyTables(m)) {
      throw new ServletException("Missing Table");
    }

    System.out.println(index(m));

    HashMap<String, HashMap<String, Object>> mm = m.toHashMap();

    OMElement report = omFactory.createOMElement(new QName("XdsEvsResult"));

    addParm(report, mm, "Test", "other", "Service");
    addParm(report, mm, "Date", "main", "Timestamp");
    addParm(report, mm, "Source", "http", "IP_address_From");

    OMElement ele = omFactory.createOMElement(new QName("Target"));
    ele.setText(localIPAddress());
    report.addChild(ele);

    addParm(report, mm, "Endpoint", "http", "URI_To");
    addParm(report, mm, "Result", "main", "Pass");
    addParm(report, mm, "LogEvent", "main", "MessageId");

    addParm(report, mm, "Error", "error", "Error");

    // System.out.println("errors are:\n" + mm.get("error"));

    return report;
  }
Пример #9
0
  @Override
  public void connect(MessageContext messageContext) throws ConnectException {
    String providerUrl = LDAPUtils.lookupContextParams(messageContext, LDAPConstants.PROVIDER_URL);
    String dn = (String) getParameter(messageContext, "dn");
    String password = (String) getParameter(messageContext, "password");

    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace(LDAPConstants.CONNECTOR_NAMESPACE, "ns");
    OMElement result = factory.createOMElement("result", ns);
    OMElement message = factory.createOMElement("message", ns);

    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, providerUrl);
    env.put(Context.SECURITY_PRINCIPAL, dn);
    env.put(Context.SECURITY_CREDENTIALS, password);

    org.apache.axis2.context.MessageContext axis2MessageContext =
        ((Axis2MessageContext) messageContext).getAxis2MessageContext();

    boolean logged = false;
    DirContext ctx = null;
    try {
      ctx = new InitialDirContext(env);
      message.setText("Success");
      result.addChild(message);
      LDAPUtils.preparePayload(messageContext, result);
    } catch (NamingException e) {
      message.setText("Fail");
      result.addChild(message);
      LDAPUtils.preparePayload(messageContext, result);
    }
  }
Пример #10
0
 public OMElement buildXML() {
   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMElement confEl = fac.createOMElement("config", null);
   if (this.getId() != null) {
     confEl.addAttribute("id", this.getId(), null);
   }
   /* build properties */
   Iterator<Property> iterator = this.getProperties().iterator();
   while (iterator.hasNext()) {
     Property property = iterator.next();
     if (this.isUseSecretAliasForPassword()
         && (property.getName().equals(RDBMS.PASSWORD)
             || property.getName().equals(RDBMS_OLD.PASSWORD)
             || property.getName().equals(GSpread.PASSWORD)
             || property.getName().equals(JNDI.PASSWORD))) {
       OMFactory factory = OMAbstractFactory.getOMFactory();
       OMElement propEl = factory.createOMElement("property", null);
       propEl.addAttribute("name", property.getName(), null);
       propEl.addAttribute("svns:secretAlias", (String) property.getValue(), null);
       confEl.addChild(propEl);
     } else {
       if (property.buildXML() != null) {
         confEl.addChild(property.buildXML());
       }
     }
   }
   return confEl;
 }
Пример #11
0
 private OMElement createCustomQuoteRequest(String symbol) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMNamespace ns = factory.createOMNamespace("http://services.samples", "ns");
   OMElement chkPrice = factory.createOMElement("CheckPriceRequest", ns);
   OMElement code = factory.createOMElement("Code", ns);
   chkPrice.addChild(code);
   code.setText(symbol);
   return chkPrice;
 }
Пример #12
0
 private static OMElement createPayLoad() {
   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMNamespace omNs = fac.createOMNamespace("http://service.carbon.wso2.org", "ns1");
   OMElement method = fac.createOMElement("echoString", omNs);
   OMElement value = fac.createOMElement("s", omNs);
   value.addChild(fac.createOMText(value, "Hello World"));
   method.addChild(value);
   return method;
 }
Пример #13
0
  private static OMElement getPayload(String value) {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns =
        factory.createOMNamespace("http://sample05.policy.samples.rampart.apache.org", "ns1");
    OMElement elem = factory.createOMElement("echo", ns);
    OMElement childElem = factory.createOMElement("param0", null);
    childElem.setText(value);
    elem.addChild(childElem);

    return elem;
  }
Пример #14
0
  private OMElement createStandardSimpleRequest(String symbol) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getSimpleQuote", omNs);
    OMElement value1 = fac.createOMElement("symbol", omNs);

    value1.addChild(fac.createOMText(method, symbol));
    method.addChild(value1);

    return method;
  }
Пример #15
0
  public void addSobjects(
      String strOperation,
      String strParamName,
      MessageContext synCtx,
      SynapseLog synLog,
      String strExternalId) {
    SOAPEnvelope envelope = synCtx.getEnvelope();
    OMFactory fac = OMAbstractFactory.getOMFactory();
    SOAPBody body = envelope.getBody();
    Iterator<OMElement> bodyChildElements = body.getChildrenWithLocalName(strOperation);
    if (bodyChildElements.hasNext()) {
      try {
        OMElement bodyElement = bodyChildElements.next();
        if (strExternalId != null) {
          OMNamespace omNs = fac.createOMNamespace("urn:partner.soap.sforce.com", "urn");
          OMElement value = fac.createOMElement("externalIDFieldName", omNs);
          value.addChild(fac.createOMText(strExternalId));
          bodyElement.addChild(value);
        }
        String strSobject = (String) ConnectorUtils.lookupTemplateParamater(synCtx, strParamName);
        OMElement sObjects = AXIOMUtil.stringToOM(strSobject);
        Iterator<OMElement> sObject = sObjects.getChildElements();
        String strType =
            sObjects.getAttributeValue(new QName(SalesforceUtil.SALESFORCE_CREATE_SOBJECTTYPE));
        OMElement tmpElement = null;
        OMNamespace omNsurn = fac.createOMNamespace("urn:partner.soap.sforce.com", "urn");
        OMNamespace omNsurn1 = fac.createOMNamespace("urn:sobject.partner.soap.sforce.com", "urn1");
        // Loops sObject
        while (sObject.hasNext()) {
          OMElement currentElement = sObject.next();
          OMElement newElement = fac.createOMElement("sObjects", omNsurn);
          // Add Object type
          if (strType != null) {
            tmpElement = fac.createOMElement("type", omNsurn1);
            tmpElement.addChild(fac.createOMText(strType));
            newElement.addChild(tmpElement);
          }
          // Add the fields
          Iterator<OMElement> sObjectFields = currentElement.getChildElements();
          while (sObjectFields.hasNext()) {
            OMElement sObjectField = sObjectFields.next();
            tmpElement = fac.createOMElement(sObjectField.getLocalName(), omNsurn1);
            tmpElement.addChild(fac.createOMText(sObjectField.getText()));
            newElement.addChild(tmpElement);
          }

          bodyElement.addChild(newElement);
        }
      } catch (Exception e) {
        synLog.error("Saleforce adaptor - error injecting sObjects to payload : " + e);
      }
    }
  }
Пример #16
0
  private OMElement createPayload() {

    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
    OMElement rpcWrapEle = fac.createOMElement("echoMTOMtoBase64", omNs);
    OMElement data = fac.createOMElement("data", omNs);
    byte[] byteArray = new byte[] {13, 56, 65, 32, 12, 12, 7, 98};
    DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
    expectedTextData = new OMTextImpl(dataHandler, true, fac);
    data.addChild(expectedTextData);
    rpcWrapEle.addChild(data);
    return rpcWrapEle;
  }
Пример #17
0
  private OMElement getPayload() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);
    OMElement value1 = fac.createOMElement("request", omNs);
    OMElement value2 = fac.createOMElement("symbol", omNs);

    value2.addChild(fac.createOMText(value1, "Secured"));
    value1.addChild(value2);
    method.addChild(value1);

    return method;
  }
Пример #18
0
  private static OMElement getPayload() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://service.esb.wso2.org", "ns");
    OMElement method = fac.createOMElement("add", omNs);
    OMElement value1 = fac.createOMElement("x", omNs);
    OMElement value2 = fac.createOMElement("y", omNs);

    value1.addChild(fac.createOMText(value1, "10"));
    value2.addChild(fac.createOMText(value2, "10"));
    method.addChild(value1);
    method.addChild(value2);

    return method;
  }
Пример #19
0
  public final OMElement getParameters() {
    OMFactory omFactory = OMAbstractFactory.getOMFactory();

    OMElement parameters = omFactory.createOMElement("parameters", null);

    for (Map.Entry<Integer, Integer> e : this.users.entrySet()) {
      OMElement user = omFactory.createOMElement("user_item", null);
      user.addAttribute("id", e.getKey().toString(), null);
      user.addAttribute("version", e.getValue().toString(), null);

      parameters.addChild(user);
    }
    return parameters;
  }
Пример #20
0
  private OMElement createMultipleQuoteRequest(String symbol, int iterations) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);

    for (int i = 0; i < iterations; i++) {
      OMElement value1 = fac.createOMElement("request", omNs);
      OMElement value2 = fac.createOMElement("symbol", omNs);
      value2.addChild(fac.createOMText(value1, symbol));
      value1.addChild(value2);
      method.addChild(value1);
    }
    return method;
  }
  public OMElement getCEPPublisher(OMElement request) throws XMLStreamException {
    request.build();
    request.detach();

    OMElement tenantId =
        request.getFirstChildWithName(
            new QName(
                ManagerServiceConstants.NAMESPACE, ManagerServiceConstants.ELEMENT_TENANT_ID));
    OMElement executionPlan =
        request.getFirstChildWithName(
            new QName(
                ManagerServiceConstants.NAMESPACE, ManagerServiceConstants.ELEMENT_EXEC_PLAN));
    OMElement requesterIp =
        request.getFirstChildWithName(
            new QName(
                ManagerServiceConstants.NAMESPACE, ManagerServiceConstants.ELEMENT_REQUESTER_IP));
    String key = getKey(executionPlan.getText(), tenantId.getText());
    log.info("CEP Publisher requested for  " + key);

    Set<Endpoint> endpointSet = cepPublishers.get(key);
    Endpoint selectedEndpoint = selectEndpoint(endpointSet, requesterIp.getText());
    OMElement response =
        factory.createOMElement(
            ManagerServiceConstants.ELEMENT_CEP_PUBLISHER_RESPONSE, OMNamespace);
    if (selectedEndpoint != null) {
      OMElement hostNameElement =
          factory.createOMElement(ManagerServiceConstants.ELEMENT_HOST_NAME, OMNamespace);
      OMElement portElement =
          factory.createOMElement(ManagerServiceConstants.ELEMENT_PORT, OMNamespace);

      OMText hostNameText = factory.createOMText(hostNameElement, selectedEndpoint.getHostName());
      OMText portText =
          factory.createOMText(portElement, Integer.toString(selectedEndpoint.getPort()));

      hostNameElement.addChild(hostNameText);
      portElement.addChild(portText);
      response.addChild(hostNameElement);
      response.addChild(portElement);
      log.info(
          "Returning CEP Publisher:"
              + selectedEndpoint.getHostName()
              + ":"
              + selectedEndpoint.getPort());
    } else {
      log.warn("No CEP publishers registered " + key);
    }

    return response;
  }
Пример #22
0
  private OMElement getPayload(String value) {
    OMFactory factory = null;
    OMNamespace ns = null;
    OMElement elem = null;
    OMElement childElem = null;

    factory = OMAbstractFactory.getOMFactory();
    ns = factory.createOMNamespace("http://echo.services.core.carbon.wso2.org", "ns");
    elem = factory.createOMElement("echoString", ns);
    childElem = factory.createOMElement("in", null);
    childElem.setText(value);
    elem.addChild(childElem);

    return elem;
  }
Пример #23
0
 /**
  * @param parentQName
  * @param factory
  * @return org.apache.axiom.om.OMElement
  */
 public org.apache.axiom.om.OMElement getOMElement(
     final javax.xml.namespace.QName parentQName, final org.apache.axiom.om.OMFactory factory)
     throws org.apache.axis2.databinding.ADBException {
   org.apache.axiom.om.OMDataSource dataSource =
       new org.apache.axis2.databinding.ADBDataSource(this, parentQName);
   return factory.createOMElement(dataSource, parentQName);
 }
  public static OMElement outputMappingToOM(OutputMapping outputMapping, OMFactory factory) {

    MapOutputMapping mapOutputMapping = (MapOutputMapping) outputMapping;

    List<EventOutputProperty> outputPropertyConfiguration =
        mapOutputMapping.getOutputPropertyConfiguration();

    OMElement mappingOMElement =
        factory.createOMElement(new QName(EventFormatterConstants.EF_ELE_MAPPING_PROPERTY));
    mappingOMElement.declareDefaultNamespace(EventFormatterConstants.EF_CONF_NS);

    mappingOMElement.addAttribute(
        EventFormatterConstants.EF_ATTR_TYPE, EventFormatterConstants.EF_MAP_MAPPING_TYPE, null);

    if (mapOutputMapping.isCustomMappingEnabled()) {
      mappingOMElement.addAttribute(
          EventFormatterConstants.EF_ATTR_CUSTOM_MAPPING,
          EventFormatterConstants.TM_VALUE_ENABLE,
          null);

      if (outputPropertyConfiguration.size() > 0) {
        for (EventOutputProperty eventOutputProperty : outputPropertyConfiguration) {
          mappingOMElement.addChild(getPropertyOmElement(factory, eventOutputProperty));
        }
      }
    } else {
      mappingOMElement.addAttribute(
          EventFormatterConstants.EF_ATTR_CUSTOM_MAPPING,
          EventFormatterConstants.TM_VALUE_DISABLE,
          null);
    }
    return mappingOMElement;
  }
Пример #25
0
  public OMElement toOM() {

    OMFactory omFactory = OMAbstractFactory.getOMFactory();

    OMElement targetElement =
        omFactory.createOMElement(
            Constants.RULE_CONF_ELE_TARGET,
            Constants.RULE_CONF_NAMESPACE,
            Constants.RULE_CONF_NAMESPACE_PREFIX);
    if (this.xpath != null) {
      targetElement.addAttribute(Constants.RULE_CONF_ATTR_XPATH, this.xpath, null);
    }

    if (this.resultXpath != null) {
      targetElement.addAttribute(Constants.RULE_CONF_ATTR_RESULT_XPATH, this.resultXpath, null);
    }

    if (this.action != null) {
      targetElement.addAttribute(Constants.RULE_CONF_ATTR_ACTION, this.action, null);
    }

    if (this.value != null) {
      targetElement.setText(this.value);
    }

    if (this.prefixToNamespaceMap != null) {

      for (String prefix : this.prefixToNamespaceMap.keySet()) {

        String nsURI = this.prefixToNamespaceMap.get(prefix);
        targetElement.declareNamespace(nsURI, prefix);
      }
    }
    return targetElement;
  }
Пример #26
0
 public void addIds(
     String strOperation, String strParamName, MessageContext synCtx, SynapseLog synLog) {
   SOAPEnvelope envelope = synCtx.getEnvelope();
   OMFactory fac = OMAbstractFactory.getOMFactory();
   SOAPBody body = envelope.getBody();
   Iterator<OMElement> bodyChildElements = body.getChildrenWithLocalName(strOperation);
   if (bodyChildElements.hasNext()) {
     try {
       OMElement bodyElement = bodyChildElements.next();
       Iterator<OMElement> cElements = bodyElement.getChildElements();
       if (cElements != null && cElements.hasNext()) {
         cElements.next();
       }
       String strSobject = (String) ConnectorUtils.lookupTemplateParamater(synCtx, strParamName);
       OMElement sObjects = AXIOMUtil.stringToOM(strSobject);
       Iterator<OMElement> sObject = sObjects.getChildElements();
       OMNamespace omNsurn = fac.createOMNamespace("urn:partner.soap.sforce.com", "urn");
       // Loops sObject
       while (sObject.hasNext()) {
         OMElement currentElement = sObject.next();
         OMElement newElement = fac.createOMElement("ids", omNsurn);
         // Add the fields
         newElement.addChild(fac.createOMText(currentElement.getText()));
         bodyElement.addChild(newElement);
       }
     } catch (Exception e) {
       synLog.error("Saleforce adaptor - error injecting sObjects to payload : " + e);
     }
   }
 }
  /**
   * Retrieve all entries from service.
   *
   * @return All entries of type Entry from the service.
   * @exception FailureFaultException If an error communication with the service occurs.
   */
  public Entry[] retrieve() throws FailureFaultException {
    final String method = "retrieve";
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace namespace = factory.createOMNamespace(SERVICE, method);

    // Create a request
    OMElement request = factory.createOMElement("RetrieveRequest", namespace);

    // Configure connection
    Options options = new Options();
    options.setTo(new EndpointReference(url.toString()));
    options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    options.setAction(method);

    // Create a client
    try {
      ServiceClient client = new ServiceClient();
      client.setOptions(options);

      // Try send request and receive response, could throw AxisFault
      OMElement response = client.sendReceive(request);

      // Debug
      printDebug("RESPONSE", response);

      // Parse and return result
      Entry[] result = XMLUtil.parseScores(response);
      return result;
    } catch (AxisFault e) {
      throw new FailureFaultException("Exception from service: ", e);
    }
  }
Пример #28
0
 /** Creates OMElement using error details. */
 public static OMElement createDSFaultOM(String msg) {
   OMFactory fac = OMAbstractFactory.getOMFactory();
   OMElement ele =
       fac.createOMElement(new QName(DBConstants.WSO2_DS_NAMESPACE, DBConstants.DS_FAULT_ELEMENT));
   ele.setText(msg);
   return ele;
 }
Пример #29
0
  private OMElement getRSTTemplate() throws TrustException {
    OMFactory omFac = OMAbstractFactory.getOMFactory();
    OMElement element = omFac.createOMElement(SP11Constants.REQUEST_SECURITY_TOKEN_TEMPLATE);

    if (ClientConstants.SAML_TOKEN_TYPE_20.equals(tokenType)) {
      TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_02, element)
          .setText(RahasConstants.TOK_TYPE_SAML_20);
    } else if (ClientConstants.SAML_TOKEN_TYPE_11.equals(tokenType)) {
      TrustUtil.createTokenTypeElement(RahasConstants.VERSION_05_02, element)
          .setText(RahasConstants.TOK_TYPE_SAML_10);
    }

    if (ClientConstants.SUBJECT_CONFIRMATION_BEARER.equals(subjectConfirmationMethod)) {
      TrustUtil.createKeyTypeElement(
          RahasConstants.VERSION_05_02, element, RahasConstants.KEY_TYPE_BEARER);
    } else if (ClientConstants.SUBJECT_CONFIRMATION_HOLDER_OF_KEY.equals(
        subjectConfirmationMethod)) {
      TrustUtil.createKeyTypeElement(
          RahasConstants.VERSION_05_02, element, RahasConstants.KEY_TYPE_SYMM_KEY);
    }

    // request claims in the token.
    OMElement claimElement =
        TrustUtil.createClaims(RahasConstants.VERSION_05_02, element, claimDialect);
    // Populate the <Claims/> element with the <ClaimType/> elements
    addClaimType(claimElement, claimUris);

    return element;
  }
 private static void addPropertyElements(
     OMFactory factory,
     OMElement parent,
     String className,
     String description,
     Map<String, String> properties) {
   if (className != null) {
     parent.addAttribute(UserCoreConstants.RealmConfig.ATTR_NAME_CLASS, className, null);
   }
   if (description != null) {
     parent.addAttribute(UserCoreConstants.RealmConfig.CLASS_DESCRIPTION, description, null);
   }
   Iterator<Map.Entry<String, String>> ite = properties.entrySet().iterator();
   while (ite.hasNext()) {
     Map.Entry<String, String> entry = ite.next();
     String name = entry.getKey();
     String value = entry.getValue();
     OMElement propElem =
         factory.createOMElement(new QName(UserCoreConstants.RealmConfig.LOCAL_NAME_PROPERTY));
     OMAttribute propAttr =
         factory.createOMAttribute(UserCoreConstants.RealmConfig.ATTR_NAME_PROP_NAME, null, name);
     propElem.addAttribute(propAttr);
     propElem.setText(value);
     parent.addChild(propElem);
   }
 }