Package org.apache.ws.security.message

Examples of org.apache.ws.security.message.WSSignEnvelope


        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
        builder.preSetUsernameToken(doc, "wernerd", "verySecret");
        builder.addCreated(doc);
        builder.addNonce(doc);
       
        WSSignEnvelope sign = new WSSignEnvelope(null, true);
        sign.setUsernameToken(builder);
        sign.setKeyIdentifierType(WSConstants.UT_SIGNING);
        sign.setSignatureAlgorithm(XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
        log.info("Before signing....");
        sign.build(doc, null);
        log.info("Before adding UsernameToken PW Text....");
        Document signedDoc = builder.build(doc, "wernerd", "verySecret");
        Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
        if (log.isDebugEnabled()) {
            log.debug("Message with UserNameToken PW Text:");
View Full Code Here


     *
     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
     */
    public void testX509SignatureDSA_SKI() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("wss4jcertDSA", "security");
        builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
        builder.setSignatureAlgorithm(XMLSignature.ALGO_ID_SIGNATURE_DSA);
       
        // builder.setUserInfo("john", "keypass");
        log.info("Before SigningDSA_SKIDirect....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, crypto);

        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * mehtod performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
View Full Code Here

     *
     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
     */
    public void testX509SignatureDSA_Autodetect() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("wss4jcertDSA", "security");
        builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
       
        // builder.setUserInfo("john", "keypass");
        log.info("Before SigningDSA_Autodetect....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, crypto);

        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * mehtod performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
View Full Code Here

     *
     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
     */
    public void testX509SignatureRSA_Autodetect() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("wss4jcert", "security");
        builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
       
        // builder.setUserInfo("john", "keypass");
        log.info("Before SigningRSA_Autodetect....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, crypto);

        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * mehtod performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
View Full Code Here

        SAMLAssertion assertion = saml.newAssertion();

        String issuerKeyName = saml.getIssuerKeyName();
        String issuerKeyPW = saml.getIssuerKeyPassword();
        Crypto issuerCrypto = saml.getIssuerCrypto();
        WSSignEnvelope wsSign = new WSSignEnvelope();
        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);

        log.info("Before SAMLSignedSenderVouches....");
       
        Document doc = unsignedEnvelope.getAsDocument();
       
        Document signedDoc = wsSign.build(doc, null, assertion, issuerCrypto, issuerKeyName, issuerKeyPW);
        log.info("After SAMLSignedSenderVouches....");

        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * method performs the necessary c14n call to properly set up the signed
View Full Code Here

     *
     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
     */
    public void testX509Signature() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
        log.info("Before Signing....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, CryptoFactory.getInstance());

         /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * mehtod performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
View Full Code Here

     *
     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
     */
    public void testX509Signature() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
        // builder.setUserInfo("john", "keypass");
        log.info("Before Signing....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, crypto);

        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * mehtod performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
View Full Code Here

     *
     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
     */
    public void testDoubleX509Signature() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
        // builder.setUserInfo("john", "keypass");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, crypto);
        Document signedDoc1 = builder.build(signedDoc, crypto);
        verify(signedDoc1);
    }
View Full Code Here

     */
    public void testSigningEncryptionEmbedded() throws Exception {
        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
        SOAPEnvelope envelope = null;
        WSEncryptBody encrypt = new WSEncryptBody();
        WSSignEnvelope sign = new WSSignEnvelope();
       
        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
        encrypt.setKeyIdentifierType(WSConstants.EMBEDDED_KEYNAME);
        encrypt.setKey(key);

        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
        log.info("Before Encryption....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = sign.build(doc, crypto);
        Document encryptedSignedDoc = encrypt.build(signedDoc, crypto);
        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * mehtod performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
View Full Code Here

        saml.setInstanceDoc(doc);
        saml.setUserCrypto(crypto);
        saml.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
        SAMLAssertion assertion = saml.newAssertion();

        WSSignEnvelope wsSign = new WSSignEnvelope();
        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
        wsSign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");

        log.info("Before SAMLSignedKeyHolder....");
       
        /*
         * set up for keyHolder
         */
        Document signedDoc = wsSign.build(doc, crypto, assertion, null, null, null);
        log.info("After SAMLSignedKeyHolder....");

        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * method performs the necessary c14n call to properly set up the signed
View Full Code Here

TOP

Related Classes of org.apache.ws.security.message.WSSignEnvelope

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.