gpt4 book ai didi

org.n52.security.common.xml.XMLPath.all()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 03:21:05 25 4
gpt4 key购买 nike

本文整理了Java中org.n52.security.common.xml.XMLPath.all()方法的一些代码示例,展示了XMLPath.all()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLPath.all()方法的具体详情如下:
包路径:org.n52.security.common.xml.XMLPath
类名称:XMLPath
方法名:all

XMLPath.all介绍

[英]Method all, expects a xpath query resulting in a NodeList.
[中]方法all,需要xpath查询生成节点列表。

代码示例

代码示例来源:origin: org.n52.security/52n-security-decision-xacml

public void debugPDPRequest(final Element request) {
  StringBuilder text = new StringBuilder();
  NodeList requestChildNodes = XMLPathCtx.createNew().findIn(request).all("/*[local-name() = 'Request']/*").get();
  for (int i = 0; i < requestChildNodes.getLength(); i++) {
    Element requestChild = (Element) requestChildNodes.item(i);
    text.append(requestChild.getLocalName()).append("\n");
    appendAttributes(text, XMLPathCtx.createNew().findIn(requestChild).all(".//*[local-name()='AttributeValue']").get());
  }
  LOG.debug("PDP request\n" + text);
}

代码示例来源:origin: org.n52.security/52n-security-enforcement-impl

/**
 * Get position from feature node.
 * 
 * @param node
 *            feature
 * @return position as text
 */
private String getPositionFromSamplingPoint(Node node) {
  NodeList nl =
      ctx.findIn(node)
          .all("./" + SOSInterceptorGlobals.ELEMENT_SA_POSITION + "/"
              + SOSInterceptorGlobals.ELEMENT_GML_POINT + "/"
              + SOSInterceptorGlobals.ELEMENT_GML_POS).get();
  for (int i = 0; i < nl.getLength();) {
    return nl.item(i).getTextContent();
  }
  return "0 0";
}

代码示例来源:origin: org.n52.security/52n-security-enforcement-impl

/**
 * Get position from feature node.
 * 
 * @param node
 *            feature
 * @return position as text
 */
private String getPositionFromSamplingPoint(Node node) {
  NodeList nl =
      ctxResponse
          .findIn(node)
          .all("./" + SOSInterceptorGlobals.ELEMENT_SA_POSITION + "/"
              + SOSInterceptorGlobals.ELEMENT_GML_POINT + "/"
              + SOSInterceptorGlobals.ELEMENT_GML_POS).get();
  for (int i = 0; i < nl.getLength();) {
    return nl.item(i).getTextContent();
  }
  return "0 0";
}

代码示例来源:origin: org.n52.security/52n-security-wss

public void setOperationUrls(String opUrl) {
  NodeList hrefNodes = m_xPathCtx.findIn(m_capsDoc).all("//ows:Operation/ows:DCP/ows:HTTP/*/@xlink:href").get();
  for (int i = 0; i < hrefNodes.getLength(); i++) {
    Node hrefNode = hrefNodes.item(i);
    hrefNode.setTextContent(opUrl);
  }
}

代码示例来源:origin: org.n52.security/52n-security-enforcement-impl

/**
 * Get EPSG code from feature node.
 * 
 * @param node
 *            feature
 * @return EPSG code
 */
private String getEpsgCodeFromPosition(Node node) {
  NodeList nl =
      ctxResponse
          .findIn(node)
          .all("./" + SOSInterceptorGlobals.ELEMENT_SA_POSITION + "/"
              + SOSInterceptorGlobals.ELEMENT_GML_POINT + "/"
              + SOSInterceptorGlobals.ELEMENT_GML_POS).get();
  for (int i = 0; i < nl.getLength(); i++) {
    if (nl.item(i).hasAttributes()) {
      NamedNodeMap attributes = nl.item(i).getAttributes();
      for (int j = 0; j < attributes.getLength(); j++) {
        if (attributes.item(i).getLocalName().equalsIgnoreCase(SOSInterceptorGlobals.ATTRIBUTE_SRS_NAME)) {
          return attributes.item(i).getTextContent();
        }
      }
    }
  }
  return "";
}

代码示例来源:origin: org.n52.security/52n-security-enforcement-impl

/**
 * Get EPSG code from feature node.
 * 
 * @param node
 *            feature
 * @return EPSG code
 */
private String getEpsgCodeFromPosition(Node node) {
  NodeList nl =
      ctx.findIn(node)
          .all("./" + SOSInterceptorGlobals.ELEMENT_SA_POSITION + "/"
              + SOSInterceptorGlobals.ELEMENT_GML_POINT + "/"
              + SOSInterceptorGlobals.ELEMENT_GML_POS).get();
  for (int i = 0; i < nl.getLength(); i++) {
    if (nl.item(i).hasAttributes()) {
      NamedNodeMap attributes = nl.item(i).getAttributes();
      for (int j = 0; j < attributes.getLength(); j++) {
        if (attributes.item(i).getLocalName().equalsIgnoreCase(SOSInterceptorGlobals.ATTRIBUTE_SRS_NAME)) {
          return attributes.item(i).getTextContent();
        }
      }
    }
  }
  return "";
}

代码示例来源:origin: org.n52.security/52n-security-facade

public List<SAML2IdPMetadata> getIdPMetadata() {
  XMLPathCtx xpathCtx = XMLPathCtx.createNew().addNamespace("md", "urn:oasis:names:tc:SAML:2.0:metadata");
  NodeList idpList = xpathCtx.findIn(m_federationMetadata).all("//md:IDPSSODescriptor").get();
  List<SAML2IdPMetadata> mdList = new ArrayList<SAML2IdPMetadata>();
  for (int i = 0; i < idpList.getLength(); i++) {
    Element idpSsoDescriptor = (Element) idpList.item(i);
    try {
      SAML2IdPMetadata idPMetadata = SAML2IdPMetadata.createFrom(idpSsoDescriptor);
      mdList.add(idPMetadata);
    } catch (MalformedURLException e) {
      LOG.error("Skipping IDPSSODescriptor element", e);
    }
  }
  return mdList;
}

代码示例来源:origin: org.n52.security/52n-security-decision-xacml

private void debugPDPResponse(Element response) {
  StringBuilder text = new StringBuilder();
  String resourceId = XMLPathCtx.createNew().findIn(response).text("//*[local-name() = 'Result']/@ResourceId").get();
  String decision = XMLPathCtx.createNew().findIn(response).text("//*[local-name() = 'Result']/*[local-name() = 'Decision']/text()").get();
  text.append("Resource: \t").append(resourceId ).append("\n");
  text.append("Decision: \t").append(decision).append("\n");
  NodeList obligationNodes = XMLPathCtx.createNew().findIn(response).all("//*[local-name() = 'Obligation']").get();
  for (int i = 0; i < obligationNodes.getLength(); i++) {
    Element obligationElem = (Element) obligationNodes.item(i);
    String oblId = obligationElem.getAttribute("ObligationId");
    String fulfillOn = obligationElem.getAttribute("FulfillOn");
    text.append("Obligation: \t").append(oblId ).append("(fulfillOn:").append(fulfillOn).append(")\n");
    appendAttributeAssignments(text, XMLPathCtx.createNew().findIn(obligationElem).all(".//*[local-name()='AttributeAssignment']").get());
  }
  LOG.debug("PDP response\n" + text);
}

代码示例来源:origin: org.n52.security/52n-security-enforcement-impl

.all("//*/ows:Operation[@name='" + entry.getKey() + "']/ows:DCP/ows:HTTP/ows:"
            + SOSInterceptorGlobals.GET).get();
for (int i = 0; i < nl.getLength(); i++) {
        .all("//*/ows:Operation[@name='" + entry.getKey() + "']/ows:DCP/ows:HTTP/ows:"
            + SOSInterceptorGlobals.POST).get();
for (int i = 0; i < nl.getLength(); i++) {

代码示例来源:origin: org.n52.security/52n-security-gatekeeper

public Payload replace(String pOldURL, Transferable res, String pEncoding, String pMimeType) {
  Document doc = DOMParser.createNew().parse(new InputSource(res.getPayload().getAsStream()));
  XMLPathCtx ctx = XMLPathCtx.createNew();
  NodeList nodes = ctx.findIn(doc).all("//OnlineResource").get();
  for (int i = 0; i < nodes.getLength(); i++) {
    Node node = nodes.item(i);
    if (node.getParentNode().getParentNode().getLocalName().equals("HTTP")) {
      String name = node.getParentNode().getLocalName();
      node.getParentNode().getParentNode().replaceChild(buildReplacement(name, doc), node.getParentNode());
    }
  }
  // WMS 1.?
  // TODO extend XPath for POST nodes: //DCPType/HTTP/*[self::Get
  // or self::Post]/OnlineResource
  // WFS 1.1
  // TODO extend XPath for POST nodes:
  // //ows:Operation/ows:DCP/ows:HTTP/*[self::ows:Get or
  // self::ows:Post]
  // WFS 1.0
  // TODO add XPath for WFS 1.0.0: //DCPType/HTTP/*[self::Get or
  // self::Post]/@onlineResource
  
  DOMSerializer serializer = DOMSerializer.createNew();
  String response = serializer.serializeToString(doc);
  Pattern lPattern = Pattern.compile(pOldURL.replaceAll("\\?", "\\\\?"));
  Matcher mMatcher = lPattern.matcher(response);
  response = mMatcher.replaceAll(m_gatekeeperURL);
  sLogger.debug("Modified ResponseDocument:\n" + response);
  return new TextualPayload(response, pEncoding);
}

代码示例来源:origin: org.n52.security/52n-security-decision-xacml

private void fillObligationFromElem(ObligationType obligation, Element oblElem) {
    String oblId = oblElem.getAttribute("ObligationId");
    String oblFulfillOn = oblElem.getAttribute("FulfillOn");
    obligation.setObligationId(oblId);
    obligation.setFulfillOn(EffectType.Enum.forString(oblFulfillOn));

    NodeList attrAssignmentElems = xmlPathCtx.findIn(oblElem).all("./p:AttributeAssignment").get();

    for (int i = 0; i < attrAssignmentElems.getLength(); i++) {
      Element attAssignmentElem = (Element) attrAssignmentElems.item(i);
      String attributeId = attAssignmentElem.getAttribute("AttributeId");
      AttributeAssignmentType attributeAssignment = obligation.addNewAttributeAssignment();
      attributeAssignment.setAttributeId(attributeId);
      attributeAssignment.setDataType(attAssignmentElem.getAttribute("DataType"));
      ((XmlObjectBase) attributeAssignment).setStringValue("Three");
    }

  }
}

代码示例来源:origin: org.n52.security/52n-security-enforcement-impl

NodeList nl = ctx.findIn(doc).all("//*/ows:Operation[@name]").get();
Map<String, Node> nodesMap = new HashMap<String, Node>();

代码示例来源:origin: org.n52.metadata/smarteditor-api

innerMap.put("title", title);
innerMap.put("resourceType", lResourceType);
NodeList identifiers = context.findIn(record).all("//gmd:identificationInfo[1]/*/gmd:citation/*/gmd:identifier/*").get();
List<String> resourceIdList = new ArrayList<>();
for (int i = 0; i < identifiers.getLength(); i++) {

代码示例来源:origin: org.n52.metadata/smarteditor-api

NodeList nodes = xmlPathContextFactory.createContext().findIn(lDoc).all("//" + mMultiElementName + "/*").get();
for (int i = 0; i < nodes.getLength(); i++) {
  String nodeStr = DOMUtil.nodeToString(nodes.item(i));

代码示例来源:origin: org.n52.security/52n-security-enforcement-impl

NodeList nl = ctx.findIn(doc).all("/wps:Capabilities/wps:ProcessOfferings/wps:Process/ows:Identifier/text()").get();
for (int i = 0; i < nl.getLength(); i++) {
  Node processIdTextNode = nl.item(i);

代码示例来源:origin: org.n52.security/52n-security-wss

private List<AuthenticationMethod> getSupportedAuthenticationMethods() {
    List<AuthenticationMethod> supportedAuthNMethods = new ArrayList<AuthenticationMethod>();
    NodeList authenticationMethodList = m_xPathCtx.findIn(m_capsDoc).all("//authn:AuthenticationMethod").get();
    for (int i = 0; i < authenticationMethodList.getLength(); i++) {
      org.w3c.dom.Node currentAuthMethod = authenticationMethodList.item(i);
      String type = m_xPathCtx.findIn(currentAuthMethod).text("@xsi:type").get();
      type = type.substring(type.lastIndexOf(":") + 1);
      String method = m_xPathCtx.findIn(currentAuthMethod).text("@method").get();
      AuthenticationMethod supportedAuthMethod;
      if (type.equals("WASType")) {
        org.w3c.dom.Node accAuthNServiceNode = m_xPathCtx.findIn(currentAuthMethod).node("//authn:AuthenticationService").get();
        String wasName = m_xPathCtx.findIn(accAuthNServiceNode).text("authn:Name/text()").get();
        String wasUrl = m_xPathCtx.findIn(accAuthNServiceNode).text("authn:OnlineResource/@xlink:href").get();
        supportedAuthMethod = new org.n52.security.authentication.WASAuthenticationMethod(wasName, wasUrl, "");
      } else {
        supportedAuthMethod = AuthenticationMethodFactory.getDefault().create(method);
      }
      supportedAuthNMethods.add(supportedAuthMethod);
    }
    return supportedAuthNMethods;
  }
}

代码示例来源:origin: org.n52.security/52n-security-decision-xacml

private ResponseDocument convertToXACML1XmlBeanResponse(String xmlChunk) {
  Document responseChunk = DOMParser.createNew().parse(new InputSource(new StringReader(xmlChunk)));
  ResponseDocument responseDoc = ResponseDocument.Factory.newInstance();
  ResponseType response = responseDoc.addNewResponse();
  ResultType result = response.addNewResult();
  result.setDecision(DecisionType.Enum.forString(xmlPathCtx.findIn(responseChunk).text("/c:Response/c:Result[1]/c:Decision/text()").get()));
  result.setResourceId(xmlPathCtx.findIn(responseChunk).text("/c:Response/c:Result[1]/@ResourceId").get());
  NodeList obligationNodes = xmlPathCtx.findIn(responseChunk).all("/c:Response/c:Result[1]/p:Obligations/*").get();
  ObligationsType obligations;
  if (obligationNodes.getLength() > 0) {
    obligations = result.addNewObligations();
    for (int i = 0; i < obligationNodes.getLength(); i++) {
      Element oblElem = (Element) obligationNodes.item(i);
      fillObligationFromElem(obligations.addNewObligation(), oblElem);
    }
  }
  return responseDoc;
}

代码示例来源:origin: org.n52.security/52n-security-facade

public static SAML2IdPMetadata createFrom(Element idpSsoDescrElement) throws MalformedURLException {
  XMLPathCtx xpathCtx = XMLPathCtx.createNew().addNamespace("md", "urn:oasis:names:tc:SAML:2.0:metadata");
  NodeList nodeList = xpathCtx.findIn(idpSsoDescrElement).all("md:SingleSignOnService").get();
  SAML2IdPMetadata metadata = new SAML2IdPMetadata();
  for (int i = 0; i < nodeList.getLength(); i++) {
    Element ssoService = (Element) nodeList.item(i);
    String binding = ssoService.getAttribute("Binding");
    String location = ssoService.getAttribute("Location");
    metadata.addSSOBinding(binding, new URL(location));
  }
  Element organizationElem = (Element) xpathCtx.findIn(idpSsoDescrElement).node("./../md:Organization").get();
  if (organizationElem == null) {
    String entityID = xpathCtx.findIn(idpSsoDescrElement).text("./../@entityID").get();
    metadata.setOrganisationDisplayName(entityID);
  } else {
    String idpDisplayName = xpathCtx.findIn(organizationElem).text("md:OrganizationDisplayName/text()").get();
    metadata.setOrganisationDisplayName(idpDisplayName);
  }
  return metadata;
}

代码示例来源:origin: org.n52.metadata/smarteditor-api

private void addNodes(Node pNode, ITreeNode pTreeNode) {
  ITreeNode lCurrentNode = new TreeNode();
  String lValue = xmlPathContextFactory.createContext().findIn(pNode).text("value").get();
  String lName = xmlPathContextFactory.createContext().findIn(pNode).text("name").get();
  LOG.debug("Node name is: {}", lName);
  LOG.debug("Node value is: {}", lValue);
  // add to pTreeNode
  if (pTreeNode.getName().equals("")) {
    pTreeNode.setId(lValue);
    pTreeNode.setName(lName);
    pTreeNode.setType(lValue);
    lCurrentNode = pTreeNode;
  } else {
    lCurrentNode.setId(lValue);
    lCurrentNode.setName(lName);
    lCurrentNode.setType(lValue);
    pTreeNode.addChild(lCurrentNode);
  }
  lCurrentNode.setObject(new HashMap<>(getDefaultOptions()));
  LOG.debug("added node with id {}", lCurrentNode.getId());
  // has lChildrenList?
  NodeList lChildrenList = xmlPathContextFactory.createContext().findIn(pNode).all("./node").get();
  if (lChildrenList != null) {
    LOG.debug("Node has ChildrenList");
    for (int i = 0; i < lChildrenList.getLength(); i++) {
      addNodes(lChildrenList.item(i), lCurrentNode);
    }
  }
  LOG.debug("node has no ChildrenList");
}

代码示例来源:origin: org.n52.metadata/smarteditor-api

/**
   * validates the backend bean properties against a given schematron (or else) validator
   *
   * @param target
   * @param errors
   */
  public void validate(Object target, Errors errors) {
    BackendBean lBean = (BackendBean) target;
    // chekc if we need to validate
    if (lBean.getValidatorId() != null && !lBean.getValidatorId().equals("")) {
      // apply schematron transformation
      Document lReport = mService.validate(lBean.getValidatorId());
      // add assertions to errors.
      XMLPathCtx context = xmlPathContextFactory.createContext();
      NodeList nodeList = context.findIn(lReport).all("//svrl:failed-assert").get();
      for (int i = 0; i < nodeList.getLength(); i++) {
        Node lNode = nodeList.item(i);
        String id = context.findIn(lNode).text("@id").get();
        String text = context.findIn(lNode).text("svrl:text").get();
        errors.rejectValue(id,text);
      }
    }
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com