Added service::isSecuredConnection() and service::getConnectionInfos() to retrieve information about the connection.
This commit is contained in:
parent
bfe8c00465
commit
1539754d53
@ -2,6 +2,11 @@
|
||||
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>
|
||||
|
||||
* Added support for attachments of type "message/rfc822".
|
||||
|
@ -198,9 +198,12 @@ libvmime_examples_sources = [
|
||||
|
||||
libvmime_messaging_sources = [
|
||||
'net/builtinServices.inl',
|
||||
'net/connectionInfos.hpp',
|
||||
'net/defaultConnectionInfos.cpp', 'net/defaultConnectionInfos.hpp',
|
||||
'net/events.cpp', 'net/events.hpp',
|
||||
'net/folder.cpp', 'net/folder.hpp',
|
||||
'net/message.cpp', 'net/message.hpp',
|
||||
'net/securedConnectionInfos.hpp',
|
||||
'net/service.cpp', 'net/service.hpp',
|
||||
'net/serviceFactory.cpp', 'net/serviceFactory.hpp',
|
||||
'net/serviceInfos.cpp', 'net/serviceInfos.hpp',
|
||||
@ -215,6 +218,7 @@ libvmime_messaging_sources = [
|
||||
libvmime_net_tls_sources = [
|
||||
'net/tls/TLSSession.cpp', 'net/tls/TLSSession.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/certificateVerifier.hpp',
|
||||
'security/cert/defaultCertificateVerifier.cpp', 'security/cert/defaultCertificateVerifier.hpp',
|
||||
|
@ -516,6 +516,13 @@ static void connectStore()
|
||||
// Connect to the mail store
|
||||
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
|
||||
vmime::ref <vmime::net::folder> f = st->getDefaultFolder();
|
||||
// vmime::ref <vmime::net::folder> f = st->getFolder(vmime::utility::path("a"));
|
||||
|
52
src/net/defaultConnectionInfos.cpp
Normal file
52
src/net/defaultConnectionInfos.cpp
Normal 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
|
||||
|
||||
|
@ -25,12 +25,15 @@
|
||||
#include "vmime/exception.hpp"
|
||||
#include "vmime/platformDependant.hpp"
|
||||
|
||||
#include "vmime/net/defaultConnectionInfos.hpp"
|
||||
|
||||
#if VMIME_HAVE_SASL_SUPPORT
|
||||
#include "vmime/security/sasl/SASLContext.hpp"
|
||||
#endif // VMIME_HAVE_SASL_SUPPORT
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
#include "vmime/net/tls/TLSSession.hpp"
|
||||
#include "vmime/net/tls/TLSSecuredConnectionInfos.hpp"
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
#include <sstream>
|
||||
@ -52,7 +55,8 @@ namespace imap {
|
||||
|
||||
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_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();
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
if (m_store->isSecuredConnection()) // dedicated port/IMAPS
|
||||
if (m_store->isIMAPS()) // dedicated port/IMAPS
|
||||
{
|
||||
ref <tls::TLSSession> tlsSession =
|
||||
vmime::create <tls::TLSSession>(m_store->getCertificateVerifier());
|
||||
@ -101,8 +105,15 @@ void IMAPConnection::connect()
|
||||
tlsSession->getSocket(m_socket);
|
||||
|
||||
m_socket = tlsSocket;
|
||||
|
||||
m_secured = true;
|
||||
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
|
||||
}
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
else
|
||||
{
|
||||
m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
|
||||
}
|
||||
|
||||
m_socket->connect(address, port);
|
||||
|
||||
@ -446,6 +457,10 @@ void IMAPConnection::startTLS()
|
||||
|
||||
m_socket = tlsSocket;
|
||||
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&)
|
||||
{
|
||||
@ -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()
|
||||
{
|
||||
if (!isConnected())
|
||||
@ -539,6 +566,9 @@ void IMAPConnection::internalDisconnect()
|
||||
m_timeoutHandler = NULL;
|
||||
|
||||
m_state = STATE_LOGOUT;
|
||||
|
||||
m_secured = false;
|
||||
m_cntInfos = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace imap {
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (!isConnected())
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "vmime/exception.hpp"
|
||||
#include "vmime/platformDependant.hpp"
|
||||
|
||||
#include "vmime/net/defaultConnectionInfos.hpp"
|
||||
|
||||
|
||||
// Helpers for service properties
|
||||
#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()
|
||||
{
|
||||
for (std::list <maildirFolder*>::iterator it = m_folders.begin() ;
|
||||
|
@ -27,12 +27,15 @@
|
||||
#include "vmime/utility/filteredStream.hpp"
|
||||
#include "vmime/utility/stringUtils.hpp"
|
||||
|
||||
#include "vmime/net/defaultConnectionInfos.hpp"
|
||||
|
||||
#if VMIME_HAVE_SASL_SUPPORT
|
||||
#include "vmime/security/sasl/SASLContext.hpp"
|
||||
#endif // VMIME_HAVE_SASL_SUPPORT
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
#include "vmime/net/tls/TLSSession.hpp"
|
||||
#include "vmime/net/tls/TLSSecuredConnectionInfos.hpp"
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
#include <algorithm>
|
||||
@ -54,7 +57,8 @@ namespace pop3 {
|
||||
|
||||
POP3Store::POP3Store(ref <session> sess, ref <security::authenticator> auth, const bool secured)
|
||||
: 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();
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
if (m_secured) // dedicated port/POP3S
|
||||
if (m_isPOP3S) // dedicated port/POP3S
|
||||
{
|
||||
ref <tls::TLSSession> tlsSession =
|
||||
vmime::create <tls::TLSSession>(getCertificateVerifier());
|
||||
@ -139,8 +143,15 @@ void POP3Store::connect()
|
||||
tlsSession->getSocket(m_socket);
|
||||
|
||||
m_socket = tlsSocket;
|
||||
|
||||
m_secured = true;
|
||||
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
|
||||
}
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
else
|
||||
{
|
||||
m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
|
||||
}
|
||||
|
||||
m_socket->connect(address, port);
|
||||
|
||||
@ -165,7 +176,7 @@ void POP3Store::connect()
|
||||
const bool tlsRequired = HAS_PROPERTY(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
|
||||
{
|
||||
@ -533,6 +544,10 @@ void POP3Store::startTLS()
|
||||
tlsSocket->handshake(m_timeoutHandler);
|
||||
|
||||
m_socket = tlsSocket;
|
||||
|
||||
m_secured = true;
|
||||
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>
|
||||
(m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket);
|
||||
}
|
||||
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()
|
||||
{
|
||||
if (!isConnected())
|
||||
@ -590,6 +617,9 @@ void POP3Store::internalDisconnect()
|
||||
m_timeoutHandler = NULL;
|
||||
|
||||
m_authentified = false;
|
||||
|
||||
m_secured = false;
|
||||
m_cntInfos = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "vmime/utility/childProcess.hpp"
|
||||
#include "vmime/utility/smartPtr.hpp"
|
||||
|
||||
#include "vmime/net/defaultConnectionInfos.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()
|
||||
{
|
||||
if (!isConnected())
|
||||
|
@ -28,12 +28,15 @@
|
||||
#include "vmime/utility/filteredStream.hpp"
|
||||
#include "vmime/utility/stringUtils.hpp"
|
||||
|
||||
#include "vmime/net/defaultConnectionInfos.hpp"
|
||||
|
||||
#if VMIME_HAVE_SASL_SUPPORT
|
||||
#include "vmime/security/sasl/SASLContext.hpp"
|
||||
#endif // VMIME_HAVE_SASL_SUPPORT
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
#include "vmime/net/tls/TLSSession.hpp"
|
||||
#include "vmime/net/tls/TLSSecuredConnectionInfos.hpp"
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
|
||||
@ -54,7 +57,7 @@ namespace smtp {
|
||||
SMTPTransport::SMTPTransport(ref <session> sess, ref <security::authenticator> auth, const bool secured)
|
||||
: transport(sess, getInfosInstance(), auth), m_socket(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();
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
if (m_secured) // dedicated port/SMTPS
|
||||
if (m_isSMTPS) // dedicated port/SMTPS
|
||||
{
|
||||
ref <tls::TLSSession> tlsSession =
|
||||
vmime::create <tls::TLSSession>(getCertificateVerifier());
|
||||
@ -106,8 +109,15 @@ void SMTPTransport::connect()
|
||||
tlsSession->getSocket(m_socket);
|
||||
|
||||
m_socket = tlsSocket;
|
||||
|
||||
m_secured = true;
|
||||
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
|
||||
}
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
else
|
||||
{
|
||||
m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
|
||||
}
|
||||
|
||||
m_socket->connect(address, port);
|
||||
|
||||
@ -163,7 +173,7 @@ void SMTPTransport::connect()
|
||||
const bool tlsRequired = HAS_PROPERTY(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
|
||||
{
|
||||
@ -436,6 +446,10 @@ void SMTPTransport::startTLS()
|
||||
tlsSocket->handshake(m_timeoutHandler);
|
||||
|
||||
m_socket = tlsSocket;
|
||||
|
||||
m_secured = true;
|
||||
m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>
|
||||
(m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket);
|
||||
}
|
||||
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()
|
||||
{
|
||||
if (!isConnected())
|
||||
@ -486,6 +512,9 @@ void SMTPTransport::internalDisconnect()
|
||||
|
||||
m_authentified = false;
|
||||
m_extendedSMTP = false;
|
||||
|
||||
m_secured = false;
|
||||
m_cntInfos = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
63
src/net/tls/TLSSecuredConnectionInfos.cpp
Normal file
63
src/net/tls/TLSSecuredConnectionInfos.cpp
Normal 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
|
||||
|
60
vmime/net/connectionInfos.hpp
Normal file
60
vmime/net/connectionInfos.hpp
Normal 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
|
||||
|
58
vmime/net/defaultConnectionInfos.hpp
Normal file
58
vmime/net/defaultConnectionInfos.hpp
Normal 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
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "vmime/net/socket.hpp"
|
||||
#include "vmime/net/timeoutHandler.hpp"
|
||||
#include "vmime/net/session.hpp"
|
||||
#include "vmime/net/connectionInfos.hpp"
|
||||
|
||||
#include "vmime/net/imap/IMAPParser.hpp"
|
||||
|
||||
@ -92,6 +93,9 @@ public:
|
||||
|
||||
ref <security::authenticator> getAuthenticator();
|
||||
|
||||
const bool isSecuredConnection() const;
|
||||
ref <connectionInfos> getConnectionInfos() const;
|
||||
|
||||
private:
|
||||
|
||||
void authenticate();
|
||||
@ -120,6 +124,9 @@ private:
|
||||
|
||||
ref <timeoutHandler> m_timeoutHandler;
|
||||
|
||||
bool m_secured;
|
||||
ref <connectionInfos> m_cntInfos;
|
||||
|
||||
|
||||
void internalDisconnect();
|
||||
|
||||
|
@ -78,7 +78,10 @@ public:
|
||||
|
||||
const int getCapabilities() const;
|
||||
|
||||
const bool isIMAPS() const;
|
||||
|
||||
const bool isSecuredConnection() const;
|
||||
ref <connectionInfos> getConnectionInfos() const;
|
||||
|
||||
protected:
|
||||
|
||||
@ -95,7 +98,7 @@ protected:
|
||||
|
||||
std::list <IMAPFolder*> m_folders;
|
||||
|
||||
bool m_secured; // Use IMAPS
|
||||
const bool m_isIMAPS; // Use IMAPS
|
||||
|
||||
|
||||
static IMAPServiceInfos sm_infos;
|
||||
|
@ -79,6 +79,9 @@ public:
|
||||
|
||||
const int getCapabilities() const;
|
||||
|
||||
const bool isSecuredConnection() const;
|
||||
ref <connectionInfos> getConnectionInfos() const;
|
||||
|
||||
private:
|
||||
|
||||
void registerFolder(maildirFolder* folder);
|
||||
|
@ -77,6 +77,9 @@ public:
|
||||
|
||||
const int getCapabilities() const;
|
||||
|
||||
const bool isSecuredConnection() const;
|
||||
ref <connectionInfos> getConnectionInfos() const;
|
||||
|
||||
private:
|
||||
|
||||
enum ResponseCode
|
||||
@ -123,7 +126,10 @@ private:
|
||||
|
||||
ref <timeoutHandler> m_timeoutHandler;
|
||||
|
||||
const bool m_isPOP3S;
|
||||
|
||||
bool m_secured;
|
||||
ref <connectionInfos> m_cntInfos;
|
||||
|
||||
|
||||
// Service infos
|
||||
|
47
vmime/net/securedConnectionInfos.hpp
Normal file
47
vmime/net/securedConnectionInfos.hpp
Normal 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
|
||||
|
@ -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);
|
||||
|
||||
const bool isSecuredConnection() const;
|
||||
ref <connectionInfos> getConnectionInfos() const;
|
||||
|
||||
private:
|
||||
|
||||
void internalDisconnect();
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "vmime/net/session.hpp"
|
||||
|
||||
#include "vmime/net/serviceInfos.hpp"
|
||||
#include "vmime/net/connectionInfos.hpp"
|
||||
|
||||
#include "vmime/net/socket.hpp"
|
||||
#include "vmime/net/timeoutHandler.hpp"
|
||||
@ -191,6 +192,18 @@ public:
|
||||
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:
|
||||
|
||||
ref <session> m_session;
|
||||
|
@ -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);
|
||||
|
||||
const bool isSecuredConnection() const;
|
||||
ref <connectionInfos> getConnectionInfos() const;
|
||||
|
||||
private:
|
||||
|
||||
void sendRequest(const string& buffer, const bool end = true);
|
||||
@ -89,7 +92,10 @@ private:
|
||||
|
||||
ref <timeoutHandler> m_timeoutHandler;
|
||||
|
||||
const bool m_isSMTPS;
|
||||
|
||||
bool m_secured;
|
||||
ref <connectionInfos> m_cntInfos;
|
||||
|
||||
|
||||
// Service infos
|
||||
|
76
vmime/net/tls/TLSSecuredConnectionInfos.hpp
Normal file
76
vmime/net/tls/TLSSecuredConnectionInfos.hpp
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user