javax.xml.crypto.dom.DOMCryptoContext Java Examples

The following examples show how to use javax.xml.crypto.dom.DOMCryptoContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DOMKeyValue.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
    DOMCryptoContext context) throws MarshalException {
    Element rsaElem = DOMUtils.createElement(doc, "RSAKeyValue",
                                             XMLSignature.XMLNS,
                                             dsPrefix);
    Element modulusElem = DOMUtils.createElement(doc, "Modulus",
                                                 XMLSignature.XMLNS,
                                                 dsPrefix);
    Element exponentElem = DOMUtils.createElement(doc, "Exponent",
                                                  XMLSignature.XMLNS,
                                                  dsPrefix);
    modulus.marshal(modulusElem, dsPrefix, context);
    exponent.marshal(exponentElem, dsPrefix, context);
    rsaElem.appendChild(modulusElem);
    rsaElem.appendChild(exponentElem);
    parent.appendChild(rsaElem);
}
 
Example #2
Source File: DOMX509IssuerSerial.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial",
                                            XMLSignature.XMLNS, dsPrefix);
    Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName",
                                            XMLSignature.XMLNS, dsPrefix);
    Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber",
                                            XMLSignature.XMLNS, dsPrefix);
    inElem.appendChild(ownerDoc.createTextNode(issuerName));
    snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString()));
    isElem.appendChild(inElem);
    isElem.appendChild(snElem);
    parent.appendChild(isElem);
}
 
Example #3
Source File: DOMDigestMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method invokes the abstract {@link #marshalParams marshalParams}
 * method to marshal any algorithm-specific parameters.
 */
public void marshal(Node parent, String prefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element dmElem = DOMUtils.createElement(ownerDoc, "DigestMethod",
                                            XMLSignature.XMLNS, prefix);
    DOMUtils.setAttribute(dmElem, "Algorithm", getAlgorithm());

    if (params != null) {
        marshalParams(dmElem, prefix);
    }

    parent.appendChild(dmElem);
}
 
Example #4
Source File: DOMDigestMethod.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method invokes the abstract {@link #marshalParams marshalParams}
 * method to marshal any algorithm-specific parameters.
 */
public void marshal(Node parent, String prefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element dmElem = DOMUtils.createElement(ownerDoc, "DigestMethod",
                                            XMLSignature.XMLNS, prefix);
    DOMUtils.setAttribute(dmElem, "Algorithm", getAlgorithm());

    if (params != null) {
        marshalParams(dmElem, prefix);
    }

    parent.appendChild(dmElem);
}
 
Example #5
Source File: DOMSignedInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element siElem = DOMUtils.createElement(ownerDoc, "SignedInfo",
                                            XMLSignature.XMLNS, dsPrefix);

    // create and append CanonicalizationMethod element
    DOMCanonicalizationMethod dcm =
        (DOMCanonicalizationMethod)canonicalizationMethod;
    dcm.marshal(siElem, dsPrefix, context);

    // create and append SignatureMethod element
    ((DOMStructure)signatureMethod).marshal(siElem, dsPrefix, context);

    // create and append Reference elements
    for (Reference reference : references) {
        ((DOMReference)reference).marshal(siElem, dsPrefix, context);
    }

    // append Id attribute
    DOMUtils.setAttributeID(siElem, "Id", id);

    parent.appendChild(siElem);
    localSiElem = siElem;
}
 
Example #6
Source File: ApacheTransform.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void init(XMLStructure parent, XMLCryptoContext context)
    throws InvalidAlgorithmParameterException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure) parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #7
Source File: ApacheTransform.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure) parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #8
Source File: DOMKeyValue.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
    DOMCryptoContext context) throws MarshalException {
    Element rsaElem = DOMUtils.createElement(doc, "RSAKeyValue",
                                             XMLSignature.XMLNS,
                                             dsPrefix);
    Element modulusElem = DOMUtils.createElement(doc, "Modulus",
                                                 XMLSignature.XMLNS,
                                                 dsPrefix);
    Element exponentElem = DOMUtils.createElement(doc, "Exponent",
                                                  XMLSignature.XMLNS,
                                                  dsPrefix);
    modulus.marshal(modulusElem, dsPrefix, context);
    exponent.marshal(exponentElem, dsPrefix, context);
    rsaElem.appendChild(modulusElem);
    rsaElem.appendChild(exponentElem);
    parent.appendChild(rsaElem);
}
 
Example #9
Source File: DOMSignatureProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element propElem = DOMUtils.createElement(ownerDoc, "SignatureProperty",
                                              XMLSignature.XMLNS, dsPrefix);

    // set attributes
    DOMUtils.setAttributeID(propElem, "Id", id);
    DOMUtils.setAttribute(propElem, "Target", target);

    // create and append any elements and mixed content
    for (XMLStructure property : content) {
        DOMUtils.appendChild(propElem,
            ((javax.xml.crypto.dom.DOMStructure)property).getNode());
    }

    parent.appendChild(propElem);
}
 
Example #10
Source File: DOMDigestMethod.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method invokes the abstract {@link #marshalParams marshalParams}
 * method to marshal any algorithm-specific parameters.
 */
public void marshal(Node parent, String prefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element dmElem = DOMUtils.createElement(ownerDoc, "DigestMethod",
                                            XMLSignature.XMLNS, prefix);
    DOMUtils.setAttribute(dmElem, "Algorithm", getAlgorithm());

    if (params != null) {
        marshalParams(dmElem, prefix);
    }

    parent.appendChild(dmElem);
}
 
Example #11
Source File: ApacheTransform.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure) parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #12
Source File: DOMSignatureProperties.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element propsElem = DOMUtils.createElement(ownerDoc,
                                               "SignatureProperties",
                                               XMLSignature.XMLNS,
                                               dsPrefix);

    // set attributes
    DOMUtils.setAttributeID(propsElem, "Id", id);

    // create and append any properties
    for (SignatureProperty property : properties) {
        ((DOMSignatureProperty)property).marshal(propsElem, dsPrefix,
                                                 context);
    }

    parent.appendChild(propsElem);
}
 
Example #13
Source File: ApacheCanonicalizer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void init(XMLStructure parent, XMLCryptoContext context)
    throws InvalidAlgorithmParameterException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure)parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #14
Source File: DOMTransform.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method invokes the abstract {@link #marshalParams marshalParams}
 * method to marshal any algorithm-specific parameters.
 */
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element transformElem = null;
    if (parent.getLocalName().equals("Transforms")) {
        transformElem = DOMUtils.createElement(ownerDoc, "Transform",
                                               XMLSignature.XMLNS,
                                               dsPrefix);
    } else {
        transformElem = DOMUtils.createElement(ownerDoc,
                                               "CanonicalizationMethod",
                                               XMLSignature.XMLNS,
                                               dsPrefix);
    }
    DOMUtils.setAttribute(transformElem, "Algorithm", getAlgorithm());

    spi.marshalParams(new javax.xml.crypto.dom.DOMStructure(transformElem),
                      context);

    parent.appendChild(transformElem);
}
 
Example #15
Source File: DOMX509IssuerSerial.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial",
                                            XMLSignature.XMLNS, dsPrefix);
    Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName",
                                            XMLSignature.XMLNS, dsPrefix);
    Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber",
                                            XMLSignature.XMLNS, dsPrefix);
    inElem.appendChild(ownerDoc.createTextNode(issuerName));
    snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString()));
    isElem.appendChild(inElem);
    isElem.appendChild(snElem);
    parent.appendChild(isElem);
}
 
Example #16
Source File: ApacheCanonicalizer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure)parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #17
Source File: DOMKeyValue.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
                      DOMCryptoContext context)
    throws MarshalException
{
    Element dsaElem = DOMUtils.createElement(doc, "DSAKeyValue",
                                             XMLSignature.XMLNS,
                                             dsPrefix);
    // parameters J, Seed & PgenCounter are not included
    Element pElem = DOMUtils.createElement(doc, "P", XMLSignature.XMLNS,
                                           dsPrefix);
    Element qElem = DOMUtils.createElement(doc, "Q", XMLSignature.XMLNS,
                                           dsPrefix);
    Element gElem = DOMUtils.createElement(doc, "G", XMLSignature.XMLNS,
                                           dsPrefix);
    Element yElem = DOMUtils.createElement(doc, "Y", XMLSignature.XMLNS,
                                           dsPrefix);
    p.marshal(pElem, dsPrefix, context);
    q.marshal(qElem, dsPrefix, context);
    g.marshal(gElem, dsPrefix, context);
    y.marshal(yElem, dsPrefix, context);
    dsaElem.appendChild(pElem);
    dsaElem.appendChild(qElem);
    dsaElem.appendChild(gElem);
    dsaElem.appendChild(yElem);
    parent.appendChild(dsaElem);
}
 
Example #18
Source File: AbstractDOMSignatureMethod.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method invokes the {@link #marshalParams marshalParams}
 * method to marshal any algorithm-specific parameters.
 */
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element smElem = DOMUtils.createElement(ownerDoc, "SignatureMethod",
                                            XMLSignature.XMLNS, dsPrefix);
    DOMUtils.setAttribute(smElem, "Algorithm", getAlgorithm());

    if (getParameterSpec() != null) {
        marshalParams(smElem, dsPrefix);
    }

    parent.appendChild(smElem);
}
 
Example #19
Source File: DOMSignedInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element siElem = DOMUtils.createElement(ownerDoc, "SignedInfo",
                                            XMLSignature.XMLNS, dsPrefix);

    // create and append CanonicalizationMethod element
    DOMCanonicalizationMethod dcm =
        (DOMCanonicalizationMethod)canonicalizationMethod;
    dcm.marshal(siElem, dsPrefix, context);

    // create and append SignatureMethod element
    ((DOMStructure)signatureMethod).marshal(siElem, dsPrefix, context);

    // create and append Reference elements
    for (Reference reference : references) {
        ((DOMReference)reference).marshal(siElem, dsPrefix, context);
    }

    // append Id attribute
    DOMUtils.setAttributeID(siElem, "Id", id);

    parent.appendChild(siElem);
    localSiElem = siElem;
}
 
Example #20
Source File: ApacheTransform.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void init(XMLStructure parent, XMLCryptoContext context)
    throws InvalidAlgorithmParameterException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure) parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #21
Source File: DOMKeyValue.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
                      DOMCryptoContext context)
    throws MarshalException
{
    Element dsaElem = DOMUtils.createElement(doc, "DSAKeyValue",
                                             XMLSignature.XMLNS,
                                             dsPrefix);
    // parameters J, Seed & PgenCounter are not included
    Element pElem = DOMUtils.createElement(doc, "P", XMLSignature.XMLNS,
                                           dsPrefix);
    Element qElem = DOMUtils.createElement(doc, "Q", XMLSignature.XMLNS,
                                           dsPrefix);
    Element gElem = DOMUtils.createElement(doc, "G", XMLSignature.XMLNS,
                                           dsPrefix);
    Element yElem = DOMUtils.createElement(doc, "Y", XMLSignature.XMLNS,
                                           dsPrefix);
    p.marshal(pElem, dsPrefix, context);
    q.marshal(qElem, dsPrefix, context);
    g.marshal(gElem, dsPrefix, context);
    y.marshal(yElem, dsPrefix, context);
    dsaElem.appendChild(pElem);
    dsaElem.appendChild(qElem);
    dsaElem.appendChild(gElem);
    dsaElem.appendChild(yElem);
    parent.appendChild(dsaElem);
}
 
Example #22
Source File: DOMDigestMethod.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method invokes the abstract {@link #marshalParams marshalParams}
 * method to marshal any algorithm-specific parameters.
 */
public void marshal(Node parent, String prefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element dmElem = DOMUtils.createElement(ownerDoc, "DigestMethod",
                                            XMLSignature.XMLNS, prefix);
    DOMUtils.setAttribute(dmElem, "Algorithm", getAlgorithm());

    if (params != null) {
        marshalParams(dmElem, prefix);
    }

    parent.appendChild(dmElem);
}
 
Example #23
Source File: ApacheCanonicalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void init(XMLStructure parent, XMLCryptoContext context)
    throws InvalidAlgorithmParameterException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure)parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #24
Source File: ApacheCanonicalizer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure)parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #25
Source File: DOMTransform.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method invokes the abstract {@link #marshalParams marshalParams}
 * method to marshal any algorithm-specific parameters.
 */
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element transformElem = null;
    if (parent.getLocalName().equals("Transforms")) {
        transformElem = DOMUtils.createElement(ownerDoc, "Transform",
                                               XMLSignature.XMLNS,
                                               dsPrefix);
    } else {
        transformElem = DOMUtils.createElement(ownerDoc,
                                               "CanonicalizationMethod",
                                               XMLSignature.XMLNS,
                                               dsPrefix);
    }
    DOMUtils.setAttribute(transformElem, "Algorithm", getAlgorithm());

    spi.marshalParams(new javax.xml.crypto.dom.DOMStructure(transformElem),
                      context);

    parent.appendChild(transformElem);
}
 
Example #26
Source File: DOMX509IssuerSerial.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element isElem = DOMUtils.createElement(ownerDoc, "X509IssuerSerial",
                                            XMLSignature.XMLNS, dsPrefix);
    Element inElem = DOMUtils.createElement(ownerDoc, "X509IssuerName",
                                            XMLSignature.XMLNS, dsPrefix);
    Element snElem = DOMUtils.createElement(ownerDoc, "X509SerialNumber",
                                            XMLSignature.XMLNS, dsPrefix);
    inElem.appendChild(ownerDoc.createTextNode(issuerName));
    snElem.appendChild(ownerDoc.createTextNode(serialNumber.toString()));
    isElem.appendChild(inElem);
    isElem.appendChild(snElem);
    parent.appendChild(isElem);
}
 
Example #27
Source File: DOMSignatureProperties.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element propsElem = DOMUtils.createElement(ownerDoc,
                                               "SignatureProperties",
                                               XMLSignature.XMLNS,
                                               dsPrefix);

    // set attributes
    DOMUtils.setAttributeID(propsElem, "Id", id);

    // create and append any properties
    for (SignatureProperty property : properties) {
        ((DOMSignatureProperty)property).marshal(propsElem, dsPrefix,
                                                 context);
    }

    parent.appendChild(propsElem);
}
 
Example #28
Source File: DOMKeyValue.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
                      DOMCryptoContext context)
    throws MarshalException
{
    Element dsaElem = DOMUtils.createElement(doc, "DSAKeyValue",
                                             XMLSignature.XMLNS,
                                             dsPrefix);
    // parameters J, Seed & PgenCounter are not included
    Element pElem = DOMUtils.createElement(doc, "P", XMLSignature.XMLNS,
                                           dsPrefix);
    Element qElem = DOMUtils.createElement(doc, "Q", XMLSignature.XMLNS,
                                           dsPrefix);
    Element gElem = DOMUtils.createElement(doc, "G", XMLSignature.XMLNS,
                                           dsPrefix);
    Element yElem = DOMUtils.createElement(doc, "Y", XMLSignature.XMLNS,
                                           dsPrefix);
    p.marshal(pElem, dsPrefix, context);
    q.marshal(qElem, dsPrefix, context);
    g.marshal(gElem, dsPrefix, context);
    y.marshal(yElem, dsPrefix, context);
    dsaElem.appendChild(pElem);
    dsaElem.appendChild(qElem);
    dsaElem.appendChild(gElem);
    dsaElem.appendChild(yElem);
    parent.appendChild(dsaElem);
}
 
Example #29
Source File: ApacheCanonicalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException
{
    if (context != null && !(context instanceof DOMCryptoContext)) {
        throw new ClassCastException
            ("context must be of type DOMCryptoContext");
    }
    if (parent == null) {
        throw new NullPointerException();
    }
    if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
        throw new ClassCastException("parent must be of type DOMStructure");
    }
    transformElem = (Element)
        ((javax.xml.crypto.dom.DOMStructure)parent).getNode();
    ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
 
Example #30
Source File: DOMSignedInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    ownerDoc = DOMUtils.getOwnerDocument(parent);
    Element siElem = DOMUtils.createElement(ownerDoc, "SignedInfo",
                                            XMLSignature.XMLNS, dsPrefix);

    // create and append CanonicalizationMethod element
    DOMCanonicalizationMethod dcm =
        (DOMCanonicalizationMethod)canonicalizationMethod;
    dcm.marshal(siElem, dsPrefix, context);

    // create and append SignatureMethod element
    ((DOMStructure)signatureMethod).marshal(siElem, dsPrefix, context);

    // create and append Reference elements
    for (Reference reference : references) {
        ((DOMReference)reference).marshal(siElem, dsPrefix, context);
    }

    // append Id attribute
    DOMUtils.setAttributeID(siElem, "Id", id);

    parent.appendChild(siElem);
    localSiElem = siElem;
}