java getvalue_Java DomUtils.getValue方法代码示例

import eu.europa.esig.dss.DomUtils; //导入方法依赖的package包/类

@Override

public List findSignatureScope(final XAdESSignature xadesSignature) {

final List result = new ArrayList();

final Set unsignedObjects = new HashSet();

unsignedObjects.addAll(xadesSignature.getSignatureObjects());

final Set signedObjects = new HashSet();

final List signatureReferences = xadesSignature.getSignatureReferences();

for (final Element signatureReference : signatureReferences) {

final String type = DomUtils.getValue(signatureReference, "@Type");

if (xadesSignature.getXPathQueryHolder().XADES_SIGNED_PROPERTIES.equals(type)) {

continue;

}

final String uri = DomUtils.getValue(signatureReference, "@URI");

final List transformations = getTransformationNames(signatureReference);

if (Utils.isStringBlank(uri)) {

// self contained document

result.add(new XmlRootSignatureScope(transformations));

} else if (uri.startsWith("#")) {

// internal reference

final boolean xPointerQuery = XPointerResourceResolver.isXPointerQuery(uri, true);

if (xPointerQuery) {

final String id = DSSXMLUtils.getIDIdentifier(signatureReference);

final XPointerSignatureScope xPointerSignatureScope = new XPointerSignatureScope(id, uri);

result.add(xPointerSignatureScope);

continue;

}

final String xmlIdOfSignedElement = uri.substring(1);

final String xPathString = XPathQueryHolder.XPATH_OBJECT + "[@Id='" + xmlIdOfSignedElement + "']";

Element signedElement = DomUtils.getElement(xadesSignature.getSignatureElement(), xPathString);

if (signedElement != null) {

if (unsignedObjects.remove(signedElement)) {

signedObjects.add(signedElement);

result.add(new XmlElementSignatureScope(xmlIdOfSignedElement, transformations));

}

} else {

signedElement = DomUtils.getElement(xadesSignature.getSignatureElement().getOwnerDocument().getDocumentElement(),

"//*" + "[@Id='" + xmlIdOfSignedElement + "']");

if (signedElement != null) {

final String namespaceURI = signedElement.getNamespaceURI();

if ((namespaceURI == null) || (!XAdESNamespaces.exists(namespaceURI) && !namespaceURI.equals(XMLSignature.XMLNS))) {

signedObjects.add(signedElement);

result.add(new XmlElementSignatureScope(xmlIdOfSignedElement, transformations));

}

}

}

} else {

// detached file

result.add(new FullSignatureScope(DSSUtils.decodeUrl(uri)));

}

}

return result;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值