Java Code Examples for org.apache.ws.security.WSConstants#WSU_NS

The following examples show how to use org.apache.ws.security.WSConstants#WSU_NS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransportBindingHandler.java    From steady with Apache License 2.0 4 votes vote down vote up
/**
 * Identifies the portions of the message to be signed/encrypted.
 */
private List<WSEncryptionPart> signPartsAndElements(
    SignedEncryptedParts signedParts,
    SignedEncryptedElements signedElements
) throws SOAPException {
    
    List<WSEncryptionPart> result = new ArrayList<WSEncryptionPart>();
    List<Element> found = new ArrayList<Element>();
    
    // Add timestamp
    if (timestampEl != null) {
        WSEncryptionPart timestampPart = 
                new WSEncryptionPart("Timestamp", WSConstants.WSU_NS, "Element");
        String id = addWsuIdToElement(timestampEl.getElement());
        timestampPart.setId(id);
        timestampPart.setElement(timestampEl.getElement());
        
        found.add(timestampPart.getElement());
        result.add(timestampPart);
    }

    // Add SignedParts
    if (signedParts != null) {
        List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
        boolean isSignBody = signedParts.isBody();
        
        for (Header head : signedParts.getHeaders()) {
            WSEncryptionPart wep = 
                new WSEncryptionPart(head.getName(), head.getNamespace(), "Element");
            parts.add(wep);
        }
        
        // Handle sign/enc parts
        result.addAll(this.getParts(true, isSignBody, parts, found));
    }
    
    if (signedElements != null) {
        // Handle SignedElements
        try {
            result.addAll(
                this.getElements(
                    "Element", signedElements.getXPathExpressions(), 
                    signedElements.getDeclaredNamespaces(), found, true
                )
            );
        } catch (XPathExpressionException e) {
            LOG.log(Level.FINE, e.getMessage(), e);
            // REVISIT
        }
    }

    return result;
}
 
Example 2
Source File: TransportBindingHandler.java    From steady with Apache License 2.0 4 votes vote down vote up
/**
 * Identifies the portions of the message to be signed/encrypted.
 */
private List<WSEncryptionPart> signPartsAndElements(
    SignedEncryptedParts signedParts,
    SignedEncryptedElements signedElements
) throws SOAPException {
    
    List<WSEncryptionPart> result = new ArrayList<WSEncryptionPart>();
    List<Element> found = new ArrayList<Element>();
    
    // Add timestamp
    if (timestampEl != null) {
        WSEncryptionPart timestampPart = 
                new WSEncryptionPart("Timestamp", WSConstants.WSU_NS, "Element");
        String id = addWsuIdToElement(timestampEl.getElement());
        timestampPart.setId(id);
        timestampPart.setElement(timestampEl.getElement());
        
        found.add(timestampPart.getElement());
        result.add(timestampPart);
    }

    // Add SignedParts
    if (signedParts != null) {
        List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
        boolean isSignBody = signedParts.isBody();
        
        for (Header head : signedParts.getHeaders()) {
            WSEncryptionPart wep = 
                new WSEncryptionPart(head.getName(), head.getNamespace(), "Element");
            parts.add(wep);
        }
        
        // Handle sign/enc parts
        result.addAll(this.getParts(true, isSignBody, parts, found));
    }
    
    if (signedElements != null) {
        // Handle SignedElements
        try {
            result.addAll(
                this.getElements(
                    "Element", signedElements.getXPathExpressions(), 
                    signedElements.getDeclaredNamespaces(), found, true
                )
            );
        } catch (XPathExpressionException e) {
            LOG.log(Level.FINE, e.getMessage(), e);
            // REVISIT
        }
    }

    return result;
}
 
Example 3
Source File: TransportBindingHandler.java    From steady with Apache License 2.0 4 votes vote down vote up
/**
 * Identifies the portions of the message to be signed/encrypted.
 */
private List<WSEncryptionPart> signPartsAndElements(
    SignedEncryptedParts signedParts,
    SignedEncryptedElements signedElements
) throws SOAPException {
    
    List<WSEncryptionPart> result = new ArrayList<WSEncryptionPart>();
    List<Element> found = new ArrayList<Element>();
    
    // Add timestamp
    if (timestampEl != null) {
        WSEncryptionPart timestampPart = 
                new WSEncryptionPart("Timestamp", WSConstants.WSU_NS, "Element");
        String id = addWsuIdToElement(timestampEl.getElement());
        timestampPart.setId(id);
        timestampPart.setElement(timestampEl.getElement());
        
        found.add(timestampPart.getElement());
        result.add(timestampPart);
    }

    // Add SignedParts
    if (signedParts != null) {
        List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
        boolean isSignBody = signedParts.isBody();
        
        for (Header head : signedParts.getHeaders()) {
            WSEncryptionPart wep = 
                new WSEncryptionPart(head.getName(), head.getNamespace(), "Element");
            parts.add(wep);
        }
        
        // Handle sign/enc parts
        result.addAll(this.getParts(true, isSignBody, parts, found));
    }
    
    if (signedElements != null) {
        // Handle SignedElements
        try {
            result.addAll(
                this.getElements(
                    "Element", signedElements.getXPathExpressions(), 
                    signedElements.getDeclaredNamespaces(), found, true
                )
            );
        } catch (XPathExpressionException e) {
            LOG.log(Level.FINE, e.getMessage(), e);
            // REVISIT
        }
    }

    return result;
}
 
Example 4
Source File: TransportBindingHandler.java    From steady with Apache License 2.0 4 votes vote down vote up
/**
 * Identifies the portions of the message to be signed/encrypted.
 */
private List<WSEncryptionPart> signPartsAndElements(
    SignedEncryptedParts signedParts,
    SignedEncryptedElements signedElements
) throws SOAPException {
    
    List<WSEncryptionPart> result = new ArrayList<WSEncryptionPart>();
    List<Element> found = new ArrayList<Element>();
    
    // Add timestamp
    if (timestampEl != null) {
        WSEncryptionPart timestampPart = 
                new WSEncryptionPart("Timestamp", WSConstants.WSU_NS, "Element");
        String id = addWsuIdToElement(timestampEl.getElement());
        timestampPart.setId(id);
        timestampPart.setElement(timestampEl.getElement());
        
        found.add(timestampPart.getElement());
        result.add(timestampPart);
    }

    // Add SignedParts
    if (signedParts != null) {
        List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
        boolean isSignBody = signedParts.isBody();
        
        for (Header head : signedParts.getHeaders()) {
            WSEncryptionPart wep = 
                new WSEncryptionPart(head.getName(), head.getNamespace(), "Element");
            parts.add(wep);
        }
        
        // Handle sign/enc parts
        result.addAll(this.getParts(true, isSignBody, parts, found));
    }
    
    if (signedElements != null) {
        // Handle SignedElements
        try {
            result.addAll(
                this.getElements(
                    "Element", signedElements.getXPathExpressions(), 
                    signedElements.getDeclaredNamespaces(), found, true
                )
            );
        } catch (XPathExpressionException e) {
            LOG.log(Level.FINE, e.getMessage(), e);
            // REVISIT
        }
    }

    return result;
}