当前位置: 首页>>代码示例>>Java>>正文


Java XMLUtils类代码示例

本文整理汇总了Java中com.sun.org.apache.xml.internal.security.utils.XMLUtils的典型用法代码示例。如果您正苦于以下问题:Java XMLUtils类的具体用法?Java XMLUtils怎么用?Java XMLUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XMLUtils类属于com.sun.org.apache.xml.internal.security.utils包,在下文中一共展示了XMLUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInclusiveNamespaces

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
public String getInclusiveNamespaces() {
    String c14nMethodURI = c14nMethod.getAttributeNS(null, Constants._ATT_ALGORITHM);
    if (!(c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#") ||
        c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
        return null;
    }

    Element inclusiveElement = XMLUtils.getNextElement(c14nMethod.getFirstChild());

    if (inclusiveElement != null) {
        try {
            String inclusiveNamespaces =
                new InclusiveNamespaces(
                    inclusiveElement,
                    InclusiveNamespaces.ExclusiveCanonicalizationNamespace
                ).getInclusiveNamespaces();
            return inclusiveNamespaces;
        } catch (XMLSecurityException e) {
            return null;
        }
    }
    return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:SignedInfo.java

示例2: itemEncryptedKey

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Method itemEncryptedKey
 *
 * @param i
 * @return the asked EncryptedKey element, null if the index is too big
 * @throws XMLSecurityException
 */
public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
    if (encryptedKeys != null) {
        return encryptedKeys.get(i);
    }
    Element e =
        XMLUtils.selectXencNode(
            this.constructionElement.getFirstChild(), EncryptionConstants._TAG_ENCRYPTEDKEY, i);

    if (e != null) {
        XMLCipher cipher = XMLCipher.getInstance();
        cipher.init(XMLCipher.UNWRAP_MODE, null);
        return cipher.loadEncryptedKey(e);
    }
    return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:KeyInfo.java

示例3: getHTMLRepresentation

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Method getHTMLRepresentation
 *
 * @return The HTML Representation.
 * @throws XMLSignatureException
 */
public String getHTMLRepresentation() throws XMLSignatureException {
    if ((this.xpathNodeSet == null) || (this.xpathNodeSet.size() == 0)) {
        return HTMLPrefix + "<blink>no node set, sorry</blink>" + HTMLSuffix;
    }

    // get only a single node as anchor to fetch the owner document
    Node n = this.xpathNodeSet.iterator().next();

    this.doc = XMLUtils.getOwnerDocument(n);

    try {
        this.writer = new StringWriter();

        this.canonicalizeXPathNodeSet(this.doc);
        this.writer.close();

        return this.writer.toString();
    } catch (IOException ex) {
        throw new XMLSignatureException("empty", ex);
    } finally {
        this.xpathNodeSet = null;
        this.doc = null;
        this.writer = null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:XMLSignatureInputDebugger.java

示例4: addDocument

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * This <code>addDocument</code> method is used to add a new resource to the
 * signed info. A {@link com.sun.org.apache.xml.internal.security.signature.Reference} is built
 * from the supplied values.
 *
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param referenceURI <code>URI</code> attribute in <code>Reference</code> for specifying
 * where data is
 * @param transforms com.sun.org.apache.xml.internal.security.signature.Transforms object with an ordered
 * list of transformations to be performed.
 * @param digestURI The digest algorithm URI to be used.
 * @param referenceId
 * @param referenceType
 * @throws XMLSignatureException
 */
public void addDocument(
    String baseURI, String referenceURI, Transforms transforms,
    String digestURI, String referenceId, String referenceType
) throws XMLSignatureException {
    // the this.doc is handed implicitly by the this.getOwnerDocument()
    Reference ref =
        new Reference(this.doc, baseURI, referenceURI, this, transforms, digestURI);

    if (referenceId != null) {
        ref.setId(referenceId);
    }

    if (referenceType != null) {
        ref.setType(referenceType);
    }

    // add Reference object to our cache vector
    this.references.add(ref);

    // add the Element of the Reference object to the Manifest/SignedInfo
    this.constructionElement.appendChild(ref.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:Manifest.java

示例5: Reference

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Build a {@link Reference} from an {@link Element}
 *
 * @param element <code>Reference</code> element
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param manifest is the {@link Manifest} of {@link SignedInfo} in which the Reference occurs.
 * @param secureValidation whether secure validation is enabled or not
 * We need this because the Manifest has the individual {@link ResourceResolver}s which have
 * been set by the user
 * @throws XMLSecurityException
 */
protected Reference(Element element, String baseURI, Manifest manifest, boolean secureValidation)
    throws XMLSecurityException {
    super(element, baseURI);
    this.secureValidation = secureValidation;
    this.baseURI = baseURI;
    Element el = XMLUtils.getNextElement(element.getFirstChild());
    if (Constants._TAG_TRANSFORMS.equals(el.getLocalName())
        && Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
        transforms = new Transforms(el, this.baseURI);
        transforms.setSecureValidation(secureValidation);
        if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
            Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };

            throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
        }
        el = XMLUtils.getNextElement(el.getNextSibling());
    }
    digestMethodElem = el;
    digestValueElement = XMLUtils.getNextElement(digestMethodElem.getNextSibling());
    this.manifest = manifest;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:Reference.java

示例6: engineGetContextFromElement

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Method engineGetContextFromElement
 *
 * @param element
 */
protected void engineGetContextFromElement(Element element) {
    super.engineGetContextFromElement(element);

    if (element == null) {
        throw new IllegalArgumentException("element null");
    }

    Text hmaclength =
        XMLUtils.selectDsNodeText(element.getFirstChild(), Constants._TAG_HMACOUTPUTLENGTH, 0);

    if (hmaclength != null) {
        this.HMACOutputLength = Integer.parseInt(hmaclength.getData());
        this.HMACOutputLengthSet = true;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:IntegrityHmac.java

示例7: getNodeSet

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Returns the node set from input which was specified as the parameter of
 * {@link XMLSignatureInput} constructor
 * @param circumvent
 *
 * @return the node set
 * @throws SAXException
 * @throws IOException
 * @throws ParserConfigurationException
 * @throws CanonicalizationException
 */
public Set<Node> getNodeSet(boolean circumvent) throws ParserConfigurationException,
    IOException, SAXException, CanonicalizationException {
    if (inputNodeSet != null) {
        return inputNodeSet;
    }
    if (inputOctetStreamProxy == null && subNode != null) {
        if (circumvent) {
            XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(subNode));
        }
        inputNodeSet = new LinkedHashSet<Node>();
        XMLUtils.getSet(subNode, inputNodeSet, excludeNode, excludeComments);
        return inputNodeSet;
    } else if (isOctetStream()) {
        convertToNodes();
        Set<Node> result = new LinkedHashSet<Node>();
        XMLUtils.getSet(subNode, result, null, false);
        return result;
    }

    throw new RuntimeException("getNodeSet() called but no input data present");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:XMLSignatureInput.java

示例8: getNodeSet

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
private Set<Node> getNodeSet(List<NodeFilter> nodeFilters) {
    if (xi.isNeedsToBeExpanded()) {
        XMLUtils.circumventBug2650
            (XMLUtils.getOwnerDocument(xi.getSubNode()));
    }

    Set<Node> inputSet = new LinkedHashSet<Node>();
    XMLUtils.getSet(xi.getSubNode(), inputSet,
                    null, !xi.isExcludeComments());
    Set<Node> nodeSet = new LinkedHashSet<Node>();
    for (Node currentNode : inputSet) {
        Iterator<NodeFilter> it = nodeFilters.iterator();
        boolean skipNode = false;
        while (it.hasNext() && !skipNode) {
            NodeFilter nf = it.next();
            if (nf.isNodeInclude(currentNode) != 1) {
                skipNode = true;
            }
        }
        if (!skipNode) {
            nodeSet.add(currentNode);
        }
    }
    return nodeSet;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ApacheNodeSetData.java

示例9: engineResolveSecretKey

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Method engineResolveSecretKey
 *
 * @param element
 * @param baseURI
 * @param storage
 * @return resolved SecretKey key or null if no {@link SecretKey} could be obtained
 *
 * @throws KeyResolverException
 */
public SecretKey engineResolveSecretKey(
    Element element, String baseURI, StorageResolver storage
) throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
    }

    if (secretKey != null
        && XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
        String name = element.getFirstChild().getNodeValue();
        if (keyName.equals(name)) {
            return secretKey;
        }
    }

    log.log(java.util.logging.Level.FINE, "I can't");
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:SingleKeyResolver.java

示例10: KeyValue

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Constructor KeyValue
 *
 * @param doc
 * @param pk
 */
public KeyValue(Document doc, PublicKey pk) {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (pk instanceof java.security.interfaces.DSAPublicKey) {
        DSAKeyValue dsa = new DSAKeyValue(this.doc, pk);

        this.constructionElement.appendChild(dsa.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    } else if (pk instanceof java.security.interfaces.RSAPublicKey) {
        RSAKeyValue rsa = new RSAKeyValue(this.doc, pk);

        this.constructionElement.appendChild(rsa.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:KeyValue.java

示例11: DSAKeyValue

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:DSAKeyValue.java

示例12: getTransforms

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Method getTransforms
 *
 * @throws XMLSecurityException
 * @return the transformations
 */
public Transforms getTransforms() throws XMLSecurityException {
    try {
        Element transformsElem =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0);

        if (transformsElem != null) {
            return new Transforms(transformsElem, this.baseURI);
        }

        return null;
    } catch (XMLSignatureException ex) {
        throw new XMLSecurityException("empty", ex);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:RetrievalMethod.java

示例13: itemCRL

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Method itemCRL
 *
 * @param i
 * @return the X509CRL, null if not present
 * @throws XMLSecurityException
 */
public XMLX509CRL itemCRL(int i) throws XMLSecurityException {

    Element e =
        XMLUtils.selectDsNode(
            this.constructionElement.getFirstChild(), Constants._TAG_X509CRL, i);

    if (e != null) {
        return new XMLX509CRL(e, this.baseURI);
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:X509Data.java

示例14: getLength

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 * Return the nonnegative number of transformations.
 *
 * @return the number of transformations
 */
public int getLength() {
    if (transforms == null) {
        transforms =
            XMLUtils.selectDsNodes(this.constructionElement.getFirstChild(), "Transform");
    }
    return transforms.length;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Transforms.java

示例15: XMLSignature

import com.sun.org.apache.xml.internal.security.utils.XMLUtils; //导入依赖的package包/类
/**
 *  Creates a XMLSignature in a Document
 * @param doc
 * @param baseURI
 * @param SignatureMethodElem
 * @param CanonicalizationMethodElem
 * @throws XMLSecurityException
 */
public XMLSignature(
    Document doc,
    String baseURI,
    Element SignatureMethodElem,
    Element CanonicalizationMethodElem
) throws XMLSecurityException {
    super(doc);

    String xmlnsDsPrefix = getDefaultPrefix(Constants.SignatureSpecNS);
    if (xmlnsDsPrefix == null || xmlnsDsPrefix.length() == 0) {
        this.constructionElement.setAttributeNS(
            Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS
        );
    } else {
        this.constructionElement.setAttributeNS(
            Constants.NamespaceSpecNS, "xmlns:" + xmlnsDsPrefix, Constants.SignatureSpecNS
        );
    }
    XMLUtils.addReturnToElement(this.constructionElement);

    this.baseURI = baseURI;
    this.signedInfo =
        new SignedInfo(this.doc, SignatureMethodElem, CanonicalizationMethodElem);

    this.constructionElement.appendChild(this.signedInfo.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);

    // create an empty SignatureValue; this is filled by setSignatureValueElement
    signatureValueElement =
        XMLUtils.createElementInSignatureSpace(this.doc, Constants._TAG_SIGNATUREVALUE);

    this.constructionElement.appendChild(signatureValueElement);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:43,代码来源:XMLSignature.java


注:本文中的com.sun.org.apache.xml.internal.security.utils.XMLUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。