axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/transport/http AxisServlet.java
Date Sun, 29 Apr 2001 00:38:26 GMT
gdaniels    01/04/28 17:38:26

  Modified:    java/src/org/apache/axis Message.java
               java/src/org/apache/axis/client HTTPCall.java
               java/src/org/apache/axis/encoding ServiceDescription.java
               java/src/org/apache/axis/handlers
                        SimpleAuthenticationHandler.java
                        SimpleAuthorizationHandler.java
               java/src/org/apache/axis/message SOAPSAXHandler.java
               java/src/org/apache/axis/registries
                        DefaultHandlerRegistry.java
                        DefaultServiceRegistry.java
               java/src/org/apache/axis/transport/http AxisServlet.java
  Added:       java/src/org/apache/axis/handlers/http
                        HTTPActionHandler.java HTTPAuthHandler.java
                        JWSHandler.java
  Removed:     java/src/org/apache/axis/handlers HTTPActionHandler.java
  Log:
  Connect the Message and the ServiceDescription a bit better (it actually
  works now).  See the StockQuote sample for an example.
  
  Move the HTTP-specific handlers down to the new handlers.http package,
  and modularize them better.  The servlet doesn't do much work now, and
  leaves everything to the three HTTP handlers.  These guys are now
  registered on the default HTTP input chain.
  
  Get the transport names from a servlet config parameter instead of hard-
  coding.  This lets us deploy different servlets with different transport
  chains.
  
  Don't fault in simpleAuthentication and simpleAuthorization handlers if
  we don't have the files. (did this so I could test the stock quote sample.
  the real solution is probably to fault if they're on the chain, but don't
  put them on the chain for the stock quote sample - or have two optional
  configurations....)
  
  I think that was it for this round...
  
  Revision  Changes    Path
  1.22      +8 -3      xml-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Message.java	2001/04/27 18:16:00	1.21
  +++ Message.java	2001/04/29 00:38:24	1.22
  @@ -79,7 +79,7 @@
     private Object originalMessage ;
     private Object currentMessage ;
     private String currentForm ;
  -  private boolean isResponse = false;
  +  private String messageType ;
     private ServiceDescription serviceDesc = null;
   
     /**
  @@ -104,7 +104,10 @@
       return( currentForm );
     }
     
  -  public void markAsResponse() { isResponse = true; }
  +  public void setMessageType(String messageType)
  +  {
  +    this.messageType = messageType;
  +  }
     
     public ServiceDescription getServiceDescription()
     {
  @@ -323,8 +326,10 @@
       ThreadedSAXAdapter parser = 
           new ThreadedSAXAdapter(new org.apache.xerces.parsers.SAXParser(), is);
       parser.setServiceDescription(serviceDesc);
  +    SOAPEnvelope env = parser.getEnvelope();
  +    env.setMessageType(messageType);
       
  -    setCurrentMessage( parser.getEnvelope(), "SOAPEnvelope" );
  +    setCurrentMessage( env, "SOAPEnvelope" );
       Debug.Print( 2, "Exit: Message::getAsSOAPEnvelope" );
       return( (SOAPEnvelope) currentMessage );
     }
  
  
  
  1.21      +4 -4      xml-axis/java/src/org/apache/axis/client/HTTPCall.java
  
  Index: HTTPCall.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/HTTPCall.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- HTTPCall.java	2001/04/28 16:29:35	1.20
  +++ HTTPCall.java	2001/04/29 00:38:24	1.21
  @@ -220,12 +220,12 @@
       if (resMsg == null)
           throw new AxisFault(new Exception("Null response message!"));
       
  -    resEnv = (SOAPEnvelope)resMsg.getAs("SOAPEnvelope");
  -    
       /** This must happen before deserialization...
        */
  -    resEnv.setServiceDescription(serviceDesc);
  -    resEnv.setMessageType(ServiceDescription.RESPONSE);
  +    resMsg.setServiceDescription(serviceDesc);
  +    resMsg.setMessageType(ServiceDescription.RESPONSE);
  +    
  +    resEnv = (SOAPEnvelope)resMsg.getAs("SOAPEnvelope");
       
       body = (RPCElement)resEnv.getFirstBody();
       resArgs = body.getParams();
  
  
  
  1.3       +0 -2      xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java
  
  Index: ServiceDescription.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceDescription.java	2001/04/27 15:24:19	1.2
  +++ ServiceDescription.java	2001/04/29 00:38:25	1.3
  @@ -164,8 +164,6 @@
        */
       public QName getParamTypeByName(String messageType, String paramName)
       {
  -        System.out.println("[" + messageType + "] - " + paramName);
  -        
           if (messageType.equals(REQUEST))
               return getInputParamTypeByName(paramName);
           if (messageType.equals(RESPONSE))
  
  
  
  1.9       +47 -43    xml-axis/java/src/org/apache/axis/handlers/SimpleAuthenticationHandler.java
  
  Index: SimpleAuthenticationHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/SimpleAuthenticationHandler.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SimpleAuthenticationHandler.java	2001/03/22 14:49:03	1.8
  +++ SimpleAuthenticationHandler.java	2001/04/29 00:38:25	1.9
  @@ -74,50 +74,54 @@
   public class SimpleAuthenticationHandler extends BasicHandler {
     public void invoke(MessageContext msgContext) throws AxisFault {
       Debug.Print( 1, "Enter: SimpleAuthenticationHandler::invoke" );
  -    try {
  -      String  userID = (String) msgContext.getProperty( MessageContext.USERID );
  -      String  passwd = (String) msgContext.getProperty( MessageContext.PASSWORD );
  -      Debug.Print( 1, "User: " + userID );
  -      Debug.Print( 2, "Pass: " + passwd );
  -
  -      FileReader        fr   = new FileReader( "users.lst" );
  -      LineNumberReader  lnr  = new LineNumberReader( fr );
  -      String            line = null ;
  -      boolean           done = false ;
  -
  -      if ( userID == null || userID.equals("") )
  -        throw new AxisFault( "Server.Unauthorized", 
  -                             "User not authorized",
  -                             null, null );
  -
  -      while ( (line = lnr.readLine()) != null ) {
  -        StringTokenizer  st = new StringTokenizer( line );
  -        String           u  = null ,
  -                         p  = null ;
  -
  -        if ( st.hasMoreTokens() ) u = st.nextToken();
  -        if ( st.hasMoreTokens() ) p = st.nextToken();
  -        Debug.Print( 2, "From file: " + u + ":" + p );
  -
  -        if ( !userID.equals(u) ) continue ;
  -        if ( passwd == null && p != null ) continue ;
  -        if ( passwd != null && !passwd.equals(p) ) continue ;
  -
  -        Debug.Print( 1, "User '" + userID + "' authenticated to server" );
  -        done = true ;
  -        break ;
  +    
  +    File userFile = new File("users.lst");
  +    if (userFile.exists()) {
  +      try {
  +        String  userID = (String) msgContext.getProperty( MessageContext.USERID );
  +        String  passwd = (String) msgContext.getProperty( MessageContext.PASSWORD );
  +        Debug.Print( 1, "User: " + userID );
  +        Debug.Print( 2, "Pass: " + passwd );
  +
  +        FileReader        fr   = new FileReader( userFile );
  +        LineNumberReader  lnr  = new LineNumberReader( fr );
  +        String            line = null ;
  +        boolean           done = false ;
  +
  +        if ( userID == null || userID.equals("") )
  +          throw new AxisFault( "Server.Unauthorized", 
  +            "User not authorized",
  +            null, null );
  +
  +        while ( (line = lnr.readLine()) != null ) {
  +          StringTokenizer  st = new StringTokenizer( line );
  +          String           u  = null ,
  +            p  = null ;
  +
  +          if ( st.hasMoreTokens() ) u = st.nextToken();
  +          if ( st.hasMoreTokens() ) p = st.nextToken();
  +          Debug.Print( 2, "From file: " + u + ":" + p );
  +
  +          if ( !userID.equals(u) ) continue ;
  +          if ( passwd == null && p != null ) continue ;
  +          if ( passwd != null && !passwd.equals(p) ) continue ;
  +
  +          Debug.Print( 1, "User '" + userID + "' authenticated to server" );
  +          done = true ;
  +          break ;
  +        }
  +        lnr.close();
  +        fr.close();
  +        if ( !done ) 
  +          throw new AxisFault( "Server.Unauthorized", 
  +            "User not authenticated",
  +            null, null );
         }
  -      lnr.close();
  -      fr.close();
  -      if ( !done ) 
  -        throw new AxisFault( "Server.Unauthorized", 
  -                             "User not authenticated",
  -                             null, null );
  -    }
  -    catch( Exception e ) {
  -      Debug.Print( 1, e );
  -      if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
  -      throw (AxisFault) e ;
  +      catch( Exception e ) {
  +        Debug.Print( 1, e );
  +        if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
  +        throw (AxisFault) e ;
  +      }
       }
       Debug.Print( 1, "Exit: SimpleAuthenticationHandler::invoke" );
     }
  
  
  
  1.10      +46 -43    xml-axis/java/src/org/apache/axis/handlers/SimpleAuthorizationHandler.java
  
  Index: SimpleAuthorizationHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/SimpleAuthorizationHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SimpleAuthorizationHandler.java	2001/03/22 14:49:03	1.9
  +++ SimpleAuthorizationHandler.java	2001/04/29 00:38:25	1.10
  @@ -76,50 +76,53 @@
   public class SimpleAuthorizationHandler extends BasicHandler {
     public void invoke(MessageContext msgContext) throws AxisFault {
       Debug.Print( 1, "Enter: SimpleAuthenticationHandler::invoke" );
  -    try {
  -      String  userID = (String) msgContext.getProperty( MessageContext.USERID );
  -      String  action = msgContext.getTargetService();
  -
  -      Debug.Print( 1, "User: '" + userID + "'" );
  -      Debug.Print( 1, "Action: '" + action + "'" );
  -
  -      FileReader        fr   = new FileReader( "perms.lst" );
  -      LineNumberReader  lnr  = new LineNumberReader( fr );
  -      String            line = null ;
  -      boolean           done = false ;
  -
  -      if ( userID == null || userID.equals("") )
  -        throw new AxisFault( "Server.Unauthorized", 
  -                             "User not authorized",
  -                             null, null );
  -
  -      while ( (line = lnr.readLine()) != null ) {
  -        StringTokenizer  st = new StringTokenizer( line );
  -        String           u  = null ,
  -                         a  = null ;
  -
  -        if ( st.hasMoreTokens() ) u = st.nextToken();
  -        if ( st.hasMoreTokens() ) a = st.nextToken();
  -        Debug.Print( 2, "From file: '" + u + "':'" + a + "'" );
  -
  -        if ( !userID.equals(u) ) continue ;
  -        if ( !action.equals(a) ) continue ;
  -
  -        Debug.Print( 1, "User '" + userID + "' authorized to: " + a );
  -        done = true ;
  -        break ;
  +    File permFile = new File("perms.lst");
  +    if (permFile.exists()) {
  +      try {
  +        String  userID = (String) msgContext.getProperty( MessageContext.USERID );
  +        String  action = msgContext.getTargetService();
  +
  +        Debug.Print( 1, "User: '" + userID + "'" );
  +        Debug.Print( 1, "Action: '" + action + "'" );
  +
  +        FileReader        fr   = new FileReader( permFile );
  +        LineNumberReader  lnr  = new LineNumberReader( fr );
  +        String            line = null ;
  +        boolean           done = false ;
  +
  +        if ( userID == null || userID.equals("") )
  +          throw new AxisFault( "Server.Unauthorized", 
  +            "User not authorized",
  +            null, null );
  +
  +        while ( (line = lnr.readLine()) != null ) {
  +          StringTokenizer  st = new StringTokenizer( line );
  +          String           u  = null ,
  +            a  = null ;
  +
  +          if ( st.hasMoreTokens() ) u = st.nextToken();
  +          if ( st.hasMoreTokens() ) a = st.nextToken();
  +          Debug.Print( 2, "From file: '" + u + "':'" + a + "'" );
  +
  +          if ( !userID.equals(u) ) continue ;
  +          if ( !action.equals(a) ) continue ;
  +
  +          Debug.Print( 1, "User '" + userID + "' authorized to: " + a );
  +          done = true ;
  +          break ;
  +        }
  +        lnr.close();
  +        fr.close();
  +        if ( !done ) 
  +          throw new AxisFault( "Server.Unauthorized", 
  +            "User not authorized",
  +            null, null );
         }
  -      lnr.close();
  -      fr.close();
  -      if ( !done ) 
  -        throw new AxisFault( "Server.Unauthorized", 
  -                             "User not authorized",
  -                             null, null );
  -    }
  -    catch( Exception e ) {
  -      Debug.Print( 1, e );
  -      if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
  -      throw (AxisFault) e ;
  +      catch( Exception e ) {
  +        Debug.Print( 1, e );
  +        if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
  +        throw (AxisFault) e ;
  +      }
       }
       Debug.Print( 1, "Exit: SimpleAuthorizationHandler::invoke" );
     }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/handlers/http/HTTPActionHandler.java
  
  Index: HTTPActionHandler.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.handlers.http;
  
  import org.apache.axis.*;
  import org.apache.axis.handlers.BasicHandler;
  import org.apache.axis.utils.Debug;
  import org.apache.axis.transport.http.HTTPConstants;
  
  import javax.servlet.* ;
  import javax.servlet.http.* ;
  
  /** An <code>HTTPActionHandler</code> simply sets the context's TargetService
   * property from the HTTPAction property.  We expect there to be a
   * Router on the chain after us, to dispatch to the service named in
   * the SOAPAction.
   * 
   * In the real world, this might do some more complex mapping of
   * SOAPAction to a TargetService.
   * 
   * @author Glen Daniels (gdaniels@allaire.com)
   * @author Doug Davis (dug@us.ibm.com)
   */
  public class HTTPActionHandler extends BasicHandler
  {
      public void invoke(MessageContext msgContext) throws AxisFault
      {
          Debug.Print( 1, "Enter: HTTPActionHandler::invoke" );
          String action = (String) msgContext.getProperty(
                                              HTTPConstants.MC_HTTP_SOAPACTION);
          Debug.Print( 2, "  HTTP SOAPAction: " + action );
          
          /** The idea is that this handler only goes in the chain IF this
           * service does a mapping between SOAPAction and target.  Therefore
           * if we get here with no action, we're in trouble.
           */
          if (action == null)
              throw new AxisFault( "Server.NoHTTPAction",
                  "No HTTPAction property in context",
                  null, null );
          
          action = action.trim();
  
          if (action.charAt(0) == '\"') {
              // assert(action.endsWith("\"")
              action = action.substring(1, action.length() - 1);
          }
  
          msgContext.setTargetService( action );
          Debug.Print( 1, "Exit : HTTPActionHandler::invoke" );
      }
  
      public void undo(MessageContext msgContext) 
      {
          Debug.Print( 1, "Enter: HTTPActionHandler::undo" );
          Debug.Print( 1, "Exit: HTTPActionHandler::undo" );
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/handlers/http/HTTPAuthHandler.java
  
  Index: HTTPAuthHandler.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.handlers.http;
  
  import org.apache.axis.*;
  import org.apache.axis.handlers.BasicHandler;
  import org.apache.axis.utils.Debug;
  import org.apache.axis.encoding.Base64 ;
  import org.apache.axis.transport.http.HTTPConstants;
  
  import javax.servlet.* ;
  import javax.servlet.http.* ;
  
  /** An <code>HTTPAuthHandler</code> simply sets the context's username
   * and password properties from the HTTP auth headers.
   * 
   * @author Glen Daniels (gdaniels@allaire.com)
   * @author Doug Davis (dug@us.ibm.com)
   */
  public class HTTPAuthHandler extends BasicHandler
  {
      public void invoke(MessageContext msgContext) throws AxisFault
      {
          Debug.Print( 1, "Enter: HTTPAuthHandler::invoke" );
          
          HttpServletRequest req = (HttpServletRequest)msgContext.getProperty(
                                        HTTPConstants.MC_HTTP_SERVLETREQUEST);
          
          /* Process the Basic Auth stuff in the headers */
          /***********************************************/
          String tmp = (String)req.getHeader(HTTPConstants.HEADER_AUTHORIZATION);
          if ( tmp != null ) tmp = tmp.trim();
          if ( tmp != null && tmp.startsWith("Basic ") ) {
              String user=null ;
              int  i ;
  
              tmp = new String( Base64.decode( tmp.substring(6) ) );
              i = tmp.indexOf( ':' );
              if ( i == -1 ) user = tmp ;
              else           user = tmp.substring( 0, i);
              msgContext.setProperty( MessageContext.USERID, user );
              if ( i != -1 )  {
                  String pwd = tmp.substring(i+1);
                  if ( pwd != null && pwd.equals("") ) pwd = null ;
                  if ( pwd != null )
                      msgContext.setProperty( MessageContext.PASSWORD, pwd );
              }
          }
  
          Debug.Print( 1, "Exit : HTTPAuthHandler::invoke" );
      }
  
      public void undo(MessageContext msgContext) 
      {
          Debug.Print( 1, "Enter: HTTPActionHandler::undo" );
          Debug.Print( 1, "Exit: HTTPActionHandler::undo" );
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/handlers/http/JWSHandler.java
  
  Index: JWSHandler.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.handlers.http;
  
  import org.apache.axis.*;
  import org.apache.axis.handlers.BasicHandler;
  import org.apache.axis.utils.Debug;
  import org.apache.axis.transport.http.HTTPConstants;
  
  import javax.servlet.* ;
  import javax.servlet.http.* ;
  
  /** A <code>JWSHandler</code> sets the target service and JWS filename
   * in the context depending on the JWS configuration and the target URL.
   * 
   * @author Glen Daniels (gdaniels@allaire.com)
   * @author Doug Davis (dug@us.ibm.com)
   */
  public class JWSHandler extends BasicHandler
  {
      public void invoke(MessageContext msgContext) throws AxisFault
      {
          Debug.Print( 1, "Enter: JWSHandler::invoke" );
          
          HttpServlet        servlet = (HttpServlet) msgContext.getProperty(
                                               HTTPConstants.MC_HTTP_SERVLET);
          ServletConfig      config  = servlet.getServletConfig();
          ServletContext     context = config.getServletContext();
          HttpServletRequest req = (HttpServletRequest) msgContext.getProperty(
                                          HTTPConstants.MC_HTTP_SERVLETREQUEST);
          String URL = req.getServletPath();
          Debug.Print(3, "URL: " + URL );
  
          String   opt     = (String) getOption("JWSProcessor");
          boolean  skipJWS = false ;
          if ( opt != null && (opt.equals("0") || opt.equalsIgnoreCase("NO") ||
                               opt.equalsIgnoreCase("OFF")) )
            skipJWS = true ;
  
          if ( !skipJWS && URL.endsWith(".jws") ) {
              String pathName = context.getRealPath( URL );
              Debug.Print(2, "Path: " + pathName );
              msgContext.setProperty( "JWSFileName", pathName );
              msgContext.setTargetService( Constants.JWSPROCESSOR_TARGET ) ;
          }
  
          Debug.Print( 1, "Exit : JWSHandler::invoke" );
      }
  
      public void undo(MessageContext msgContext) 
      {
          Debug.Print( 1, "Enter: JWSHandler::undo" );
          Debug.Print( 1, "Exit: JWSHandler::undo" );
      }
  }
  
  
  
  1.3       +1 -0      xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java
  
  Index: SOAPSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SOAPSAXHandler.java	2001/04/27 15:24:29	1.2
  +++ SOAPSAXHandler.java	2001/04/29 00:38:26	1.3
  @@ -161,6 +161,7 @@
       public void setServiceDescription(ServiceDescription serviceDesc)
       {
           this.serviceDesc = serviceDesc;
  +        envelope.setServiceDescription(serviceDesc);
       }
       
       public int getState()
  
  
  
  1.5       +8 -0      xml-axis/java/src/org/apache/axis/registries/DefaultHandlerRegistry.java
  
  Index: DefaultHandlerRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/registries/DefaultHandlerRegistry.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultHandlerRegistry.java	2001/04/22 21:05:14	1.4
  +++ DefaultHandlerRegistry.java	2001/04/29 00:38:26	1.5
  @@ -63,6 +63,7 @@
   import org.apache.axis.utils.Admin ;
   import org.apache.axis.utils.XMLUtils ;
   import org.apache.axis.handlers.* ;
  +import org.apache.axis.handlers.http.*;
   import org.apache.axis.suppliers.* ;
   import org.apache.axis.registries.* ;
   
  @@ -120,12 +121,19 @@
         this.add( "RPCDispatcher", new RPCDispatchHandler() );
         this.add( "HTTPSender"   , new HTTPDispatchHandler() );
         this.add( "HTTPAction"   , new HTTPActionHandler() );
  +      this.add( "HTTPAuth"     , new HTTPAuthHandler() );
  +      this.add( "JWSHandler"   , new JWSHandler() );
  +      
  +      // Want this around by default for testing.
  +      this.add( "EchoHandler"  , new EchoHandler() );
   
         c = new SimpleChain();
         c.addHandler( this.find( "debug" ) );
         this.add( "global.input", c );
   
         c = new SimpleChain();
  +      c.addHandler( this.find( "HTTPAuth" ) );
  +      c.addHandler( this.find( "JWSHandler" ) );
         c.addHandler( this.find( "HTTPAction" ) );
         this.add( "HTTP.input", c );
   
  
  
  
  1.5       +2 -0      xml-axis/java/src/org/apache/axis/registries/DefaultServiceRegistry.java
  
  Index: DefaultServiceRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/registries/DefaultServiceRegistry.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultServiceRegistry.java	2001/04/22 21:05:15	1.4
  +++ DefaultServiceRegistry.java	2001/04/29 00:38:26	1.5
  @@ -127,6 +127,8 @@
         cc.addOption( "methodName", "AdminService" );
         handlerRegistry.add( "AdminService", cc );
         this.add( "AdminService", cc );
  +      
  +      this.add( "EchoService", handlerRegistry.find( "EchoHandler" ) );
       }
       else {
         // Do nothing
  
  
  
  1.14      +36 -33    xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
  
  Index: AxisServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AxisServlet.java	2001/04/27 02:42:14	1.13
  +++ AxisServlet.java	2001/04/29 00:38:26	1.14
  @@ -61,23 +61,34 @@
   import org.apache.axis.* ;
   import org.apache.axis.server.* ;
   import org.apache.axis.utils.* ;
  -import org.apache.axis.encoding.Base64 ;
   
   /**
    *
    * @author Doug Davis (dug@us.ibm.com)
    */
   public class AxisServlet extends HttpServlet {
  +  // These have default values.
  +  private String transportInName = "HTTP.Input";
  +  private String transportOutName = "HTTP.Output";
   
     private static final String AXIS_ENGINE = "AxisEngine" ;
   
     public void init() {
  +      ServletContext context = getServletConfig().getServletContext();
  +      String param = context.getInitParameter("transport.input");
  +      System.out.println("Got input name '" + param + "'");
  +      if (param != null)
  +          transportInName = param;
  +      param = getInitParameter("transport.output");
  +      if (param != null)
  +          transportOutName = param;
     }
   
     public void doGet(HttpServletRequest req, HttpServletResponse res)
                   throws ServletException, IOException {
       res.setContentType("text/html");
       res.getWriter().println( "In doGet" );
  +    res.getWriter().println(" Input = " + transportInName);
     }
   
     public void doPost(HttpServletRequest req, HttpServletResponse res)
  @@ -88,7 +99,7 @@
   
       Handler  engine = null ;
   
  -    // Debug.setDebugLevel( 2 );
  +    //Debug.setDebugLevel( 6 );
   
       /* Get or 'new' the Axis engine object */
       /***************************************/
  @@ -109,7 +120,7 @@
       /*******************************************************************/
       MessageContext    msgContext = new MessageContext();
       InputStream       inp        = req.getInputStream();
  -    Message         msg        = new Message( inp, "InputStream" );
  +    Message           msg        = new Message( inp, "InputStream" );
   
       /* Set the request(incoming) message field in the context */
       /**********************************************************/
  @@ -117,8 +128,8 @@
   
       /* Set the Transport Specific Input/Output chains IDs */
       /******************************************************/
  -    msgContext.setProperty(MessageContext.TRANS_INPUT , "HTTP.input" );
  -    msgContext.setProperty(MessageContext.TRANS_OUTPUT, "HTTP.output" );
  +    msgContext.setProperty(MessageContext.TRANS_INPUT , transportInName );
  +    msgContext.setProperty(MessageContext.TRANS_OUTPUT, transportOutName );
   
       /* Save some HTTP specific info in the bag in case a handler needs it */
       /**********************************************************************/
  @@ -131,42 +142,32 @@
       /* This will save us the trouble of having to parse the Request     */
       /* message - although we will need to double-check later on that    */
       /* the SOAPAction header does in fact match the URI in the body.    */
  -    /* (is this last stmt true???)                                      */
  +    /* (is this last stmt true??? (I don't think so - Glen))            */
       /* if SOAPAction is "" then use the URL                             */
       /* if SOAPAction is null then we'll we be forced to scan the body   */
       /*   for it.                                                        */
       /********************************************************************/
       String  tmp ;
       tmp = (String) req.getHeader( HTTPConstants.HEADER_SOAP_ACTION );
  -    if ( tmp != null && "".equals(tmp) )
  -      tmp = req.getContextPath(); // Is this right?
  -    if ( tmp != null ) 
  -      msgContext.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, tmp );
  -
  -    /* Process the Basic Auth stuff in the headers */
  -    /***********************************************/
  -    tmp = (String) req.getHeader( HTTPConstants.HEADER_AUTHORIZATION );
  -    if ( tmp != null ) tmp = tmp.trim();
  -    if ( tmp != null && tmp.startsWith("Basic ") ) {
  -      String user=null ;
  -      int  i ;
  -
  -      tmp = new String( Base64.decode( tmp.substring(6) ) );
  -      i = tmp.indexOf( ':' );
  -      if ( i == -1 ) user = tmp ;
  -      else           user = tmp.substring( 0, i);
  -      msgContext.setProperty( MessageContext.USERID, user );
  -      if ( i != -1 )  {
  -        String pwd = tmp.substring(i+1);
  -        if ( pwd != null && pwd.equals("") ) pwd = null ;
  -        if ( pwd != null )
  -          msgContext.setProperty( MessageContext.PASSWORD, pwd );
  +    
  +    try {
  +      /** Technically, if we don't find this header, we should probably fault.
  +      * It's required in the SOAP HTTP binding.
  +      */
  +      if ( tmp == null ) {
  +          throw new AxisFault( "Client.NoSOAPAction",
  +              "No SOAPAction header!",
  +              null, null );
         }
  -    }
  +      
  +      if ( "".equals(tmp) )
  +          tmp = req.getContextPath(); // Is this right?
  +      
  +      if ( tmp != null ) 
  +        msgContext.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, tmp );
   
  -    /* Invoke the Axis engine... */
  -    /*****************************/
  -    try {
  +      /* Invoke the Axis engine... */
  +      /*****************************/
         engine.invoke( msgContext );
       }
       catch( Exception e ) {
  @@ -176,6 +177,8 @@
             res.setStatus( HttpServletResponse.SC_UNAUTHORIZED );
           else
             res.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
  +        // It's been suggested that a lack of SOAPAction should produce some
  +        // other error code (in the 400s)...
         }
         else 
           res.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
  
  
  

Mime
View raw message