Package org.apache.ws.security

Examples of org.apache.ws.security.SOAPConstants


     * Test getting a DOM Element from WSEncryptionPart directly
     */
    @org.junit.Test
    public void testEncryptionPartDOMElement() throws Exception {
        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
        SOAPConstants soapConstants =
            WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
        WSSecEncrypt encrypt = new WSSecEncrypt();
        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);

        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);
       
        List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
        // Give wrong names to make sure it's picking up the element
        WSEncryptionPart encP =
            new WSEncryptionPart(
                "Incorrect Localname",
                "Incorrect N/S",
                "");
        Element bodyElement = WSSecurityUtil.findBodyElement(doc);
        assert bodyElement != null && "Body".equals(bodyElement.getLocalName());
        encP.setElement(bodyElement);
        parts.add(encP);
        encrypt.setParts(parts);
       
        Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
       
        String outputString =
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
        if (LOG.isDebugEnabled()) {
            LOG.debug(outputString);
        }
        assertTrue (!outputString.contains("testMethod"));
        List<WSSecurityEngineResult> results = verify(encryptedDoc);
       
        QName bodyName = new QName(soapConstants.getEnvelopeURI(), "Body");
        WSSecurityUtil.checkAllElementsProtected(results, WSConstants.ENCR, new QName[]{bodyName});
    }
View Full Code Here


        builder.prepare(doc, crypto);

        /*
         * Set up the parts structure to encrypt the body
         */
        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
                .getDocumentElement());
        java.util.List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
        WSEncryptionPart encP = new WSEncryptionPart(soapConstants
                .getBodyQName().getLocalPart(), soapConstants.getEnvelopeURI(),
                "Content");
        parts.add(encP);

        /*
         * Encrypt the parts (Body), create EncryptedData elements that reference
View Full Code Here

        builder.prepare(doc, crypto);

        /*
         * Set up the parts structure to encrypt the body
         */
        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
                .getDocumentElement());
        java.util.List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
        WSEncryptionPart encP = new WSEncryptionPart(soapConstants
                .getBodyQName().getLocalPart(), soapConstants.getEnvelopeURI(),
                "Content");
        parts.add(encP);

        /*
         * Encrypt the parts (Body), create EncryptedData elements that reference
View Full Code Here

        //
        // prepend elements in the right order to the security header
        //
        prependDKElementToHeader(secHeader);
               
        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(envelope);
        if (parts == null) {
            parts = new Vector();
            WSEncryptionPart encP =
                new WSEncryptionPart(
                    soapConstants.getBodyQName().getLocalPart(),
                    soapConstants.getEnvelopeURI(),
                    "Content"
                );
            parts.add(encP);
        }
        Element externRefList = encryptForExternalRef(null, parts);
View Full Code Here

        Document doc,
        Element envelope,
        String actor,
        boolean doCreate
    ) {
        SOAPConstants sc = getSOAPConstants(envelope);
        Element wsseSecurity = getSecurityHeader(doc, actor, sc);
        if (wsseSecurity != null) {
            return wsseSecurity;
        }
        Element header =
            findChildElement(envelope, sc.getEnvelopeURI(), sc.getHeaderQName().getLocalPart());
        if (header == null && doCreate) {
            header =
                createElementInSameNamespace(envelope, sc.getHeaderQName().getLocalPart());
            header = prependChildElement(envelope, header);
        }
        if (doCreate) {
            wsseSecurity =
                header.getOwnerDocument().createElementNS(WSConstants.WSSE_NS, "wsse:Security");
View Full Code Here

     * @param doc The SOAP envelope as <code>Document</code>
     * @return The value of the <code>wsu:Id</code> attribute of the SOAP body
     * @throws Exception
     */
    protected String setBodyID(Document doc) throws Exception {
        SOAPConstants soapConstants =
            WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
        Element bodyElement =
            (Element) WSSecurityUtil.getDirectChild(
                doc.getFirstChild(),
                soapConstants.getBodyQName().getLocalPart(),
                soapConstants.getEnvelopeURI()
            );
        if (bodyElement == null) {
            throw new Exception("SOAP Body Element node not found");
        }
        return setWsuId(bodyElement);
View Full Code Here

    public Document build(Document doc, WSSecHeader secHeader)
        throws WSSecurityException, ConversationException {
       
        this.prepare(doc, secHeader);
        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());

        if (parts == null) {
            parts = new Vector();
            WSEncryptionPart encP =
                new WSEncryptionPart(
                    soapConstants.getBodyQName().getLocalPart(),
                    soapConstants.getEnvelopeURI(),
                    "Content"
                );
            parts.add(encP);
        }
       
View Full Code Here

       
        if (envelope == null) {
            envelope = document.getDocumentElement();
        }

        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(envelope);
        if (parts == null) {
            parts = new Vector();
            WSEncryptionPart encP =
                new WSEncryptionPart(
                    soapConstants.getBodyQName().getLocalPart(),
                    soapConstants.getEnvelopeURI(),
                    "Content"
                );
            parts.add(encP);
        }
View Full Code Here

        Element keyInfoElement = keyInfo.getElement();
        keyInfoElement.setAttributeNS(
            WSConstants.XMLNS_NS, "xmlns:" + WSConstants.SIG_PREFIX, WSConstants.SIG_NS
        );

        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(envelope);
        if (parts == null) {
            parts = new Vector();
            WSEncryptionPart encP =
                new WSEncryptionPart(
                    soapConstants.getBodyQName().getLocalPart(),
                    soapConstants.getEnvelopeURI(),
                    "Content"
                );
            parts.add(encP);
        }
        Vector encDataRefs = doEncryption(doc, this.symmetricKey, keyInfo, parts);
View Full Code Here

        if (doDebug) {
            log.debug("Beginning signing...");
        }

        prepare(doc, cr, secHeader);
        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());

        if (parts == null) {
            parts = new Vector();
            WSEncryptionPart encP =
                new WSEncryptionPart(
                    soapConstants.getBodyQName().getLocalPart(),
                    soapConstants.getEnvelopeURI(),
                    "Content"
                );
            parts.add(encP);
        }
View Full Code Here

TOP

Related Classes of org.apache.ws.security.SOAPConstants

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.