Package javax.xml.crypto.dsig.dom

Examples of javax.xml.crypto.dsig.dom.DOMSignContext


      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


            //doc.appendChild(assertionElement);
           
            // Create a DOMSignContext and specify the DSA PrivateKey and
            // location of the resulting XMLSignature's parent element
           
            DOMSignContext dsc = null;
            KeySelector ks = KeySelector.singletonKeySelector(privKey);
            NodeList nl = assertionElement.getElementsByTagNameNS(assertionElement.getNamespaceURI(), "Issuer");
            Node issuer = null;
            if (nl != null && nl.getLength() > 0) {
                issuer = nl.item(0);
            }
            Node nextSibling = (issuer != null) ? issuer.getNextSibling():null;
            if (nextSibling != null) {
                dsc = new DOMSignContext(ks, assertionElement, nextSibling);
            } else {
                dsc = new DOMSignContext(privKey, assertionElement);
            }
            HashMap map = new HashMap();
            map.put(this.getID(),assertionElement);

            dsc.setURIDereferencer(new DSigResolver(map,assertionElement));
            XMLSignature signature = fac.newXMLSignature(si, ki);
            dsc.putNamespacePrefix("http://www.w3.org/2000/09/xmldsig#", "ds");
           
            // Marshal, generate (and sign) the enveloped signature
            signature.sign(dsc);
           
            signedAssertion = assertionElement;
View Full Code Here

           
           
           
            // Create a DOMSignContext and specify the DSA PrivateKey and
            // location of the resulting XMLSignature's parent element
            DOMSignContext dsc = null;
            KeySelector ks = KeySelector.singletonKeySelector(privKey);
            NodeList nl = assertionElement.getElementsByTagNameNS(assertionElement.getNamespaceURI(), "Issuer");
            Node issuer = null;
            if (nl != null && nl.getLength() > 0) {
                issuer = nl.item(0);
            }
            Node nextSibling = (issuer != null) ? issuer.getNextSibling():null;
            if (nextSibling != null) {
                dsc = new DOMSignContext(ks, assertionElement, nextSibling);
            } else {
                dsc = new DOMSignContext(privKey, assertionElement);
            }
            HashMap map = new HashMap();
            map.put(this.getID(),assertionElement);
           
            dsc.setURIDereferencer(new DSigResolver(map,assertionElement));
            XMLSignature signature = fac.newXMLSignature(si, ki);
            dsc.putNamespacePrefix("http://www.w3.org/2000/09/xmldsig#", "ds");
           
            // Marshal, generate (and sign) the enveloped signature
            signature.sign(dsc);
           
            signedAssertion = assertionElement;
View Full Code Here

            // Prepend the signature element to the security header (after the assertion)
            //
            XMLSignContext signContext = null;
            if (siblingElement != null && siblingElement.getNextSibling() != null) {
                signContext =
                    new DOMSignContext(key, securityHeaderElement, siblingElement.getNextSibling());
            } else {
                signContext = new DOMSignContext(key, securityHeaderElement);
            }
            signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
            if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
                signContext.putNamespacePrefix(
                    WSConstants.C14N_EXCL_OMIT_COMMENTS,
View Full Code Here

            // Prepend the signature element to the security header (after the assertion)
            //
            XMLSignContext signContext = null;
            if (siblingElement != null && siblingElement.getNextSibling() != null) {
                signContext =
                    new DOMSignContext(key, securityHeaderElement, siblingElement.getNextSibling());
            } else {
                signContext = new DOMSignContext(key, securityHeaderElement);
            }
            signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
            if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
                signContext.putNamespacePrefix(
                    WSConstants.C14N_EXCL_OMIT_COMMENTS,
View Full Code Here

      XMLSignature signature = SIGNATURE_FACTORY.newXMLSignature( si, null, Collections.singletonList( obj ), null, null );

      DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
      documentBuilderFactory.setNamespaceAware( true );
      Document signedDoc = documentBuilderFactory.newDocumentBuilder().newDocument();
      DOMSignContext dsc = new DOMSignContext( x509Support.getPrivateKey(), signedDoc );

      signature.sign( dsc );

      return signedDoc;
    } catch ( Exception e ) {
View Full Code Here

    // Step 8: Instantiate a DOMSignContext object, and register the private
    // key with it. The XMLSignContext interface (which DOMSignContext
    // implements) contains context information for generating XML
    // signatures.
    Document doc = dbf.newDocumentBuilder().newDocument();
    DOMSignContext dsc = new DOMSignContext(kp.getPrivate(), doc);

    // Step 9: Sign. The sign() operation in the XMLSignature interface
    // signs the XMLSignature. Under the surface, the method carries out
    // several actions, including computing the digest values for all the
    // References based on the corresponding digest methods, and calculating
View Full Code Here

    KeyValue kv = kif.newKeyValue(kp.getPublic());
    KeyInfo ki = kif.newKeyInfo(Collections.singletonList(kv));

    // 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.
View Full Code Here

    KeyValue kv = kif.newKeyValue(kp.getPublic());
    KeyInfo ki = kif.newKeyInfo(Collections.singletonList(kv));

    // 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.
View Full Code Here

            if(featureBinding.isEndorsingSignature()){
                nextSibling = securityHeader.getLastChild().getNextSibling();
            }
           
            SignedInfo signedInfo = WSSPolicyConsumerImpl.getInstance().constructSignedInfo(context);
            DOMSignContext signContext = null;
            if(nextSibling == null){
                signContext = new DOMSignContext(signingKey,securityHeader.getAsSoapElement());//firstChildElement);
            }else{
                signContext = new DOMSignContext(signingKey,securityHeader.getAsSoapElement(),nextSibling);
            }
            signContext.setURIDereferencer(DSigResolver.getInstance());
            XMLSignature signature = dsigHelper.constructSignature(signedInfo, keyInfo, signaturePolicy.getUUID());
            signContext.put(MessageConstants.WSS_PROCESSING_CONTEXT, context);
            signContext.putNamespacePrefix(MessageConstants.DSIG_NS, MessageConstants.DSIG_PREFIX);
//            XMLUtils.circumventBug2650(context.getSecurableSoapMessage().getSOAPPart());
            signature.sign(signContext);
           
            //For SignatureConfirmation
            List scList = (ArrayList)context.getExtraneousProperty("SignatureConfirmation");
View Full Code Here

TOP

Related Classes of javax.xml.crypto.dsig.dom.DOMSignContext

Copyright © 2018 www.massapicom. 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.