You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2006/09/15 10:49:00 UTC

svn commit: r446551 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/rampart: ./ builder/ util/

Author: ruchithf
Date: Fri Sep 15 01:48:59 2006
New Revision: 446551

URL: http://svn.apache.org/viewvc?view=rev&rev=446551
Log:
Completed client side signBeforeEncrypt processing of SymmentricBinding

Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TransportBindingBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java?view=diff&rev=446551&r1=446550&r2=446551
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java Fri Sep 15 01:48:59 2006
@@ -79,14 +79,6 @@
     private String timestampId;
     
     private Document document;
-    
-    private Vector encryptionParts;
-    
-    private Vector signatureParts;
-    
-    private Vector endorsedSignatureParts;
-    
-    private Vector signedEndorsedSignatureParts;
 
     private TokenStorage tokenStorage;
     
@@ -169,55 +161,6 @@
         }
         
     }
-    
-    /**
-     * @return Returns the encryptionParts.
-     */
-    public Vector getEncryptionParts() {
-        return encryptionParts;
-    }
-
-    /**
-     * @param encryptionParts The encryptionParts to set.
-     */
-    public void setEncryptionParts(Vector encryptionParts) {
-        this.encryptionParts = encryptionParts;
-    }
-
-    /**
-     * @return Returns the endorsedSignatureParts.
-     */
-    public Vector getEndorsedSignatureParts() {
-        return endorsedSignatureParts;
-    }
-
-    /**
-     * @param endorsedSignatureParts The endorsedSignatureParts to set.
-     */
-    public void addEndorsedSignaturePart(String id) {
-        if(this.endorsedSignatureParts == null) {
-            this.endorsedSignatureParts = new Vector();
-        }
-        
-        this.endorsedSignatureParts.add(id);
-    }
-
-    /**
-     * @return Returns the signatureParts.
-     */
-    public Vector getSignatureParts() {
-        return signatureParts;
-    }
-
-    /**
-     * @param signatureParts The signatureParts to set.
-     */
-    public void addSignaturePart(String id) {
-        if(this.signatureParts == null) {
-            this.signatureParts = new Vector();
-        }
-        this.signatureParts.add(id);
-    }
 
     /**
      * @return Returns the document.
@@ -519,20 +462,4 @@
     public boolean isClientSide() {
         return isClientSide;
     }
-
-    /**
-     * @return Returns the signedendorsedSignatureParts.
-     */
-    public Vector getSignedEndorsedSignatureParts() {
-        return signedEndorsedSignatureParts;
-    }
-
-    public void addSignedEndorsedSignatureParts(String id) {
-        if(this.signedEndorsedSignatureParts == null) {
-            this.signedEndorsedSignatureParts = new Vector();
-        }
-        
-        this.signedEndorsedSignatureParts.add(id);
-    }
-
 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java?view=diff&rev=446551&r1=446550&r2=446551
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/BindingBuilder.java Fri Sep 15 01:48:59 2006
@@ -287,7 +287,7 @@
                     
                     //Add the token to the header
                     Element siblingElem = RampartUtil
-                            .insertSiblingAfter(this.getInsertionLocation(),
+                            .insertSiblingAfter(rmd, this.getInsertionLocation(),
                                     (Element) endSuppTok.getToken());
                     this.setInsertionLocation(siblingElem);
                     
@@ -305,13 +305,13 @@
                             Element bstElem = encrKey.getBinarySecurityTokenElement();
                             if(bstElem != null) {
                                Element siblingElem = RampartUtil
-                                        .insertSiblingAfter(this.getInsertionLocation(),
+                                        .insertSiblingAfter(rmd, this.getInsertionLocation(),
                                                 bstElem);
                                this.setInsertionLocation(siblingElem);
                             }
                             
                             Element siblingElem = RampartUtil
-                                    .insertSiblingAfter(
+                                    .insertSiblingAfter(rmd, 
                                             this.getInsertionLocation(),
                                             encrKey.getEncryptedKeyElement());
                             
@@ -336,8 +336,8 @@
                         WSSecSignature sig = this.getSignatureBuider(rmd, token);
                         Element bstElem = sig.getBinarySecurityTokenElement();
                         if(bstElem != null) {   
-                            bstElem = RampartUtil.insertSiblingAfter(this
-                                    .getInsertionLocation(), bstElem);
+                            bstElem = RampartUtil.insertSiblingAfter(rmd, 
+                                    this.getInsertionLocation(), bstElem);
                             this.setInsertionLocation(bstElem);
                         }
                         endSuppTokMap.put(token, sig);
@@ -349,7 +349,7 @@
                     
                     //Add the UT
                     Element elem = utBuilder.getUsernameTokenElement();
-                    RampartUtil.insertSiblingAfter(this.getInsertionLocation(), elem);
+                    RampartUtil.insertSiblingAfter(rmd, this.getInsertionLocation(), elem);
                     
                     //Move the insert location to th enext element
                     this.setInsertionLocation(elem);
@@ -493,12 +493,14 @@
                 
                 //Add elements to header
                 this.setInsertionLocation(RampartUtil
-                        .insertSiblingAfter(this.getInsertionLocation(),
+                        .insertSiblingAfter(rmd, 
+                                this.getInsertionLocation(),
                                 dkSign.getdktElement()));
 
                 this.setInsertionLocation(RampartUtil.insertSiblingAfter(
-                        this.getInsertionLocation(), dkSign
-                                .getSignatureElement()));
+                        rmd, 
+                        this.getInsertionLocation(), 
+                        dkSign.getSignatureElement()));
 
                 return dkSign.getSignatureValue();
                 
@@ -513,6 +515,31 @@
             //TODO :  Example SAMLTOken Signature
             throw new UnsupportedOperationException("TODO");
         }
+    }
+    
+    /**
+     * Get hold of the token from the token storage
+     * @param rmd
+     * @param tokenId
+     * @param tok
+     * @return
+     * @throws RampartException
+     */
+    protected org.apache.rahas.Token getToken(RampartMessageData rmd, 
+                    String tokenId) throws RampartException {
+        org.apache.rahas.Token tok = null;
+        try {
+            tok = rmd.getTokenStorage().getToken(tokenId);
+        } catch (TrustException e) {
+            throw new RampartException("errorInRetrievingTokenId", 
+                    new String[]{tokenId}, e);
+        }
+        
+        if(tok == null) {
+            throw new RampartException("errorInRetrievingTokenId", 
+                    new String[]{tokenId});
+        }
+        return tok;
     }
     
 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java?view=diff&rev=446551&r1=446550&r2=446551
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/SymmetricBindingBuilder.java Fri Sep 15 01:48:59 2006
@@ -39,6 +39,7 @@
 import org.w3c.dom.Element;
 
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Vector;
 
 
@@ -59,16 +60,14 @@
         //Setup required tokens
         initializeTokens(rmd);
         
-        if(rmd.isClientSide()) {
             
-            if(Constants.ENCRYPT_BEFORE_SIGNING.equals(rpd.getProtectionOrder())) {
-                this.doEncryptBeforeSig(rmd);
-            } else {
-            }
+        if(Constants.ENCRYPT_BEFORE_SIGNING.equals(rpd.getProtectionOrder())) {
+            this.doEncryptBeforeSig(rmd);
         } else {
-            
+            this.doSignBeforeEncrypt(rmd);
         }
-        
+
+    
         log.debug("SymmetricBindingBuilder build invoked : DONE");
         
     }
@@ -97,17 +96,7 @@
             /*
              * Get hold of the token from the token storage
              */
-            try {
-                tok = rmd.getTokenStorage().getToken(tokenId);
-            } catch (TrustException e) {
-                throw new RampartException("errorInRetrievingTokenId", 
-                        new String[]{tokenId}, e);
-            }
-            
-            if(tok == null) {
-                throw new RampartException("errorInRetrievingTokenId", 
-                        new String[]{tokenId});
-            }
+            tok = this.getToken(rmd, tokenId);
 
             /*
              * Attach the token into the message based on token inclusion 
@@ -129,9 +118,7 @@
             Vector encrParts = RampartUtil.getEncryptedParts(rmd);
             
             Document doc = rmd.getDocument();
-            
 
-            
             if(encryptionToken.isDerivedKeys()) {
                 log.debug("Use drived keys");
                 
@@ -237,12 +224,14 @@
                     
                     //Add elements to header
                     this.setInsertionLocation(RampartUtil
-                            .insertSiblingAfter(this.getInsertionLocation(),
+                            .insertSiblingAfter(rmd, 
+                                    this.getInsertionLocation(),
                                     dkSign.getdktElement()));
 
                     this.setInsertionLocation(RampartUtil.insertSiblingAfter(
-                            this.getInsertionLocation(), dkSign
-                                    .getSignatureElement()));
+                            rmd, 
+                            this.getInsertionLocation(),
+                            dkSign.getSignatureElement()));
                     this.mainSigId = RampartUtil.addWsuIdToElement((OMElement)dkSign.getSignatureElement());
                     
                 } catch (ConversationException e) {
@@ -257,44 +246,284 @@
             }
             
             //Do endorsed signatures
-            this.doEndorsedSignatures(rmd, endSuppTokMap);
+            Vector endSigVals = this.doEndorsedSignatures(rmd, endSuppTokMap);
+            for (Iterator iter = endSigVals.iterator(); iter.hasNext();) {
+                signatureValues.add(iter.next());
+            }
             
             //Do signed endorsing signatures
-            this.doEndorsedSignatures(rmd, sgndEndSuppTokMap);
+            Vector sigEndSigVals = this.doEndorsedSignatures(rmd, sgndEndSuppTokMap);
+            for (Iterator iter = sigEndSigVals.iterator(); iter.hasNext();) {
+                signatureValues.add(iter.next());
+            }
+            
+            Vector secondEncrParts = new Vector();
             
             //Check for signature protection
             if(rpd.isSignatureProtection() && this.mainSigId != null) {
                 //Now encrypt the signature using the above token
-                Vector secondEncrParts = new Vector();
                 secondEncrParts.add(new WSEncryptionPart(this.mainSigId, "Element"));
+            }
+            Element secondRefList = null;
+            
+            if(encryptionToken.isDerivedKeys()) {
+                try {
+                    secondRefList = dkEncr.encryptForExternalRef(null, 
+                            secondEncrParts);
+                    RampartUtil.insertSiblingAfter(
+                            rmd, 
+                            encrDKTokenElem, 
+                            secondRefList);
+                } catch (WSSecurityException e) {
+                    throw new RampartException("errorInDKEncr");
+                }
+            } else {
+                try {
+                    //Encrypt, get hold of the ref list and add it
+                    secondRefList = encr.encryptForExternalRef(null,
+                            encrParts);
+                    RampartUtil.insertSiblingAfter(
+                            rmd, 
+                            encrTokenElement,
+                            secondRefList);
+                } catch (WSSecurityException e) {
+                    throw new RampartException("errorInEncryption", e);
+                }    
+            }
+        } else {
+            throw new RampartException("encryptionTokenMissing");
+        }
+    }
+
+
+    public void doSignBeforeEncrypt(RampartMessageData rmd) throws RampartException {
+
+        RampartPolicyData rpd = rmd.getPolicyData();
+        Document doc = rmd.getDocument();
+        
+        Token sigToken = rpd.getSignatureToken();
+        
+        String encrTokId = null;
+        String sigTokId = null;
+        
+        org.apache.rahas.Token encrTok = null;
+        org.apache.rahas.Token sigTok = null;
+        
+        Element sigTokElem = null;
+        
+        Vector signatureValues = new Vector();
+        
+        if(sigToken != null) {
+            if(sigToken instanceof SecureConversationToken) {
+                sigTokId = rmd.getIssuedSignatureTokenId();
+            } else if(sigToken instanceof IssuedToken) {
+                sigTokId = rmd.getSecConvTokenId();
+            }
+        } else {
+            throw new RampartException("signatureTokenMissing");
+        }
+        
+        sigTok = this.getToken(rmd, sigTokId);
+
+        if(Constants.INCLUDE_ALWAYS.equals(sigToken.getInclusion()) ||
+                Constants.INCLUDE_ONCE.equals(sigToken.getInclusion())) {
+            sigTokElem = RampartUtil.appendChildToSecHeader(rmd, sigTok.getToken());
+        }
+
+        this.setInsertionLocation(sigTokElem);
+        
+        Vector sigParts = null;
+        
+//      Now add the supporting tokens
+        SupportingToken sgndSuppTokens = rpd.getSignedSupportingTokens();
+        
+        HashMap sigSuppTokMap = this.handleSupportingTokens(rmd, sgndSuppTokens);
+        
+        SupportingToken endSuppTokens = rpd.getEndorsingSupportingTokens();
+
+        HashMap endSuppTokMap = this.handleSupportingTokens(rmd, endSuppTokens);
+
+        SupportingToken sgndEndSuppTokens = rpd.getSignedEndorsingSupportingTokens();
+        
+        HashMap sgndEndSuppTokMap = this.handleSupportingTokens(rmd, sgndEndSuppTokens);
+
+        //Setup signature parts
+        sigParts = addSignatureParts(sigSuppTokMap, rpd.getSignedParts());
+        sigParts = addSignatureParts(sgndEndSuppTokMap, sigParts);
+        
+        //Sign the message
+        //We should use the same key in the case of EncryptBeforeSig
+        if(sigToken.isDerivedKeys()) {
+            try {
+                WSSecDKSign dkSign = new WSSecDKSign();
+
+                OMElement ref = sigTok.getAttachedReference();
+                if(ref == null) {
+                    ref = sigTok.getUnattachedReference();
+                }
+                if(ref != null) {
+                    dkSign.setExternalKey(sigTok.getSecret(), (Element) 
+                            doc.importNode((Element) ref, true));
+                } else {
+                    
+                    dkSign.setExternalKey(sigTok.getSecret(), sigTok.getId());
+                }
+
+                //Set the algo info
+                dkSign.setSignatureAlgorithm(rpd.getAlgorithmSuite().getSymmetricSignature());
                 
-                Element secondRefList = null;
                 
-                if(encryptionToken.isDerivedKeys()) {
-                    try {
-                        secondRefList = dkEncr.encryptForExternalRef(null, 
-                                secondEncrParts);
-                        RampartUtil.insertSiblingAfter(encrDKTokenElem, 
-                                secondRefList);
-                    } catch (WSSecurityException e) {
-                        throw new RampartException("errorInDKEncr");
-                    }
-                } else {
-                    try {
-                        //Encrypt, get hold of the ref list and add it
-                        secondRefList = encr.encryptForExternalRef(null,
-                                encrParts);
-                        RampartUtil.insertSiblingAfter(encrTokenElement,
-                                secondRefList);
-                    } catch (WSSecurityException e) {
-                        throw new RampartException("errorInEncryption", e);
-                    }    
+                dkSign.prepare(doc);
+                
+                sigParts.add(new WSEncryptionPart(rmd.getTimestampId()));                          
+                
+                if(rpd.isTokenProtection() && sigTokElem != null) {
+                    sigParts.add(new WSEncryptionPart(sigTokId));
                 }
+                
+                dkSign.setParts(sigParts);
+                
+                dkSign.addReferencesToSign(sigParts, rmd.getSecHeader());
+                
+                //Do signature
+                dkSign.computeSignature();
+                
+                signatureValues.add(dkSign.getSignatureValue());
+                
+                //Add elements to header
+                this.setInsertionLocation(RampartUtil
+                        .insertSiblingAfter(
+                                rmd, 
+                                this.getInsertionLocation(),
+                                dkSign.getdktElement()));
+
+                this.setInsertionLocation(RampartUtil.insertSiblingAfter(
+                        rmd, 
+                        this.getInsertionLocation(), 
+                        dkSign.getSignatureElement()));
+                this.mainSigId = RampartUtil.addWsuIdToElement((OMElement)dkSign.getSignatureElement());
+                
+            } catch (ConversationException e) {
+                throw new RampartException(
+                        "errorInDerivedKeyTokenSignature", e);
+            } catch (WSSecurityException e) {
+                throw new RampartException(
+                        "errorInDerivedKeyTokenSignature", e);
             }
+        } else {
+            //TODO :  Example SAMLTOken Signature
+        }
+
+        //Do endorsed signatures
+        Vector endSigVals = this.doEndorsedSignatures(rmd, endSuppTokMap);
+        for (Iterator iter = endSigVals.iterator(); iter.hasNext();) {
+            signatureValues.add(iter.next());
+        }
+        
+        //Do signed endorsing signatures
+        Vector sigEndSigVals = this.doEndorsedSignatures(rmd, sgndEndSuppTokMap);
+        for (Iterator iter = sigEndSigVals.iterator(); iter.hasNext();) {
+            signatureValues.add(iter.next());
+        }
+
+        //Encryption
+        Token encrToken = rpd.getEncryptionToken();
+        Element encrTokElem = null;
+        if(sigToken.equal(encrToken)) {
+            //Use the same token
+            encrTokId = sigTokId;
+            encrTok = sigTok;
+            encrTokElem = sigTokElem;
+        } else {
+            encrTokId = rmd.getIssuedEncryptionTokenId();
+            encrTok = this.getToken(rmd, encrTokId);
+            
+            if(Constants.INCLUDE_ALWAYS.equals(encrToken.getInclusion()) ||
+                    Constants.INCLUDE_ONCE.equals(encrToken.getInclusion())) {
+                encrTokElem = (Element)sigTok.getToken();
+                
+                //Add the encrToken element before the sigToken element
+                RampartUtil.insertSiblingBefore(rmd, sigTokElem, encrTokElem);
+            }
+            
+        }
+        
+        Vector encrParts = RampartUtil.getEncryptedParts(rmd);
+        
+        //Check for signature protection
+        if(rpd.isSignatureProtection() && this.mainSigId != null) {
+            //Now encrypt the signature using the above token
+            encrParts.add(new WSEncryptionPart(this.mainSigId, "Element"));
+        }
+        Element refList = null;
+        
+        if(encrToken.isDerivedKeys()) {
+            
+            try {
+                WSSecDKEncrypt dkEncr = new WSSecDKEncrypt();
+                
+                if(encrTokElem != null && encrTok.getAttachedReference() != null) {
+                    
+                    dkEncr.setExternalKey(encrTok.getSecret(), (Element) doc
+                            .importNode((Element) encrTok.getAttachedReference(),
+                                    true));
+                    
+                } else if(encrTok.getUnattachedReference() != null) {
+                    dkEncr.setExternalKey(encrTok.getSecret(), (Element) doc
+                            .importNode((Element) encrTok.getUnattachedReference(),
+                                    true));
+                }
+                
+                Element encrDKTokenElem = null;
+                try {
+                    encrDKTokenElem = dkEncr.getdktElement();
+                    RampartUtil.insertSiblingAfter(rmd, encrTokElem, encrDKTokenElem);
+                    dkEncr.prepare(doc);
+                    
+                    refList = dkEncr.encryptForExternalRef(null, encrParts);
+                    
+                } catch (WSSecurityException e) {
+                    throw new RampartException("errorInDKEncr");
+                } catch (ConversationException e) {
+                    throw new RampartException("errorInDKEncr");
+                }
+                
+                refList = dkEncr.encryptForExternalRef(null, 
+                        encrParts);
+                RampartUtil.insertSiblingAfter(rmd, 
+                                                encrDKTokenElem, 
+                                                refList);
+                                                
+            } catch (WSSecurityException e) {
+                throw new RampartException("errorInDKEncr");
+            }
+        } else {
+            try {
+                
+                WSSecEncrypt encr = new WSSecEncrypt();
+                
+                encr.setWsConfig(rmd.getConfig());
+                
+                encr.setEphemeralKey(encrTok.getSecret());
+                encr.setDocument(doc);
+                
+                try {
+                    //Encrypt, get hold of the ref list and add it
+                    refList = encr.encryptForExternalRef(null, encrParts);
+                } catch (WSSecurityException e) {
+                    throw new RampartException("errorInEncryption", e);
+                }
+
+                //Encrypt, get hold of the ref list and add it
+                refList = encr.encryptForExternalRef(null, encrParts);
+                RampartUtil.insertSiblingAfter(rmd,
+                                                encrTokElem,
+                                                refList);
+            } catch (WSSecurityException e) {
+                throw new RampartException("errorInEncryption", e);
+            }    
         }
     }
-    
-    
     
     /**
      * Setup the required tokens

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TransportBindingBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TransportBindingBuilder.java?view=diff&rev=446551&r1=446550&r2=446551
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TransportBindingBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/builder/TransportBindingBuilder.java Fri Sep 15 01:48:59 2006
@@ -325,7 +325,4 @@
             return null;
         }
     }
-
-
-    
 }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties?view=diff&rev=446551&r1=446550&r2=446551
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/errors.properties Fri Sep 15 01:48:59 2006
@@ -32,4 +32,6 @@
 errorInEncryption = Error in encryption
 errorInDKEncr = Error in encryption with a derived key
 errorCreatingRahasToken = Error in creating a org.apache.rahas.Token instance
-UnsupportedTokenInSupportingToken = Unsupprted token in supporting tokens
\ No newline at end of file
+UnsupportedTokenInSupportingToken = Unsupprted token in supporting tokens
+encryptionTokenMissing = Encryption token missing
+signatureTokenMissing = Signature token missging
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java?view=diff&rev=446551&r1=446550&r2=446551
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/util/RampartUtil.java Fri Sep 15 01:48:59 2006
@@ -475,7 +475,10 @@
                 elem, true));
     }
 
-    public static Element insertSiblingAfter(Element child, Element sibling) {
+    public static Element insertSiblingAfter(RampartMessageData rmd, Element child, Element sibling) {
+        if(child == null) {
+            appendChildToSecHeader(rmd, sibling);
+        }
         if(child.getOwnerDocument().equals(sibling.getOwnerDocument())) {
             ((OMElement)child).insertSiblingAfter((OMElement)sibling);
             return sibling;
@@ -487,18 +490,44 @@
         
     }
     
+    public static Element insertSiblingBefore(RampartMessageData rmd, Element child, Element sibling) {
+        if(child == null) {
+            appendChildToSecHeader(rmd, sibling);
+        }
+        if(child.getOwnerDocument().equals(sibling.getOwnerDocument())) {
+            ((OMElement)child).insertSiblingBefore((OMElement)sibling);
+            return sibling;
+        } else {
+            Element newSib = (Element)child.getOwnerDocument().importNode(sibling, true);
+            ((OMElement)child).insertSiblingBefore((OMElement)newSib);
+            return newSib;
+        }
+        
+    }
+    
     public static Vector getEncryptedParts(RampartMessageData rmd) {
         RampartPolicyData rpd =  rmd.getPolicyData();
         Vector parts = rpd.getEncryptedParts();
+        if(rpd.isEncryptBody()) {
+            parts.add(new WSEncryptionPart(addWsuIdToElement(rmd
+                    .getMsgContext().getEnvelope().getBody()), "Content"));
+        }
+        
+        return parts;
+    }
+    
+    public static Vector getSignedParts(RampartMessageData rmd) {
+        RampartPolicyData rpd =  rmd.getPolicyData();
+        Vector parts = rpd.getSignedParts();
         if(rpd.isEntireHeadersAndBodySignatures()) {
             //TODO: Handle the headers when wsse11:EncryptedHeader is 
             //implemented
             parts.add(new WSEncryptionPart(addWsuIdToElement(rmd
-                    .getMsgContext().getEnvelope().getBody()), "Content"));
+                    .getMsgContext().getEnvelope().getBody())));
             
         } else if(rpd.isEncryptBody()) {
             parts.add(new WSEncryptionPart(addWsuIdToElement(rmd
-                    .getMsgContext().getEnvelope().getBody()), "Content"));
+                    .getMsgContext().getEnvelope().getBody())));
         }
         
         return parts;



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org