Package javax.xml.crypto.dsig

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


                                              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);
        }

        return document;
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);

        Document outputDocument = this.documentBuilderFactory.newDocumentBuilder().newDocument();
        DOMResult domResult = new DOMResult(outputDocument);

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

                    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);
        }

        return document;
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

      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

        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);

        Document outputDocument = this.documentBuilderFactory.newDocumentBuilder().newDocument();
        DOMResult domResult = new DOMResult(outputDocument);

        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

        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);

        ByteArrayWriter writer = new ByteArrayWriter();
        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

        if(includeKeyInfoInSignature){
            ki = createKeyInfo(publicKey,x509Certificate);
        }
        XMLSignature signature = fac.newXMLSignature(si, ki);

        signature.sign(dsc);
    }

    private static KeyInfo createKeyInfo(PublicKey publicKey, X509Certificate x509Certificate) throws KeyException {
        KeyInfoFactory keyInfoFactory = fac.getKeyInfoFactory();
        KeyInfo keyInfo = null;
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.