Package javax.xml.crypto.dsig

Examples of javax.xml.crypto.dsig.XMLSignature.sign()


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

     // Marshal, generate, and sign the enveloped signature.
     signature.sign(dsc);
    
     //Write signature to a binary file if you desire
     /*
     File someFile = new File();
     FileOutputStream fos = new FileOutputStream(SIGNATURE_FILE_BINARY);
View Full Code Here


            DOMSignContext dsc = new DOMSignContext(keyEntry.getPrivateKey(),
                    target);

            XMLSignature signature = signFactory.newXMLSignature(si, ki);

            signature.sign(dsc);

        } catch (Exception e) {
            throw new STSException("Cannot sign xml document: "
                    + e.getMessage(), e);
        }
View Full Code Here

            DOMSignContext dsc = new DOMSignContext(keyEntry.getPrivateKey(),
                    target);

            XMLSignature signature = signFactory.newXMLSignature(si, ki);

            signature.sign(dsc);

        } catch (Exception e) {
            throw new STSException("Cannot sign xml document: "
                    + e.getMessage(), e);
        }
View Full Code Here

            dsc.setNextSibling(xmlSigInsertionPoint);

            // Marshal, generate (and sign) the enveloped signature
            XMLSignature signature = sigFactory.newXMLSignature(signedInfo,
                keyInfo);
            signature.sign(dsc);

            return toJdom(w3cElement);

        } catch (final Exception e) {
            throw new RuntimeException("Error signing SAML element: "
View Full Code Here

            DOMSignContext dsc = new DOMSignContext(keyEntry.getPrivateKey(),
                    target);

            XMLSignature signature = signFactory.newXMLSignature(si, ki);

            signature.sign(dsc);

        } catch (Exception e) {
            throw new STSException("Cannot sign xml document: "
                    + e.getMessage(), e);
        }
View Full Code Here

            DOMSignContext dsc = new DOMSignContext(keyEntry.getPrivateKey(),
                    target);

            XMLSignature signature = signFactory.newXMLSignature(si, ki);

            signature.sign(dsc);

        } catch (Exception e) {
            throw new STSException("Cannot sign xml document: "
                    + e.getMessage(), e);
        }
View Full Code Here

        Document document = this.documentBuilderFactory.newDocumentBuilder().parse(inputStream);
        DOMSignContext signContext = new DOMSignContext(privateKey, document.getDocumentElement());
        XMLSignature signature = this.xmlSignatureFactory.newXMLSignature(this.signedInfo, this.keyInfo);

        signature.sign(signContext);

        StringWriter writer = new StringWriter();
        StreamResult streamResult = new StreamResult(writer);

        TransformerFactory transformerFactory = TransformerFactory.newInstance();
View Full Code Here

      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 ) {
      throw new RuntimeException( e );
    }
View Full Code Here

        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

      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);
    }
   
    private Element getFirstChildElement(Node node)
    {
      Node child = node.getFirstChild();
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.