axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject cvs commit: ws-axis/c/src/transport/axis2/ssl OpenSSLChannel.cpp OpenSSLChannel.hpp SSLChannelLoader.cpp
Date Mon, 06 Dec 2004 10:13:06 GMT
damitha     2004/12/06 02:13:06

  Modified:    c/src/transport/axis2 Axis2Transport.cpp Axis2Transport.h
                        Makefile.am SecureChannel.cpp
               c/src/transport/axis2/ssl OpenSSLChannel.cpp
                        OpenSSLChannel.hpp SSLChannelLoader.cpp
  Removed:     c/src/transport SSLChannel.hpp
               c/src/transport/axis2 SSLChannelFactory.cpp
                        SSLChannelFactory.hpp SecureChannel.h
  Log:
  Cleaner solution for ssl transport as discussed in mailing list and jira
  
  Revision  Changes    Path
  1.29      +5 -2      ws-axis/c/src/transport/axis2/Axis2Transport.cpp
  
  Index: Axis2Transport.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/Axis2Transport.cpp,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Axis2Transport.cpp	6 Dec 2004 08:35:07 -0000	1.28
  +++ Axis2Transport.cpp	6 Dec 2004 10:13:06 -0000	1.29
  @@ -49,6 +49,7 @@
       m_iContentLength = 0;
       m_pcReceived = 0;
       m_pChannel = new Channel ();
  +    m_pFactory = new ChannelFactory();
       m_bChannelSecure = false;
   	m_bMimeTrue = false;
       m_viCurrentHeader = m_vHTTPHeaders.begin();
  @@ -116,7 +117,8 @@
               // (as it may not be secure) and create a new secure channel.
               delete m_pChannel;
   
  -            m_pChannel = (Channel *) new SecureChannel ();
  +            //m_pChannel = (Channel *) new SecureChannel ();
  +            m_pChannel = m_pFactory->getSecureChannelObject();
   
               m_pChannel->setURL (pcEndpointUri);
   
  @@ -732,7 +734,8 @@
       {
           if (m_bChannelSecure)
           {
  -             ((SecureChannel *) m_pChannel)->setTransportProperty (type, value);
  +             //((SecureChannel *) m_pChannel)->setTransportProperty (type, value);
  +             m_pFactory->initialize(value);
           }
           break;
       }
  
  
  
  1.18      +4 -2      ws-axis/c/src/transport/axis2/Axis2Transport.h
  
  Index: Axis2Transport.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/Axis2Transport.h,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Axis2Transport.h	30 Nov 2004 11:49:03 -0000	1.17
  +++ Axis2Transport.h	6 Dec 2004 10:13:06 -0000	1.18
  @@ -24,7 +24,8 @@
   
   #include "../SOAPTransport.h"
   #include "Channel.h"
  -#include "SecureChannel.h"
  +#include "SecureChannel.hpp"
  +#include "ChannelFactory.hpp"
   #include <string>
   #include <vector>
   
  @@ -368,7 +369,8 @@
       std::string m_strMimeContentTransferEncoding;
       std::string m_strMimeContentID;
       std::string m_strMimeContentLocation; 
  -    std::string m_strMimeReceived; 
  +    std::string m_strMimeReceived;
  +    ChannelFactory* m_pFactory;
   };
   
   #endif
  
  
  
  1.6       +1 -1      ws-axis/c/src/transport/axis2/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/Makefile.am,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Makefile.am	25 Nov 2004 12:41:58 -0000	1.5
  +++ Makefile.am	6 Dec 2004 10:13:06 -0000	1.6
  @@ -7,7 +7,7 @@
   				Axis2Transport.cpp \
   				AxisTransportException.cpp \
   				Axis2TransportInstantiator.cpp \
  -				SSLChannelFactory.cpp
  +				ChannelFactory.cpp
   
   libaxis2_transport_la_LIBADD = -lstdc++
   INCLUDES = -I../../../include
  
  
  
  1.5       +10 -11    ws-axis/c/src/transport/axis2/SecureChannel.cpp
  
  Index: SecureChannel.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/SecureChannel.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SecureChannel.cpp	30 Nov 2004 11:49:04 -0000	1.4
  +++ SecureChannel.cpp	6 Dec 2004 10:13:06 -0000	1.5
  @@ -1,9 +1,8 @@
  -#include "SecureChannel.h"
  -#include "SSLChannelFactory.hpp"
  +#include "SecureChannel.hpp"
   
   SecureChannel::SecureChannel()
   {
  -    m_pFactory = new SSLChannelFactory();
  +    //m_pFactory = new SSLChannelFactory();
       //m_pFactory->initialize();
       //m_pSSLChannel = m_pFactory->getSSLChannelObject(); 
       //m_pSSLChannel->SSLInit();
  @@ -15,10 +14,10 @@
   
   bool SecureChannel::open() throw (AxisTransportException&)
   {
  -    m_pSSLChannel = m_pFactory->getSSLChannelObject(); 
  -    m_pSSLChannel->SSLInit();
  -    Channel::open();
  -    m_pSSLChannel->openSSLConnection(&m_Sock); 
  +    //m_pSSLChannel = m_pFactory->getSSLChannelObject(); 
  +    //m_pSSLChannel->SSLInit();
  +    //Channel::open();
  +    //m_pSSLChannel->openSSLConnection(&m_Sock); 
       return true;
   }
   
  @@ -28,13 +27,13 @@
   
   const Channel & SecureChannel::operator << (const char * msg) throw (AxisTransportException)
   {
  -    m_pSSLChannel->SSLWrite(msg, &m_Sock);
  +    //m_pSSLChannel->SSLWrite(msg, &m_Sock);
       return *this;
   }
   
   const Channel &SecureChannel::operator >> (std::string & msg) throw (AxisTransportException)
   {
  -    m_pSSLChannel->SSLRead(msg);
  +    //m_pSSLChannel->SSLRead(msg);
       return *this;
   }
   
  @@ -53,8 +52,8 @@
   int SecureChannel::setTransportProperty (AXIS_TRANSPORT_INFORMATION_TYPE type,
       const char* value)
   {
  -    if(DLL_NAME == type)
  -        m_pFactory->initialize(value);
  +    //if(DLL_NAME == type)
  +    //    m_pFactory->initialize(value);
       //m_pFactory->setTransportProperty(type, value);
       return AXIS_SUCCESS;
   }
  
  
  
  1.2       +46 -28    ws-axis/c/src/transport/axis2/ssl/OpenSSLChannel.cpp
  
  Index: OpenSSLChannel.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/ssl/OpenSSLChannel.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OpenSSLChannel.cpp	25 Nov 2004 12:41:58 -0000	1.1
  +++ OpenSSLChannel.cpp	6 Dec 2004 10:13:06 -0000	1.2
  @@ -20,6 +20,12 @@
    */
   
   #include "OpenSSLChannel.hpp"
  +#include <openssl/ssl.h>
  +#include <openssl/err.h>
  +
  +char* m_pcError;
  +SSL_CTX* m_sslContext;
  +SSL* m_sslHandle;
   
   /* "global" init done? */
   static bool g_InitSSL = false;
  @@ -59,12 +65,14 @@
   {
   }
   
  -bool OpenSSLChannel::SSLInit()
  +bool OpenSSLChannel::open() throw (AxisTransportException&)
   {
  +    Channel::open();
  +    openSecureSocket(); 
       return true;
   }
   
  -bool OpenSSLChannel::openSSLConnection(unsigned int* pSock)
  +int OpenSSLChannel::openSecureSocket()
   {
       SSL_METHOD* req_method = SSLv23_client_method();
       SSL_SESSION* ssl_sessionid = NULL;
  @@ -78,7 +86,7 @@
           /* OpenSSL documents that this must be at least 120 bytes long. */
           char error_buffer[120];
           ERR_error_string(sslerror, error_buffer);
  -        closeSSLChannel();
  +        closeSecureSocket();
           throw AxisSSLChannelException(CLIENT_SSLCHANNEL_CONTEXT_CREATE_ERROR, error_buffer);
       }
   
  @@ -92,7 +100,7 @@
       SSL_set_connect_state(m_sslHandle);
   
       /* pass the raw socket into the SSL layers */
  -    SSL_set_fd(m_sslHandle, *pSock);
  +    SSL_set_fd(m_sslHandle, m_Sock);
   
       int iError = SSL_connect(m_sslHandle);
       /*
  @@ -101,15 +109,30 @@
        *  <0  is "handshake was not successful, because a fatal error occurred"
        */
        if(iError <= 0)
  -         setSSLError(iError);
  +         setSecureError(iError);
   
  -    return true;
  +    return 0;
  +}
  +
  +const Channel & SecureChannel::operator << (const char * msg) throw (AxisTransportException)
  +{
  +    writeSecureSocket(msg);
  +    return *this;
   }
   
  -int OpenSSLChannel::SSLRead(std::string& msg)
  +const Channel &SecureChannel::operator >> (std::string & msg) throw (AxisTransportException)
  +{
  +    int iBuffSize = 4096;
  +    char buff[iBuffSize];
  +    readSecureSocket(buff, iBuffSize);
  +    msg = buff;
  +    return *this;
  +}
  +
  +bool OpenSSLChannel::readSecureSocket(char* pcMsg, int piSize)
   {
       int nByteRecv = 0;
  -    const int BUF_SIZE = 4096;
  +    //const int BUF_SIZE = 4096;
       char buf[BUF_SIZE];
       nByteRecv = SSL_read(m_sslHandle, buf, BUF_SIZE - 1);
       if(nByteRecv < 0)
  @@ -117,47 +140,42 @@
           char error_string[256];
           /* failed SSL_read */
           int iError = SSL_get_error(m_sslHandle, nByteRecv);
  -        setSSLError(iError);
  -        closeSSLChannel();
  +        setSecureError(iError);
  +        closeSecureSocket();
       }
       if(nByteRecv)
       {
          buf[nByteRecv] = '\0';  
          /* got a part of the message, so add it to form */
  -       msg = buf;
  +       pcMsg = buf;
       }
       else
          printf("execution break\n");
       return true;
   }
   
  -int OpenSSLChannel::SSLWrite(const std::string& msg, unsigned int* pSock)
  +bool OpenSSLChannel::writeSecureSocket(const char* pcMsg)
   {
  -    if(INVALID_SOCKET == *pSock)
  +    if(INVALID_SOCKET == m_Sock)
       {
           throw AxisSSLChannelException(CLIENT_SSLCHANNEL_INVALID_SOCKET_ERROR,"");
       }
  -    int size = msg.size(), nByteSent;
  +    int size = strlen(pcMsg), nByteSent;
   
  -    nByteSent = SSL_write(m_sslHandle, (char *)msg.c_str(), size);
  +    nByteSent = SSL_write(m_sslHandle, (char *)pcMsg, size);
   
       if(nByteSent < 0)
       {
           char error_string[256];
           int iError = SSL_get_error(m_sslHandle, nByteSent);
  -        setSSLError(iError);
  -        closeSSLChannel();
  +        setSecureError(iError);
  +        closeSecureSocket();
       }
   
       return true;
   }
   
  -void OpenSSLChannel::setSSLError(char* pcError)
  -{
  -    strcpy(m_pcError, pcError);
  -}
  -
  -void OpenSSLChannel::setSSLError(int iError)
  +void OpenSSLChannel::setSecureError(int iError)
   {
       switch(iError)
       {
  @@ -174,7 +192,7 @@
                   iError =  errno;
               #endif
   
  -            closeSSLChannel();
  +            closeSecureSocket();
               throw AxisSSLChannelException(CLIENT_SSLCHANNEL_ERROR, "SSL_ERROR_SYSCALL");
   
           }
  @@ -191,7 +209,7 @@
                char error_buffer[120];
   
                ERR_error_string(sslerror, error_buffer);
  -             closeSSLChannel();
  +             closeSecureSocket();
                throw AxisSSLChannelException(CLIENT_SSLCHANNEL_ERROR, error_buffer);
           }
           default: 
  @@ -208,14 +226,14 @@
               char error_buffer[120];
   
               ERR_error_string(sslerror, error_buffer);
  -            closeSSLChannel();
  +            closeSecureSocket();
               throw AxisSSLChannelException(CLIENT_SSLCHANNEL_ERROR, error_buffer);
   
           }
       }
   }
   
  -char* OpenSSLChannel::getSSLError()
  +char* OpenSSLChannel::getSecureError()
   {
       return m_pcError;    
   }
  @@ -226,7 +244,7 @@
    *
    */
   
  -void OpenSSLChannel::closeSSLChannel()
  +int OpenSSLChannel::closeSecureSocket()
   {
       if(m_sslHandle)
       {
  
  
  
  1.2       +37 -44    ws-axis/c/src/transport/axis2/ssl/OpenSSLChannel.hpp
  
  Index: OpenSSLChannel.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/ssl/OpenSSLChannel.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OpenSSLChannel.hpp	25 Nov 2004 12:41:58 -0000	1.1
  +++ OpenSSLChannel.hpp	6 Dec 2004 10:13:06 -0000	1.2
  @@ -1,53 +1,46 @@
  -/*
  - *   Copyright 2003-2004 The Apache Software Foundation.
  - *
  - *   Licensed under the Apache License, Version 2.0 (the "License");
  - *   you may not use this file except in compliance with the License.
  - *   You may obtain a copy of the License at
  - *
  - *       http://www.apache.org/licenses/LICENSE-2.0
  - *
  - *   Unless required by applicable law or agreed to in writing, software
  - *   distributed under the License is distributed on an "AS IS" BASIS,
  - *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - *   See the License for the specific language governing permissions and
  - *   limitations under the License.
  - */
  -
  -/*
  - * @author damitha Kumarage (damitha@hsenid.lk, damitha@opensource.lk)
  - *
  - */
  -
  -#if !defined(_AXIS_AXIS2_OPENSSLCHANNEL_HPP)
  -#define _AXIS_AXIS2_OPENSSLCHANNEL_HPP
  -#include "../../SSLChannel.hpp"
  -#include "../Channel.h"
  +#if !defined(_AXIS_OPENSSLCHANNEL_H)
  +#define _AXIS_OPENSSLCHANNEL_H
  +#include "../SecureChannel.hpp"
   #include "AxisSSLChannelException.hpp"
  -#include <openssl/ssl.h>
  -#include <openssl/err.h>
  -AXIS_CPP_NAMESPACE_START
  +#include <iostream>
  +using namespace std;
   
  -class OpenSSLChannel: public SSLChannel
  +class OpenSSLChannel: public SecureChannel
   {
   public:
  -   OpenSSLChannel(); 
  -   ~OpenSSLChannel();
  -   bool SSLInit();
  -   bool openSSLConnection(unsigned int* pSock);
  -   int SSLRead(std::string& msg);
  -   int SSLWrite(const std::string& msg, unsigned int* pSock);
  -   void closeSSLChannel();
  -   void setSSLError(int);
  -   void setSSLError(char*);
  -   char* getSSLError();
  +	OpenSSLChannel();
  +	~OpenSSLChannel();
  +
  +	bool open() throw (AxisTransportException&);
  +	void close();
  +
  +	const Channel& operator >> (std::string&) throw (AxisTransportException);
  +	const Channel& operator << (const char *) throw (AxisTransportException);
  +
  +	bool setServerName( std::string) { return true;};
  +	string getServerName(){ return NULL;};
  +
  +	void setSecureProperties( const char *){};
  +	const char * getSecureProperties(){ return NULL;};
  +        int setTransportProperty(AXIS_TRANSPORT_INFORMATION_TYPE
  +            type, const char* value){ return 0;};
   
   private:
  -   char* m_pcError;
  -   SSL_CTX* m_sslContext;
  -   SSL* m_sslHandle;
  -};
  +    bool openConnection(){ return true;};
  +    bool closeConnection(){ return true;};
  +
  +    int openSecureSocket();
  +    int closeSecureSocket();
   
  -AXIS_CPP_NAMESPACE_END
  +    bool writeSecureSocket(const char *);
  +    bool readSecureSocket( char *, int);
  +
  +    void setSecureError(int iError);
  +    char* getSecureError();
  +
  +protected:
  +	string sServerName;
  +};
   
   #endif
  +
  
  
  
  1.2       +4 -4      ws-axis/c/src/transport/axis2/ssl/SSLChannelLoader.cpp
  
  Index: SSLChannelLoader.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/ssl/SSLChannelLoader.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SSLChannelLoader.cpp	25 Nov 2004 12:41:58 -0000	1.1
  +++ SSLChannelLoader.cpp	6 Dec 2004 10:13:06 -0000	1.2
  @@ -20,13 +20,13 @@
    *
    */
   
  -#include "OpenSSLChannel.hpp"
  +#include "../SecureChannel.hpp"
   
   extern "C" {
   STORAGE_CLASS_INFO
  -int CreateInstance(SSLChannel **inst)
  +int CreateInstance(SecureChannel **inst)
   {
  -	*inst = new OpenSSLChannel();
  +	*inst = new SecureChannel();
   	if (*inst)
   	{
   		return AXIS_SUCCESS;
  @@ -34,7 +34,7 @@
   	return AXIS_FAIL;
   }
   STORAGE_CLASS_INFO 
  -int DestroyInstance(SSLChannel *inst)
  +int DestroyInstance(SecureChannel *inst)
   {
   	if (inst)
   	{
  
  
  

Mime
View raw message