gpt4 book ai didi

org.apache.wss4j.common.util.XMLUtils.findElement()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 12:57:40 27 4
gpt4 key购买 nike

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

XMLUtils.findElement介绍

[英]Returns the first element that matches name and namespace.

This is a replacement for a XPath lookup //name with the given namespace. It's somewhat faster than XPath, and we do not deal with prefixes, just with the real namespace URI
[中]返回匹配namenamespace的第一个元素。
这是对给定名称空间的XPath查找//name的替换。它比XPath快一些,我们不处理前缀,只处理真正的名称空间URI

代码示例

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

private DOMX509IssuerSerial getIssuerSerial() throws WSSecurityException {
  if (issuerSerial != null) {
    return issuerSerial;
  }
  Element elem = getFirstElement();
  if (elem == null) {
    return null;
  }
  if (WSS4JConstants.X509_DATA_LN.equals(elem.getLocalName())) {
    elem =
      XMLUtils.findElement(
        elem, WSS4JConstants.X509_ISSUER_SERIAL_LN, WSS4JConstants.SIG_NS
      );
  }
  issuerSerial = new DOMX509IssuerSerial(elem);
  return issuerSerial;
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-dom

/**
 * If there are other types of properties other than Name, Label and Nonce
 * This is provided for extensibility purposes
 *
 * @param properties The properties and values in a Map
 */
public void setProperties(Map<String, String> properties) {
  if (properties != null && !properties.isEmpty()) {
    for (Entry<String, String> entry : properties.entrySet()) {
      String propertyName = entry.getValue();
      //Check whether this property is already there
      //If so change the value
      Element node =
        XMLUtils.findElement(elementProperties, propertyName, ns);
      if (node != null) { //If the node is not null
        Text node1 = getFirstNode(node);
        if (node1 != null) {
          node1.setData(properties.get(propertyName));
        }
      } else {
        addProperty(propertyName, properties.get(propertyName));
      }
    }
  }
}

代码示例来源:origin: apache/cxf

@Override
public void modifySecurityHeader(Element securityHeader) {
  if (securityHeader != null) {
    // Find the Timestamp + change it.
    Element timestampElement =
      XMLUtils.findElement(securityHeader, "Timestamp", WSS4JConstants.WSU_NS);
    Element createdValue =
      XMLUtils.findElement(timestampElement, "Created", WSS4JConstants.WSU_NS);
    ZonedDateTime created = ZonedDateTime.parse(createdValue.getTextContent());
    // Add 5 seconds
    createdValue.setTextContent(DateUtil.getDateTimeFormatter(true).format(created.plusSeconds(5L)));
  }
}

代码示例来源:origin: apache/cxf

@Override
public void modifySecurityHeader(Element securityHeader) {
  if (securityHeader != null) {
    Element signatureElement =
      XMLUtils.findElement(securityHeader, "Signature", WSS4JConstants.SIG_NS);
    Node firstChild = signatureElement.getFirstChild();
    while (!(firstChild instanceof Element) && firstChild != null) {
      firstChild = signatureElement.getNextSibling();
    }
    ((Element)firstChild).setAttributeNS(null, "Id", "xyz");
  }
}

代码示例来源:origin: apache/cxf

@Override
public void modifySecurityHeader(Element securityHeader) {
  if (securityHeader != null) {
    Element encryptedKey =
      XMLUtils.findElement(securityHeader, "EncryptedKey", WSS4JConstants.ENC_NS);
    Element cipherValue =
      XMLUtils.findElement(encryptedKey, "CipherValue", WSS4JConstants.ENC_NS);
    String cipherText = cipherValue.getTextContent();
    StringBuilder stringBuilder = new StringBuilder(cipherText);
    int index = stringBuilder.length() / 2;
    char ch = stringBuilder.charAt(index);
    if (ch != 'A') {
      ch = 'A';
    } else {
      ch = 'B';
    }
    stringBuilder.setCharAt(index, ch);
    cipherValue.setTextContent(stringBuilder.toString());
  }
}

代码示例来源:origin: apache/cxf

public void modifySOAPBody(Element soapBody) {
  if (soapBody != null) {
    Element cipherValue =
      XMLUtils.findElement(soapBody, "CipherValue", WSS4JConstants.ENC_NS);
    String cipherText = cipherValue.getTextContent();
    StringBuilder stringBuilder = new StringBuilder(cipherText);
    int index = stringBuilder.length() / 2;
    char ch = stringBuilder.charAt(index);
    if (ch != 'A') {
      ch = 'A';
    } else {
      ch = 'B';
    }
    stringBuilder.setCharAt(index, ch);
    cipherValue.setTextContent(stringBuilder.toString());
  }
}

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