Package org.apache.ws.security.message

Examples of org.apache.ws.security.message.WSSecEncrypt.build()


        wsEncrypt.setKey(key);
        wsEncrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
        wsEncrypt.setDocument(doc);

        // Step 4 :: Encrypting using the key.
        Document encDoc = wsEncrypt.build(doc, crypto, secHeader);

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


        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
        Document doc = unsignedEnvelope.getAsDocument();
        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);       
        Document encryptedDoc = builder.build(doc, crypto, secHeader);
       
        try {
            verify(encryptedDoc);
        } catch (WSSecurityException ex) {
            assertTrue(ex.getErrorCode() == 6);
View Full Code Here

       
        log.info("Before Encrypting ThumbprintSHA1....");
        Document doc = unsignedEnvelope.getAsDocument();
        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);       
        Document encryptedDoc = builder.build(doc, crypto, secHeader);
       
        String outputString =
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
        if (log.isDebugEnabled()) {
            log.debug("Encrypted message with THUMBPRINT_IDENTIFIER:");
View Full Code Here

    
        log.info("Before Encrypting EncryptedKeySHA1....");
        Document doc = unsignedEnvelope.getAsDocument();
        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);       
        Document encryptedDoc = builder.build(doc, crypto, secHeader);
    
        String outputString =
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
        if (log.isDebugEnabled()) {
            log.debug("Encrypted message with ENCRYPTED_KEY_SHA1_IDENTIFIER:");
View Full Code Here

            );
       
        WSSecEncrypt builder = new WSSecEncrypt();
        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
        Document encryptedDoc = builder.build(samlDoc, crypto, secHeader);
       
        //
        // Remove the assertion its place in the security header and then append it
        //
        org.w3c.dom.Element secHeaderElement = secHeader.getSecurityHeader();
View Full Code Here

        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);       
        Document encryptedDoc = builder.build(doc, crypto, secHeader);
       
        try {
            verify(encryptedDoc);
        } catch (WSSecurityException ex) {
            assertTrue(ex.getErrorCode() == 6);
View Full Code Here

        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);
       
        Document signedDoc = sign.build(doc, crypto, secHeader);
        Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);
        /*
         * convert the resulting document into a message first. The toAxisPMessage()
         * method performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
         * as a document again for further processing.
View Full Code Here

        builder.setUserInfo("alice");
        Document doc = unsignedEnvelope.getAsDocument();
        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);
        try {
            builder.build(doc, CryptoFactory.getInstance(), secHeader);
            fail("Expected failure on a bad username");
        } catch (WSSecurityException ex) {
            String expectedError = "No certificates for user alice were found for encryption";
            assertTrue(ex.getMessage().indexOf(expectedError) != -1);
        }
View Full Code Here

        builder.setUserInfo("x509v1cert");
        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
        Document doc = unsignedEnvelope.getAsDocument();
        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);       
        Document encryptedDoc = builder.build(doc, v1Crypto, secHeader);
       
        if (log.isDebugEnabled()) {
            log.debug("Encrypted message with BST_DIRECT_REFERENCE:");
            String outputString =
                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
View Full Code Here

            builder.setUserInfo("x509v1cert");
            builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
            Document doc = unsignedEnvelope.getAsDocument();
            WSSecHeader secHeader = new WSSecHeader();
            secHeader.insertSecurityHeader(doc);       
            builder.build(doc, v1Crypto, secHeader);
            fail("Expected failure when using an X509#v1 certificate with SKI");
        } catch (WSSecurityException ex) {
            // expected
            assertTrue(ex.getMessage().indexOf(
                "An X509 certificate with version 3 must be used for SKI")
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.