You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by we...@apache.org on 2005/05/21 21:41:01 UTC

cvs commit: ws-fx/wss4j/src/org/apache/ws/security/handler WSS4JHandler.java

werner      2005/05/21 12:41:01

  Modified:    wss4j/src/org/apache/ws/security/handler WSS4JHandler.java
  Log:
  applied patch for JIRA WSFX-49, flexible handling of
  SAML property file.
  Also modified the document conversion to apply c14n
  when serializing to avoid to many namespace declarations.
  
  Revision  Changes    Path
  1.6       +19 -20    ws-fx/wss4j/src/org/apache/ws/security/handler/WSS4JHandler.java
  
  Index: WSS4JHandler.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/wss4j/src/org/apache/ws/security/handler/WSS4JHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WSS4JHandler.java	10 Mar 2005 18:52:09 -0000	1.5
  +++ WSS4JHandler.java	21 May 2005 19:41:01 -0000	1.6
  @@ -39,6 +39,7 @@
   import org.apache.ws.security.util.StringUtil;
   import org.apache.ws.security.util.WSSecurityUtil;
   import org.apache.xml.security.signature.XMLSignature;
  +import org.apache.xml.security.utils.XMLUtils;
   import org.opensaml.SAMLAssertion;
   import org.w3c.dom.Document;
   import org.w3c.dom.Node;
  @@ -369,7 +370,8 @@
               msgContext.setProperty(WSHandlerConstants.SND_SECURITY, doc);
           } else {
               ByteArrayOutputStream os = new ByteArrayOutputStream();
  -            documentToStream(doc, os);
  +            // documentToStream(doc, os);
  +			XMLUtils.outputDOM(doc, os, true);
   
               try {
                   sPart.setContent(new StreamSource(new ByteArrayInputStream(os.toByteArray())));
  @@ -485,7 +487,8 @@
           */
   
           ByteArrayOutputStream os = new ByteArrayOutputStream();
  -        documentToStream(doc, os);
  +        // documentToStream(doc, os);
  +		XMLUtils.outputDOM(doc, os, true);
           try {
               sPart.setContent(new StreamSource(new ByteArrayInputStream(os.toByteArray())));
           } catch (SOAPException se) {
  @@ -967,7 +970,18 @@
           }
           return crypto;
       }
  -
  +    
  +    protected SAMLIssuer loadSamlIssuer() throws JAXRPCException{
  +        String samlPropFile = null;
  +        if ((samlPropFile =
  +                (String) handlerInfo.getHandlerConfig().get(WSHandlerConstants.SAML_PROP_FILE))
  +                == null) {
  +            samlPropFile =
  +                    (String) msgContext.getProperty(WSHandlerConstants.SAML_PROP_FILE);
  +        }
  +        return SAMLIssuerFactory.getInstance(samlPropFile);  
  +    }
  +    
       private void decodeSignatureParameter() throws JAXRPCException {
           sigCrypto = loadSignatureCrypto();
           /* There are currently no other signature parameters that need to be handled
  @@ -1131,15 +1145,7 @@
       private void performSTAction(boolean mu, Document doc)
               throws JAXRPCException {
           WSSAddSAMLToken builder = new WSSAddSAMLToken(actor, mu);
  -
  -        String samlPropFile = null;
  -        if ((samlPropFile =
  -                (String) handlerInfo.getHandlerConfig().get(WSHandlerConstants.SAML_PROP_FILE))
  -                == null) {
  -            samlPropFile =
  -                    (String) msgContext.getProperty(WSHandlerConstants.SAML_PROP_FILE);
  -        }
  -        SAMLIssuer saml = SAMLIssuerFactory.getInstance(samlPropFile);
  +        SAMLIssuer saml = loadSamlIssuer();
           saml.setUsername(username);
           SAMLAssertion assertion = saml.newAssertion();
   
  @@ -1149,16 +1155,9 @@
   
       private void performST_SIGNAction(int actionToDo, boolean mu, Document doc)
               throws JAXRPCException {
  -        String samlPropFile = null;
  -        if ((samlPropFile =
  -                (String) handlerInfo.getHandlerConfig().get(WSHandlerConstants.SAML_PROP_FILE))
  -                == null) {
  -            samlPropFile =
  -                    (String) msgContext.getProperty(WSHandlerConstants.SAML_PROP_FILE);
  -        }
           Crypto crypto = null;
           crypto = loadSignatureCrypto();
  -        SAMLIssuer saml = SAMLIssuerFactory.getInstance(samlPropFile);
  +        SAMLIssuer saml = loadSamlIssuer();
   
           saml.setUsername(username);
           saml.setUserCrypto(crypto);