Examples of newXMLSignature()


Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

        dsc.putNamespacePrefix("http://www.w3.org/2000/09/xmldsig#", "ns2");

        // Create the XMLSignature, but don't sign it yet.
        try {
            SignedInfo si = initSignedInfo(fac);
            XMLSignature signature = fac.newXMLSignature(si, ki);

            // Marshal, generate, and sign the enveloped signature.
            signature.sign(dsc);
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

      //keyInfoElements.add(keyInfoFactory.newX509Data(Arrays.asList(certificates)));
      keyInfoElements.add(keyInfoFactory.newX509Data(Collections.singletonList(certificates[0])));
 
      KeyInfo keyInfo = keyInfoFactory.newKeyInfo(keyInfoElements);
 
      XMLSignature signature = signFactory.newXMLSignature(signedInfo,keyInfo);
 
      Element soapHeader = getFirstChildElement(document.getDocumentElement());
      DOMSignContext signContext = new DOMSignContext(keyPair.getPrivate(),soapHeader);
      signContext.putNamespacePrefix(XMLSignature.XMLNS,"ds");
      signature.sign(signContext);
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

    // Step 5c : Create a DOMSignContext and specify the DSA PrivateKey and
    // location of the resulting XMLSignature's parent element.
    DOMSignContext dsc = new DOMSignContext(kp.getPrivate(), doc);

    // Step 6 : Create the XMLSignature, but don't sign it yet.
    XMLSignature signature = fac.newXMLSignature(si, ki);

    // Step 7 : Marshal, generate, and sign the enveloped signature.
    signature.sign(dsc);

    // Final step : Save XML Signature to a XML file
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

    // Step 5c : Create a DOMSignContext and specify the DSA PrivateKey and
    // location of the resulting XMLSignature's parent element.
    DOMSignContext dsc = new DOMSignContext(kp.getPrivate(), doc.getDocumentElement());

    // Step 6 : Create the XMLSignature, but don't sign it yet.
    XMLSignature signature = fac.newXMLSignature(si, ki);

    // Step 7 : Marshal, generate, and sign the enveloped signature.
    signature.sign(dsc);

    // Final step : Save XML Signature to a XML file
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

        dsc.putNamespacePrefix(XML_DIGSIG_NS, "ns2");

        // Create the XMLSignature, but don't sign it yet.
        try {
            SignedInfo si = initSignedInfo(fac);
            XMLSignature signature = fac.newXMLSignature(si, ki);

            // Marshal, generate, and sign the enveloped signature.
            signature.sign(dsc);
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

                dsc.putNamespacePrefix(XML_DIGSIG_NS, "ns2");

                // Create the XMLSignature, but don't sign it yet.
                try {
                        SignedInfo si = initSignedInfo(fac);
                        XMLSignature signature = fac.newXMLSignature(si, ki);

                        // Marshal, generate, and sign the enveloped signature.
                        signature.sign(dsc);
                } catch (Exception e) {
                        throw new RuntimeException(e);
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

                parent = XmlSignatureHelper.newDocumentBuilder(Boolean.TRUE).newDocument();
            }

            DOMSignContext dsc = createAndConfigureSignContext(parent, keySelector);

            XMLSignature signature = fac.newXMLSignature(si, keyInfo, objects, signatureId, null);
            // generate the signature
            signature.sign(dsc);

            return XmlSignatureHelper.getDocument(parent);
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

                                              fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null),
                                              Collections.singletonList(ref));
            DOMSignContext dsc = new DOMSignContext(privateKey, document.getDocumentElement());
            KeyValue keyValue = keyInfoFactory.newKeyValue(publicKey);
            KeyInfo ki = keyInfoFactory.newKeyInfo(Collections.singletonList(keyValue));
            XMLSignature signature = fac.newXMLSignature(si, ki);
            signature.sign(dsc);
        } catch (Exception e) {
            Logger.warn("Error while signing an XML document.", e);
        }
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

                                              fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null),
                                              Collections.singletonList(ref));
            DOMSignContext dsc = new DOMSignContext(privateKey, document.getDocumentElement());
            KeyValue keyValue = keyInfoFactory.newKeyValue(publicKey);
            KeyInfo ki = keyInfoFactory.newKeyInfo(Collections.singletonList(keyValue));
            XMLSignature signature = fac.newXMLSignature(si, ki);
            signature.sign(dsc);
        } catch (Exception e) {
            Logger.warn("Error while signing an XML document.", e);
        }
View Full Code Here

Examples of javax.xml.crypto.dsig.XMLSignatureFactory.newXMLSignature()

        /*
         * JSR105 ds:Signature creation
         */
        String signatureValueId = signatureConfig.getPackageSignatureId() + "-signature-value";
        javax.xml.crypto.dsig.XMLSignature xmlSignature = signatureFactory
            .newXMLSignature(signedInfo, null, objects, signatureConfig.getPackageSignatureId(),
            signatureValueId);

        /*
         * ds:Signature Marshalling.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.