dims        2005/08/17 09:45:58

  Modified:    src/org/apache/ws/security/handler WSS4JHandler.java
  Added:       src/org/apache/ws/security/util XMLUtils.java
  Log:
  remove org.apache.axis from files under org.apache.ws.security (to ensure 
that they can work without Axis 1.X)
  
  Revision  Changes    Path
  1.11      +8 -9      
ws-wss4j/src/org/apache/ws/security/handler/WSS4JHandler.java
  
  Index: WSS4JHandler.java
  ===================================================================
  RCS file: 
/home/cvs/ws-wss4j/src/org/apache/ws/security/handler/WSS4JHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- WSS4JHandler.java 17 Aug 2005 03:19:45 -0000      1.10
  +++ WSS4JHandler.java 17 Aug 2005 16:45:58 -0000      1.11
  @@ -130,6 +130,8 @@
       static final String REQUEST_ONLY = "request-only";
       static final String RESPONSE_ONLY = "response-only";
   
  +    public static final java.lang.String ALLOW_FORM_OPTIMIZATION = 
"axis.form.optimization";
  +
       /**
        * Initializes the instance of the handler.
        */
  @@ -148,13 +150,13 @@
       }
   
       public boolean handleRequest(MessageContext mc) {
  -        mc.setProperty(org.apache.axis.SOAPPart.ALLOW_FORM_OPTIMIZATION,
  +        mc.setProperty(ALLOW_FORM_OPTIMIZATION,
               Boolean.TRUE);
           return processMessage(mc, true);
       }
   
       public boolean handleResponse(MessageContext mc) {
  -        mc.setProperty(org.apache.axis.SOAPPart.ALLOW_FORM_OPTIMIZATION,
  +        mc.setProperty(ALLOW_FORM_OPTIMIZATION,
               Boolean.TRUE);
           return processMessage(mc, false);
       }
  @@ -166,7 +168,7 @@
   
           RequestData reqData = new RequestData();
           reqData.setMsgContext(mc);
  -        
  +
           doDebug = log.isDebugEnabled();
           msgContext = (SOAPMessageContext) mc;
           String deployment = null;
  @@ -296,8 +298,7 @@
           }
           if (doDebug) {
               log.debug("WSS4JHandler: orginal SOAP request: ");
  -            log.debug(org.apache.axis.utils.XMLUtils
  -                    .PrettyDocumentToString(doc));
  +            
log.debug(org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc));
           }
           
           soapConstants =
  @@ -564,9 +565,7 @@
               }
           }
   
  -/* JAXRPC conversion changes */
  -/* commented axis specific code */
  -//           ((org.apache.axis.message.SOAPHeaderElement) 
headerElement).setProcessed(true);
  +        /* JAXRPC conversion changes */
           headerElement.setMustUnderstand(false); // is this sufficient?
   
           /*
  @@ -1638,7 +1637,7 @@
               DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance();
               dbf.setNamespaceAware(true);
               DocumentBuilder builder = dbf.newDocumentBuilder();
  -            doc = 
builder.parse(org.apache.axis.utils.XMLUtils.sourceToInputSource(content));
  +            doc = 
builder.parse(org.apache.ws.security.util.XMLUtils.sourceToInputSource(content));
           } catch (Exception ex) {
               throw new JAXRPCException("messageToDocument: cannot convert 
SOAPMessage into Document", ex);
           }
  
  
  
  1.1                  ws-wss4j/src/org/apache/ws/security/util/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  package org.apache.ws.security.util;
  
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  import org.xml.sax.InputSource;
  
  import javax.xml.transform.Source;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.dom.DOMSource;
  import javax.xml.transform.sax.SAXSource;
  import javax.xml.transform.stream.StreamResult;
  import javax.xml.transform.stream.StreamSource;
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.OutputStream;
  
  public class XMLUtils {
      public static String PrettyDocumentToString(Document doc) {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ElementToStream(doc.getDocumentElement(), baos);
          return new String(baos.toByteArray());
      }
  
      public static void ElementToStream(Element element, OutputStream out) {
          try {
              DOMSource source = new DOMSource(element);
              StreamResult result = new StreamResult(out);
              TransformerFactory transFactory = 
TransformerFactory.newInstance();
              Transformer transformer = transFactory.newTransformer();
              transformer.transform(source, result);
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      /**
       * Utility to get the bytes uri
       *
       * @param source the resource to get
       */
      public static InputSource sourceToInputSource(Source source) {
          if (source instanceof SAXSource) {
              return ((SAXSource) source).getInputSource();
          } else if (source instanceof DOMSource) {
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              Node node = ((DOMSource) source).getNode();
              if (node instanceof Document) {
                  node = ((Document) node).getDocumentElement();
              }
              Element domElement = (Element) node;
              ElementToStream(domElement, baos);
              InputSource isource = new InputSource(source.getSystemId());
              isource.setByteStream(new 
ByteArrayInputStream(baos.toByteArray()));
              return isource;
          } else if (source instanceof StreamSource) {
              StreamSource ss = (StreamSource) source;
              InputSource isource = new InputSource(ss.getSystemId());
              isource.setByteStream(ss.getInputStream());
              isource.setCharacterStream(ss.getReader());
              isource.setPublicId(ss.getPublicId());
              return isource;
          } else {
              return getInputSourceFromURI(source.getSystemId());
          }
      }
  
      /**
       * Utility to get the bytes uri.
       * Does NOT handle authenticated URLs,
       * use getInputSourceFromURI(uri, username, password)
       *
       * @param uri the resource to get
       */
      public static InputSource getInputSourceFromURI(String uri) {
          return new InputSource(uri);
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to