gpt4 book ai didi

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

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

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

XMLPath.text介绍

[英]Method text, expects a xpath query resulting in a string.
[中]方法文本,需要xpath查询生成字符串。

代码示例

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

private void buildExtentTemplate(Document document, Map<String, String> hashMap, XMLPathCtx xmlPathCtx) {
  hashMap.put("west", xmlPathCtx.findIn(document).text("//gmd:westBoundLongitude/*/text()").get());
  hashMap.put("east", xmlPathCtx.findIn(document).text("//gmd:eastBoundLongitude/*/text()").get());
  hashMap.put("north", xmlPathCtx.findIn(document).text("//gmd:northBoundLatitude/*/text()").get());
  hashMap.put("south", xmlPathCtx.findIn(document).text("//gmd:southBoundLatitude/*/text()").get());
}

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

private void buildPartyTemplate(Document document, Map<String, String> hashMap, XMLPathCtx xmlPathCtx) {
  hashMap.put("IndividualName", xmlPathCtx.findIn(document).text("//gmd:individualName/*/text()").get());
  hashMap.put("PositionName", xmlPathCtx.findIn(document).text("//gmd:positionName/*/text()").get());
  hashMap.put("OrganisationName", xmlPathCtx.findIn(document).text("//gmd:organisationName/*/text()").get());
  hashMap.put("Voice", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:phone/*/gmd:voice/*/text()").get());
  hashMap.put("Fax", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:phone/*/gmd:facsimile/*/text()").get());
  hashMap.put("DeliveryPoint", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:address/*/gmd:deliveryPoint/*/text()").get());
  hashMap.put("City", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:address/*/gmd:city/*/text()").get());
  hashMap.put("AdministrativeArea", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:address/*/gmd:administrativeArea/*/text()").get());
  hashMap.put("PostalCode", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:address/*/gmd:postalCode/*/text()").get());
  hashMap.put("Country", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:address/*/gmd:country/*/text()").get());
  hashMap.put("MailAddress", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:address/*/gmd:electronicMailAddress/*/text()").get());
  hashMap.put("Role", xmlPathCtx.findIn(document).text("//gmd:role/*/@codeListValue").get());
  hashMap.put("Url", xmlPathCtx.findIn(document).text("//gmd:contactInfo/*/gmd:onlineResource/*/gmd:linkage/gmd:URL").get());
}

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

/**
 * Load a builder class defined in '/catalog_api_factory.xml'
 *
 * @param pType xml or kvp is standard, any other type might be given also
 * @param pName Name of the REquest (GetRecords, GetCapabilities, ect)
 * @return Class or null, if not loaded
 */
protected Class loadClass(String pType, String pName) {
  String lExpression = "//api:BuilderFactory/api:Group[@type='" + pType + "']/api:Builder[@name='" + pName + "']/api:class";
  LOG.debug("Evaluating expression: {} ", lExpression);
  String className = xmlPathCtx.findIn(mRoot).text(lExpression).get();
  if (className == null) {
    LOG.warn(lExpression + " could not be evaluated. Result is null.");
    return null;
  }
  try {
    return Class.forName(className);
  } catch (ClassNotFoundException e) {
    LOG.error(e.getMessage());
    return null;
  }
}

代码示例来源: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.metadata/smarteditor-api

String fileIdentifier = xmlPathContextFactory.createContext().findIn(document).text("//gmd:fileIdentifier/gco:CharacterString/text()").get();

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

public String getTemplateFor(Document document) {
  Node rootNode = context.findIn(document).node("/*[1]").get();
  String serviceType = getServiceTypeFrom(rootNode);
  String version = context.findIn(rootNode).text("@version").get();
  return version.equals("") ? templateMap.get(serviceType) : templateMap.get(serviceType + "_" + version);
}

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

for (Document record : records) {
  Map<String, Object> innerMap = new HashMap<>();
  String fileIdentifier = context.findIn(record).text("//gmd:fileIdentifier[1]/*/text()").get();
  String title = context.findIn(record).text("//gmd:identificationInfo[1]/*/gmd:citation/*/gmd:title/*/text()").get();
  String lResourceType = context.findIn(record).text("//gmd:hierarchyLevel[1]/*/@codeListValue").get();
  innerMap.put("title", title);
  innerMap.put("resourceType", lResourceType);
  for (int i = 0; i < identifiers.getLength(); i++) {
    Node node = identifiers.item(i);
    String code = context.findIn(node).text("gmd:code/*/text()").get();
    String codeSpace = context.findIn(node).text("gmd:codeSpace/*/text()").get();
    StringBuilder stringBuilder = new StringBuilder();
    if (!StringUtils.isEmpty(codeSpace)) {

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

public String getAssertionConsumerUrl() {
  return getXpathCtx().findIn(
      m_paosResponse).text("//samlp:AuthnRequest/@AssertionConsumerServiceURL").get();
}

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

/**
 * Creates an instance of this class from an XML file.
 *
 * @param in
 *        a service excpetion XML document
 *
 * @return
 * @throws org.xml.sax.SAXException
 * @throws IOException
 */
public static ServiceException createFromXML(InputSource in) {
  Document excDoc = DOMParser.createNew().parse(in);
  XMLPathCtx pathCtx = XMLPathCtx.createNew();
  String cd = pathCtx.findIn(excDoc).text("//ServiceException/@code").get().trim();
  if (cd.equals(""))
    cd = "No code available";
  String msg = pathCtx.findIn(excDoc).text("//ServiceException/text()").get().trim();
  if (msg.equals(""))
    msg = "No exception information available";
  return new ServiceException(msg, cd);
}

代码示例来源: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.metadata/smarteditor-api

@RequestMapping(value = "/saveTemplate", method = RequestMethod.POST)
  public void saveTemplate(HttpServletResponse response) throws Exception {
    // get backend document
    Document mergeBackend = backendManagerService.mergeBackend();
    String title = xmlPathContextFactory.createContext().findIn(mergeBackend).text("//gmd:title/*/text()").get();
    try {
      templateManager.saveTemplate(title, "MD_Metadata",
          userInfoBean.getUserId() != null ? userInfoBean.getUserId() : "",
          userInfoBean.getGroupId() != null ? userInfoBean.getGroupId() : "",
          "public",
          DOMUtil.convertToString(mergeBackend, false));
    } catch (Exception e) {
      LOG.error(e.getMessage());
      response.sendError(500, e.getMessage());
    }
    LOG.info("Template saved...");
  }
}

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

/**
 * @return
 */
public LicensePrecondition getLicensePrecondition() {
  org.w3c.dom.Node licBroClientElement = m_xPathCtx.findIn(m_capsDoc).node("/wss:WSS_Capabilities/wss:Capability/licb:LicensePrecondition/licb:LicenseBrokerClient").get();
  if (licBroClientElement == null) {
    return null;
  }
  String licenseRedirectURL = m_xPathCtx.findIn(licBroClientElement).text("licb:RedirectURL/text()").get();
  String ssoGetURL = m_xPathCtx.findIn(licBroClientElement).text("licb:SSOGetURL").get();
  if (licenseRedirectURL == null && ssoGetURL == null) {
    String baseUrl = m_xPathCtx.findIn(licBroClientElement).text("ows:DCP/ows:HTTP/ows:Post/text()").get();
    if (baseUrl == null) {
      return null;
    }
    baseUrl = ensureSingleEndingSlash(baseUrl);
    licenseRedirectURL = baseUrl + "getOrCreateLicenseToken.faces";
    ssoGetURL = baseUrl + "getLicenseToken.faces";
  }
  LicensePrecondition licensePrecondition = new LicensePrecondition(ssoGetURL.trim(), licenseRedirectURL.trim(), null);
  return licensePrecondition;
}

代码示例来源: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.metadata/smarteditor-api

/**
 * Simply determines the resource type from the current backend
 *
 * @return
 */
public String getResourceType() {
  if (getMergeDocument() != null) {
    return xmlPathContextFactory.createContext().findIn(getMergeDocument()).text("//gmd:hierarchyLevel/*/@codeListValue").get();
  }
  return null;
}

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

String offeringID = xPath.findIn(offering).text("@gml:id").get();
    String lcContent = xPath.findIn(actual).text("gml:Envelope/gml:lowerCorner/text()").get();
    String ucContent = xPath.findIn(actual).text("gml:Envelope/gml:upperCorner/text()").get();
    String bpContent = xPath.findIn(timePeriod).text("gml:beginPosition/text()").get();
    String epContent = xPath.findIn(timePeriod).text("gml:endPosition/text()").get();

代码示例来源: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

/**
   * 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);
      }
    }
  }
}

代码示例来源: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");
}

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