gpt4 book ai didi

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

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

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

XMLPathCtx.findIn介绍

[英]Method findIn constructs a new XMLPath starting in a string source.
[中]方法findIn从字符串源开始构造一个新的XMLPath。

代码示例

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

/**
 * Method findIn constructs a new XMLPath starting in a string source.
 *
 * @param source the source.
 * @return XMLPath.
 */
public XMLPath findIn(final String source) {
  return findIn(DOMParser.createNew().parse(new InputSource(new StringReader(source))));
}

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

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.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-core

/**
 * Method findIn constructs a new XMLPath starting in a InputSource source.
 *
 * @param source the source.
 * @return XMLPath.
 */
public XMLPath findIn(final InputSource source) {
  return findIn(DOMParser.createNew().parse(source));
}

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

public String getValue(Node rootNode, XMLPathCtx context) {
    String nameSpaceURI = getNamespaceURI(rootNode);
    if (startsWith ? nameSpaceURI.startsWith(namespace) : nameSpaceURI.equals(namespace)) {
      if (nodeExists != null && context.findIn(rootNode).node(nodeExists).get() != null) {
        return value;
      } else {
        return value;
      }
    }
    return null;
  }
}

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

private Node getSecuredServiceTypeNode() {
  Node securedServiceTypeNode = m_xPathCtx.findIn(m_capsDoc).node("//wss:SecuredServiceType").get();
  return securedServiceTypeNode;
}

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

public void setAuthenticationMethods(Collection<AuthenticationMethod> methods) {
  Node newSuppAuthMethodsElem = m_capsDoc.createElementNS("http://www.gdi-nrw.org/wss", "SupportedAuthenticationMethodList");
  Node capabilityElement = m_xPathCtx.findIn(m_capsDoc).node("//wss:Capability").get();
  Node lOldSuppAuthMethodsElem =
      m_xPathCtx.findIn(capabilityElement).node("//wss:Capability/wss:SupportedAuthenticationMethodList").get();
  if (lOldSuppAuthMethodsElem != null) {
    capabilityElement.removeChild(lOldSuppAuthMethodsElem);
  }
  AuthenticationMethodDOMRenderer renderer = new AuthenticationMethodDOMRenderer();
  for (AuthenticationMethod method : methods) {
    Element authMethodElem = renderer.render(method);
    Node importedNode = m_capsDoc.importNode(authMethodElem, true);
    newSuppAuthMethodsElem.appendChild(importedNode);
  }
  capabilityElement.appendChild(newSuppAuthMethodsElem);
}

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

public void setLicensePrecondition(LicensePrecondition licenseProcondition) {
  if (licenseProcondition == null) {
    return;
  }
  Node caproot = m_xPathCtx.findIn(m_capsDoc).node("//wss:Capability").get();
  String baseUrl = licenseProcondition.getBaseUrl();
  String redirectUrl = licenseProcondition.getRedirectUrl();
  String ssoUrl = licenseProcondition.getSsoGetUrl();
  String filledTemplate = String.format(licensePreconditionTemplate, baseUrl, ssoUrl, redirectUrl, baseUrl);
  StringReader reader = new StringReader(filledTemplate);
  Document templateDoc = DOMParser.createNew().parse(new InputSource(reader));
  Node importedTemplateNode = m_capsDoc.importNode(templateDoc.getDocumentElement(), true);
  caproot.appendChild(importedTemplateNode);
}

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

public Element getAuthnRequest() {
  return (Element) getXpathCtx().findIn(
      m_paosResponse).node("//samlp:AuthnRequest").get();
}

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

private Node find(final String xpath) {
  Node node = XMLPathCtx.createNew().addNamespaces(namespaces).findIn(sourceDocument).node(xpath).get();
  if (node == null) {
    throw new IllegalArgumentException("XPath <" + xpath + "> must resolve to an node");
  }
  return (Element) node;
}

代码示例来源: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.security/52n-security-facade

public Element getRelayState() {
  return (Element) getXpathCtx().findIn(m_paosResponse).node("//ecp:RelayState").get();
}

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

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