Added service::isSecuredConnection() and service::getConnectionInfos() to retrieve information about the connection.

This commit is contained in:
Vincent Richard 2006-01-29 17:36:34 +00:00
parent bfe8c00465
commit 1539754d53
22 changed files with 564 additions and 16 deletions

View File

@ -2,6 +2,11 @@
VERSION 0.8.1cvs VERSION 0.8.1cvs
================ ================
2006-01-29 Vincent Richard <vincent@vincent-richard.net>
* Added service::isSecuredConnection() and service::getConnectionInfos()
to retrieve information about the connection.
2006-01-16 Vincent Richard <vincent@vincent-richard.net> 2006-01-16 Vincent Richard <vincent@vincent-richard.net>
* Added support for attachments of type "message/rfc822". * Added support for attachments of type "message/rfc822".

View File

@ -198,9 +198,12 @@ libvmime_examples_sources = [
libvmime_messaging_sources = [ libvmime_messaging_sources = [
'net/builtinServices.inl', 'net/builtinServices.inl',
'net/connectionInfos.hpp',
'net/defaultConnectionInfos.cpp', 'net/defaultConnectionInfos.hpp',
'net/events.cpp', 'net/events.hpp', 'net/events.cpp', 'net/events.hpp',
'net/folder.cpp', 'net/folder.hpp', 'net/folder.cpp', 'net/folder.hpp',
'net/message.cpp', 'net/message.hpp', 'net/message.cpp', 'net/message.hpp',
'net/securedConnectionInfos.hpp',
'net/service.cpp', 'net/service.hpp', 'net/service.cpp', 'net/service.hpp',
'net/serviceFactory.cpp', 'net/serviceFactory.hpp', 'net/serviceFactory.cpp', 'net/serviceFactory.hpp',
'net/serviceInfos.cpp', 'net/serviceInfos.hpp', 'net/serviceInfos.cpp', 'net/serviceInfos.hpp',
@ -215,6 +218,7 @@ libvmime_messaging_sources = [
libvmime_net_tls_sources = [ libvmime_net_tls_sources = [
'net/tls/TLSSession.cpp', 'net/tls/TLSSession.hpp', 'net/tls/TLSSession.cpp', 'net/tls/TLSSession.hpp',
'net/tls/TLSSocket.cpp', 'net/tls/TLSSocket.hpp', 'net/tls/TLSSocket.cpp', 'net/tls/TLSSocket.hpp',
'net/tls/TLSSecuredConnectionInfos.cpp', 'net/tls/TLSSecuredConnectionInfos.hpp',
'security/cert/certificateChain.cpp', 'security/cert/certificateChain.hpp', 'security/cert/certificateChain.cpp', 'security/cert/certificateChain.hpp',
'security/cert/certificateVerifier.hpp', 'security/cert/certificateVerifier.hpp',
'security/cert/defaultCertificateVerifier.cpp', 'security/cert/defaultCertificateVerifier.hpp', 'security/cert/defaultCertificateVerifier.cpp', 'security/cert/defaultCertificateVerifier.hpp',

View File

@ -516,6 +516,13 @@ static void connectStore()
// Connect to the mail store // Connect to the mail store
st->connect(); st->connect();
// Display some information about the connection
vmime::ref <vmime::net::connectionInfos> ci = st->getConnectionInfos();
std::cout << std::endl;
std::cout << "Connected to '" << ci->getHost() << "' (port " << ci->getPort() << ")" << std::endl;
std::cout << "Connection is " << (st->isSecuredConnection() ? "" : "NOT ") << "secured." << std::endl;
// Open the default folder in this store // Open the default folder in this store
vmime::ref <vmime::net::folder> f = st->getDefaultFolder(); vmime::ref <vmime::net::folder> f = st->getDefaultFolder();
// vmime::ref <vmime::net::folder> f = st->getFolder(vmime::utility::path("a")); // vmime::ref <vmime::net::folder> f = st->getFolder(vmime::utility::path("a"));

View File

@ -0,0 +1,52 @@
//
// VMime library (http://www.vmime.org)
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
#include "vmime/net/defaultConnectionInfos.hpp"
namespace vmime {
namespace net {
defaultConnectionInfos::defaultConnectionInfos(const string& host, const port_t port)
: m_host(host), m_port(port)
{
}
const string defaultConnectionInfos::getHost() const
{
return m_host;
}
const port_t defaultConnectionInfos::getPort() const
{
return m_port;
}
} // net
} // vmime

View File

@ -25,12 +25,15 @@
#include "vmime/exception.hpp" #include "vmime/exception.hpp"
#include "vmime/platformDependant.hpp" #include "vmime/platformDependant.hpp"
#include "vmime/net/defaultConnectionInfos.hpp"
#if VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_SASL_SUPPORT
#include "vmime/security/sasl/SASLContext.hpp" #include "vmime/security/sasl/SASLContext.hpp"
#endif // VMIME_HAVE_SASL_SUPPORT #endif // VMIME_HAVE_SASL_SUPPORT
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
#include "vmime/net/tls/TLSSession.hpp" #include "vmime/net/tls/TLSSession.hpp"
#include "vmime/net/tls/TLSSecuredConnectionInfos.hpp"
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
#include <sstream> #include <sstream>
@ -52,7 +55,8 @@ namespace imap {
IMAPConnection::IMAPConnection(weak_ref <IMAPStore> store, ref <security::authenticator> auth) IMAPConnection::IMAPConnection(weak_ref <IMAPStore> store, ref <security::authenticator> auth)
: m_store(store), m_auth(auth), m_socket(NULL), m_parser(NULL), m_tag(NULL), : m_store(store), m_auth(auth), m_socket(NULL), m_parser(NULL), m_tag(NULL),
m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(NULL) m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(NULL),
m_secured(false)
{ {
} }
@ -92,7 +96,7 @@ void IMAPConnection::connect()
m_socket = m_store->getSocketFactory()->create(); m_socket = m_store->getSocketFactory()->create();
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
if (m_store->isSecuredConnection()) // dedicated port/IMAPS if (m_store->isIMAPS()) // dedicated port/IMAPS
{ {
ref <tls::TLSSession> tlsSession = ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(m_store->getCertificateVerifier()); vmime::create <tls::TLSSession>(m_store->getCertificateVerifier());
@ -101,8 +105,15 @@ void IMAPConnection::connect()
tlsSession->getSocket(m_socket); tlsSession->getSocket(m_socket);
m_socket = tlsSocket; m_socket = tlsSocket;
m_secured = true;
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
} }
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
else
{
m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
}
m_socket->connect(address, port); m_socket->connect(address, port);
@ -446,6 +457,10 @@ void IMAPConnection::startTLS()
m_socket = tlsSocket; m_socket = tlsSocket;
m_parser->setSocket(m_socket); m_parser->setSocket(m_socket);
m_secured = true;
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>
(m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket);
} }
catch (exceptions::command_error&) catch (exceptions::command_error&)
{ {
@ -517,6 +532,18 @@ const bool IMAPConnection::isConnected() const
} }
const bool IMAPConnection::isSecuredConnection() const
{
return m_secured;
}
ref <connectionInfos> IMAPConnection::getConnectionInfos() const
{
return m_cntInfos;
}
void IMAPConnection::disconnect() void IMAPConnection::disconnect()
{ {
if (!isConnected()) if (!isConnected())
@ -539,6 +566,9 @@ void IMAPConnection::internalDisconnect()
m_timeoutHandler = NULL; m_timeoutHandler = NULL;
m_state = STATE_LOGOUT; m_state = STATE_LOGOUT;
m_secured = false;
m_cntInfos = NULL;
} }

View File

@ -33,7 +33,7 @@ namespace imap {
IMAPStore::IMAPStore(ref <session> sess, ref <security::authenticator> auth, const bool secured) IMAPStore::IMAPStore(ref <session> sess, ref <security::authenticator> auth, const bool secured)
: store(sess, getInfosInstance(), auth), m_connection(NULL), m_secured(secured) : store(sess, getInfosInstance(), auth), m_connection(NULL), m_isIMAPS(secured)
{ {
} }
@ -91,12 +91,6 @@ const bool IMAPStore::isValidFolderName(const folder::path::component& /* name *
} }
const bool IMAPStore::isSecuredConnection() const
{
return m_secured;
}
void IMAPStore::connect() void IMAPStore::connect()
{ {
if (isConnected()) if (isConnected())
@ -123,6 +117,30 @@ const bool IMAPStore::isConnected() const
} }
const bool IMAPStore::isIMAPS() const
{
return m_isIMAPS;
}
const bool IMAPStore::isSecuredConnection() const
{
if (m_connection == NULL)
return false;
return m_connection->isSecuredConnection();
}
ref <connectionInfos> IMAPStore::getConnectionInfos() const
{
if (m_connection == NULL)
return NULL;
return m_connection->getConnectionInfos();
}
void IMAPStore::disconnect() void IMAPStore::disconnect()
{ {
if (!isConnected()) if (!isConnected())

View File

@ -26,6 +26,8 @@
#include "vmime/exception.hpp" #include "vmime/exception.hpp"
#include "vmime/platformDependant.hpp" #include "vmime/platformDependant.hpp"
#include "vmime/net/defaultConnectionInfos.hpp"
// Helpers for service properties // Helpers for service properties
#define GET_PROPERTY(type, prop) \ #define GET_PROPERTY(type, prop) \
@ -154,6 +156,18 @@ const bool maildirStore::isConnected() const
} }
const bool maildirStore::isSecuredConnection() const
{
return false;
}
ref <connectionInfos> maildirStore::getConnectionInfos() const
{
return vmime::create <defaultConnectionInfos>("localhost", 0);
}
void maildirStore::disconnect() void maildirStore::disconnect()
{ {
for (std::list <maildirFolder*>::iterator it = m_folders.begin() ; for (std::list <maildirFolder*>::iterator it = m_folders.begin() ;

View File

@ -27,12 +27,15 @@
#include "vmime/utility/filteredStream.hpp" #include "vmime/utility/filteredStream.hpp"
#include "vmime/utility/stringUtils.hpp" #include "vmime/utility/stringUtils.hpp"
#include "vmime/net/defaultConnectionInfos.hpp"
#if VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_SASL_SUPPORT
#include "vmime/security/sasl/SASLContext.hpp" #include "vmime/security/sasl/SASLContext.hpp"
#endif // VMIME_HAVE_SASL_SUPPORT #endif // VMIME_HAVE_SASL_SUPPORT
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
#include "vmime/net/tls/TLSSession.hpp" #include "vmime/net/tls/TLSSession.hpp"
#include "vmime/net/tls/TLSSecuredConnectionInfos.hpp"
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
#include <algorithm> #include <algorithm>
@ -54,7 +57,8 @@ namespace pop3 {
POP3Store::POP3Store(ref <session> sess, ref <security::authenticator> auth, const bool secured) POP3Store::POP3Store(ref <session> sess, ref <security::authenticator> auth, const bool secured)
: store(sess, getInfosInstance(), auth), m_socket(NULL), : store(sess, getInfosInstance(), auth), m_socket(NULL),
m_authentified(false), m_timeoutHandler(NULL), m_secured(secured) m_authentified(false), m_timeoutHandler(NULL),
m_isPOP3S(secured), m_secured(false)
{ {
} }
@ -130,7 +134,7 @@ void POP3Store::connect()
m_socket = getSocketFactory()->create(); m_socket = getSocketFactory()->create();
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
if (m_secured) // dedicated port/POP3S if (m_isPOP3S) // dedicated port/POP3S
{ {
ref <tls::TLSSession> tlsSession = ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(getCertificateVerifier()); vmime::create <tls::TLSSession>(getCertificateVerifier());
@ -139,8 +143,15 @@ void POP3Store::connect()
tlsSession->getSocket(m_socket); tlsSession->getSocket(m_socket);
m_socket = tlsSocket; m_socket = tlsSocket;
m_secured = true;
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
} }
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
else
{
m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
}
m_socket->connect(address, port); m_socket->connect(address, port);
@ -165,7 +176,7 @@ void POP3Store::connect()
const bool tlsRequired = HAS_PROPERTY(PROPERTY_CONNECTION_TLS_REQUIRED) const bool tlsRequired = HAS_PROPERTY(PROPERTY_CONNECTION_TLS_REQUIRED)
&& GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS_REQUIRED); && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS_REQUIRED);
if (!m_secured && tls) // only if not POP3S if (!m_isPOP3S && tls) // only if not POP3S
{ {
try try
{ {
@ -533,6 +544,10 @@ void POP3Store::startTLS()
tlsSocket->handshake(m_timeoutHandler); tlsSocket->handshake(m_timeoutHandler);
m_socket = tlsSocket; m_socket = tlsSocket;
m_secured = true;
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>
(m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket);
} }
catch (exceptions::command_error&) catch (exceptions::command_error&)
{ {
@ -556,6 +571,18 @@ const bool POP3Store::isConnected() const
} }
const bool POP3Store::isSecuredConnection() const
{
return m_secured;
}
ref <connectionInfos> POP3Store::getConnectionInfos() const
{
return m_cntInfos;
}
void POP3Store::disconnect() void POP3Store::disconnect()
{ {
if (!isConnected()) if (!isConnected())
@ -590,6 +617,9 @@ void POP3Store::internalDisconnect()
m_timeoutHandler = NULL; m_timeoutHandler = NULL;
m_authentified = false; m_authentified = false;
m_secured = false;
m_cntInfos = NULL;
} }

View File

@ -28,6 +28,8 @@
#include "vmime/utility/childProcess.hpp" #include "vmime/utility/childProcess.hpp"
#include "vmime/utility/smartPtr.hpp" #include "vmime/utility/smartPtr.hpp"
#include "vmime/net/defaultConnectionInfos.hpp"
#include "vmime/config.hpp" #include "vmime/config.hpp"
@ -92,6 +94,18 @@ const bool sendmailTransport::isConnected() const
} }
const bool sendmailTransport::isSecuredConnection() const
{
return false;
}
ref <connectionInfos> sendmailTransport::getConnectionInfos() const
{
return vmime::create <defaultConnectionInfos>("localhost", 0);
}
void sendmailTransport::disconnect() void sendmailTransport::disconnect()
{ {
if (!isConnected()) if (!isConnected())

View File

@ -28,12 +28,15 @@
#include "vmime/utility/filteredStream.hpp" #include "vmime/utility/filteredStream.hpp"
#include "vmime/utility/stringUtils.hpp" #include "vmime/utility/stringUtils.hpp"
#include "vmime/net/defaultConnectionInfos.hpp"
#if VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_SASL_SUPPORT
#include "vmime/security/sasl/SASLContext.hpp" #include "vmime/security/sasl/SASLContext.hpp"
#endif // VMIME_HAVE_SASL_SUPPORT #endif // VMIME_HAVE_SASL_SUPPORT
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
#include "vmime/net/tls/TLSSession.hpp" #include "vmime/net/tls/TLSSession.hpp"
#include "vmime/net/tls/TLSSecuredConnectionInfos.hpp"
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
@ -54,7 +57,7 @@ namespace smtp {
SMTPTransport::SMTPTransport(ref <session> sess, ref <security::authenticator> auth, const bool secured) SMTPTransport::SMTPTransport(ref <session> sess, ref <security::authenticator> auth, const bool secured)
: transport(sess, getInfosInstance(), auth), m_socket(NULL), : transport(sess, getInfosInstance(), auth), m_socket(NULL),
m_authentified(false), m_extendedSMTP(false), m_timeoutHandler(NULL), m_authentified(false), m_extendedSMTP(false), m_timeoutHandler(NULL),
m_secured(secured) m_isSMTPS(secured), m_secured(false)
{ {
} }
@ -97,7 +100,7 @@ void SMTPTransport::connect()
m_socket = getSocketFactory()->create(); m_socket = getSocketFactory()->create();
#if VMIME_HAVE_TLS_SUPPORT #if VMIME_HAVE_TLS_SUPPORT
if (m_secured) // dedicated port/SMTPS if (m_isSMTPS) // dedicated port/SMTPS
{ {
ref <tls::TLSSession> tlsSession = ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(getCertificateVerifier()); vmime::create <tls::TLSSession>(getCertificateVerifier());
@ -106,8 +109,15 @@ void SMTPTransport::connect()
tlsSession->getSocket(m_socket); tlsSession->getSocket(m_socket);
m_socket = tlsSocket; m_socket = tlsSocket;
m_secured = true;
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
} }
#endif // VMIME_HAVE_TLS_SUPPORT #endif // VMIME_HAVE_TLS_SUPPORT
else
{
m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
}
m_socket->connect(address, port); m_socket->connect(address, port);
@ -163,7 +173,7 @@ void SMTPTransport::connect()
const bool tlsRequired = HAS_PROPERTY(PROPERTY_CONNECTION_TLS_REQUIRED) const bool tlsRequired = HAS_PROPERTY(PROPERTY_CONNECTION_TLS_REQUIRED)
&& GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS_REQUIRED); && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS_REQUIRED);
if (!m_secured && tls) // only if not POP3S if (!m_isSMTPS && tls) // only if not POP3S
{ {
try try
{ {
@ -436,6 +446,10 @@ void SMTPTransport::startTLS()
tlsSocket->handshake(m_timeoutHandler); tlsSocket->handshake(m_timeoutHandler);
m_socket = tlsSocket; m_socket = tlsSocket;
m_secured = true;
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>
(m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket);
} }
catch (exceptions::command_error&) catch (exceptions::command_error&)
{ {
@ -459,6 +473,18 @@ const bool SMTPTransport::isConnected() const
} }
const bool SMTPTransport::isSecuredConnection() const
{
return m_secured;
}
ref <connectionInfos> SMTPTransport::getConnectionInfos() const
{
return m_cntInfos;
}
void SMTPTransport::disconnect() void SMTPTransport::disconnect()
{ {
if (!isConnected()) if (!isConnected())
@ -486,6 +512,9 @@ void SMTPTransport::internalDisconnect()
m_authentified = false; m_authentified = false;
m_extendedSMTP = false; m_extendedSMTP = false;
m_secured = false;
m_cntInfos = NULL;
} }

View File

@ -0,0 +1,63 @@
//
// VMime library (http://www.vmime.org)
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
#include "vmime/net/tls/TLSSecuredConnectionInfos.hpp"
#include "vmime/net/tls/TLSSession.hpp"
namespace vmime {
namespace net {
namespace tls {
TLSSecuredConnectionInfos::TLSSecuredConnectionInfos
(const string& host, const port_t port,
ref <TLSSession> tlsSession, ref <TLSSocket> tlsSocket)
: m_host(host), m_port(port),
m_tlsSession(tlsSession), m_tlsSocket(tlsSocket)
{
}
const string TLSSecuredConnectionInfos::getHost() const
{
return m_host;
}
const port_t TLSSecuredConnectionInfos::getPort() const
{
return m_port;
}
ref <const security::cert::certificateChain> TLSSecuredConnectionInfos::getPeerCertificates() const
{
return m_tlsSocket->getPeerCertificates();
}
} // tls
} // net
} // vmime

View File

@ -0,0 +1,60 @@
//
// VMime library (http://www.vmime.org)
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
#ifndef VMIME_NET_CONNECTIONINFOS_HPP_INCLUDED
#define VMIME_NET_CONNECTIONINFOS_HPP_INCLUDED
#include "vmime/object.hpp"
namespace vmime {
namespace net {
/** Information about the connection used by a service.
*/
class connectionInfos : public object
{
public:
/** Return the host to which the service is connected.
*
* @return server host name or address
*/
virtual const string getHost() const = 0;
/** Return the port to which the service is connected.
*
* @return server port
*/
virtual const port_t getPort() const = 0;
};
} // net
} // vmime
#endif // VMIME_NET_CONNECTIONINFOS_HPP_INCLUDED

View File

@ -0,0 +1,58 @@
//
// VMime library (http://www.vmime.org)
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
#ifndef VMIME_NET_DEFAULTCONNECTIONINFOS_HPP_INCLUDED
#define VMIME_NET_DEFAULTCONNECTIONINFOS_HPP_INCLUDED
#include "vmime/net/connectionInfos.hpp"
namespace vmime {
namespace net {
/** Information about the connection used by a service.
*/
class defaultConnectionInfos : public connectionInfos
{
public:
defaultConnectionInfos(const string& host, const port_t port);
const string getHost() const;
const port_t getPort() const;
private:
string m_host;
port_t m_port;
};
} // net
} // vmime
#endif // VMIME_NET_DEFAULTCONNECTIONINFOS_HPP_INCLUDED

View File

@ -30,6 +30,7 @@
#include "vmime/net/socket.hpp" #include "vmime/net/socket.hpp"
#include "vmime/net/timeoutHandler.hpp" #include "vmime/net/timeoutHandler.hpp"
#include "vmime/net/session.hpp" #include "vmime/net/session.hpp"
#include "vmime/net/connectionInfos.hpp"
#include "vmime/net/imap/IMAPParser.hpp" #include "vmime/net/imap/IMAPParser.hpp"
@ -92,6 +93,9 @@ public:
ref <security::authenticator> getAuthenticator(); ref <security::authenticator> getAuthenticator();
const bool isSecuredConnection() const;
ref <connectionInfos> getConnectionInfos() const;
private: private:
void authenticate(); void authenticate();
@ -120,6 +124,9 @@ private:
ref <timeoutHandler> m_timeoutHandler; ref <timeoutHandler> m_timeoutHandler;
bool m_secured;
ref <connectionInfos> m_cntInfos;
void internalDisconnect(); void internalDisconnect();

View File

@ -78,7 +78,10 @@ public:
const int getCapabilities() const; const int getCapabilities() const;
const bool isIMAPS() const;
const bool isSecuredConnection() const; const bool isSecuredConnection() const;
ref <connectionInfos> getConnectionInfos() const;
protected: protected:
@ -95,7 +98,7 @@ protected:
std::list <IMAPFolder*> m_folders; std::list <IMAPFolder*> m_folders;
bool m_secured; // Use IMAPS const bool m_isIMAPS; // Use IMAPS
static IMAPServiceInfos sm_infos; static IMAPServiceInfos sm_infos;

View File

@ -79,6 +79,9 @@ public:
const int getCapabilities() const; const int getCapabilities() const;
const bool isSecuredConnection() const;
ref <connectionInfos> getConnectionInfos() const;
private: private:
void registerFolder(maildirFolder* folder); void registerFolder(maildirFolder* folder);

View File

@ -77,6 +77,9 @@ public:
const int getCapabilities() const; const int getCapabilities() const;
const bool isSecuredConnection() const;
ref <connectionInfos> getConnectionInfos() const;
private: private:
enum ResponseCode enum ResponseCode
@ -123,7 +126,10 @@ private:
ref <timeoutHandler> m_timeoutHandler; ref <timeoutHandler> m_timeoutHandler;
const bool m_isPOP3S;
bool m_secured; bool m_secured;
ref <connectionInfos> m_cntInfos;
// Service infos // Service infos

View File

@ -0,0 +1,47 @@
//
// VMime library (http://www.vmime.org)
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
#ifndef VMIME_NET_SECUREDCONNECTIONINFOS_HPP_INCLUDED
#define VMIME_NET_SECUREDCONNECTIONINFOS_HPP_INCLUDED
#include "vmime/net/connectionInfos.hpp"
namespace vmime {
namespace net {
/** Information about the secured connection used by a service.
*/
class securedConnectionInfos : public connectionInfos
{
};
} // net
} // vmime
#endif // VMIME_NET_SECUREDCONNECTIONINFOS_HPP_INCLUDED

View File

@ -65,6 +65,9 @@ public:
void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL); void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL);
const bool isSecuredConnection() const;
ref <connectionInfos> getConnectionInfos() const;
private: private:
void internalDisconnect(); void internalDisconnect();

View File

@ -31,6 +31,7 @@
#include "vmime/net/session.hpp" #include "vmime/net/session.hpp"
#include "vmime/net/serviceInfos.hpp" #include "vmime/net/serviceInfos.hpp"
#include "vmime/net/connectionInfos.hpp"
#include "vmime/net/socket.hpp" #include "vmime/net/socket.hpp"
#include "vmime/net/timeoutHandler.hpp" #include "vmime/net/timeoutHandler.hpp"
@ -191,6 +192,18 @@ public:
m_session->getProperties()[getInfos().getPropertyPrefix() + name] = value; m_session->getProperties()[getInfos().getPropertyPrefix() + name] = value;
} }
/** Check whether the connection is secured.
*
* @return true if the connection is secured, false otherwise
*/
virtual const bool isSecuredConnection() const = 0;
/** Get information about the connection.
*
* @return information about the connection
*/
virtual ref <connectionInfos> getConnectionInfos() const = 0;
private: private:
ref <session> m_session; ref <session> m_session;

View File

@ -65,6 +65,9 @@ public:
void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL); void send(const mailbox& expeditor, const mailboxList& recipients, utility::inputStream& is, const utility::stream::size_type size, utility::progressListener* progress = NULL);
const bool isSecuredConnection() const;
ref <connectionInfos> getConnectionInfos() const;
private: private:
void sendRequest(const string& buffer, const bool end = true); void sendRequest(const string& buffer, const bool end = true);
@ -89,7 +92,10 @@ private:
ref <timeoutHandler> m_timeoutHandler; ref <timeoutHandler> m_timeoutHandler;
const bool m_isSMTPS;
bool m_secured; bool m_secured;
ref <connectionInfos> m_cntInfos;
// Service infos // Service infos

View File

@ -0,0 +1,76 @@
//
// VMime library (http://www.vmime.org)
// Copyright (C) 2002-2005 Vincent Richard <vincent@vincent-richard.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
#ifndef VMIME_NET_TLSSECUREDCONNECTIONINFOS_HPP_INCLUDED
#define VMIME_NET_TLSSECUREDCONNECTIONINFOS_HPP_INCLUDED
#include "vmime/net/securedConnectionInfos.hpp"
#include "vmime/security/cert/certificateChain.hpp"
namespace vmime {
namespace net {
namespace tls {
class TLSSession;
class TLSSocket;
/** Information about a TLS-secured connection used by a service.
*/
class TLSSecuredConnectionInfos : public securedConnectionInfos
{
public:
TLSSecuredConnectionInfos(const string& host, const port_t port,
ref <TLSSession> tlsSession, ref <TLSSocket> tlsSocket);
const string getHost() const;
const port_t getPort() const;
/** Return the peer's certificate (chain) as sent by the peer.
*
* @return server certificate chain
*/
ref <const security::cert::certificateChain> getPeerCertificates() const;
private:
string m_host;
port_t m_port;
ref <TLSSession> m_tlsSession;
ref <TLSSocket> m_tlsSocket;
};
} // tls
} // net
} // vmime
#endif // VMIME_NET_TLSSECUREDCONNECTIONINFOS_HPP_INCLUDED