aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2006-01-29 17:36:34 +0000
committerVincent Richard <[email protected]>2006-01-29 17:36:34 +0000
commit1539754d5357df5eed7a88cc3f2955c87af9faae (patch)
tree76089fb32db228042b3185fcd7889e91e0f5fe92
parentgetPeerCertificates() should be const. (diff)
downloadvmime-1539754d5357df5eed7a88cc3f2955c87af9faae.tar.gz
vmime-1539754d5357df5eed7a88cc3f2955c87af9faae.zip
Added service::isSecuredConnection() and service::getConnectionInfos() to retrieve information about the connection.
-rw-r--r--ChangeLog5
-rw-r--r--SConstruct4
-rw-r--r--examples/example6.cpp7
-rw-r--r--src/net/defaultConnectionInfos.cpp52
-rw-r--r--src/net/imap/IMAPConnection.cpp34
-rw-r--r--src/net/imap/IMAPStore.cpp32
-rw-r--r--src/net/maildir/maildirStore.cpp14
-rw-r--r--src/net/pop3/POP3Store.cpp36
-rw-r--r--src/net/sendmail/sendmailTransport.cpp14
-rw-r--r--src/net/smtp/SMTPTransport.cpp35
-rw-r--r--src/net/tls/TLSSecuredConnectionInfos.cpp63
-rw-r--r--vmime/net/connectionInfos.hpp60
-rw-r--r--vmime/net/defaultConnectionInfos.hpp58
-rw-r--r--vmime/net/imap/IMAPConnection.hpp7
-rw-r--r--vmime/net/imap/IMAPStore.hpp5
-rw-r--r--vmime/net/maildir/maildirStore.hpp3
-rw-r--r--vmime/net/pop3/POP3Store.hpp6
-rw-r--r--vmime/net/securedConnectionInfos.hpp47
-rw-r--r--vmime/net/sendmail/sendmailTransport.hpp3
-rw-r--r--vmime/net/service.hpp13
-rw-r--r--vmime/net/smtp/SMTPTransport.hpp6
-rw-r--r--vmime/net/tls/TLSSecuredConnectionInfos.hpp76
22 files changed, 564 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 54fe8aa3..e8b4c35b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
VERSION 0.8.1cvs
================
+2006-01-29 Vincent Richard <[email protected]>
+
+ * Added service::isSecuredConnection() and service::getConnectionInfos()
+ to retrieve information about the connection.
+
2006-01-16 Vincent Richard <[email protected]>
* Added support for attachments of type "message/rfc822".
diff --git a/SConstruct b/SConstruct
index d2c17549..4b1894d2 100644
--- a/SConstruct
+++ b/SConstruct
@@ -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',
diff --git a/examples/example6.cpp b/examples/example6.cpp
index 344a4d87..7bd7a82c 100644
--- a/examples/example6.cpp
+++ b/examples/example6.cpp
@@ -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"));
diff --git a/src/net/defaultConnectionInfos.cpp b/src/net/defaultConnectionInfos.cpp
new file mode 100644
index 00000000..e6ecfae0
--- /dev/null
+++ b/src/net/defaultConnectionInfos.cpp
@@ -0,0 +1,52 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// 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
+
+
diff --git a/src/net/imap/IMAPConnection.cpp b/src/net/imap/IMAPConnection.cpp
index 76c09316..e4a49041 100644
--- a/src/net/imap/IMAPConnection.cpp
+++ b/src/net/imap/IMAPConnection.cpp
@@ -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;
}
diff --git a/src/net/imap/IMAPStore.cpp b/src/net/imap/IMAPStore.cpp
index 95f96276..aba36751 100644
--- a/src/net/imap/IMAPStore.cpp
+++ b/src/net/imap/IMAPStore.cpp
@@ -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())
diff --git a/src/net/maildir/maildirStore.cpp b/src/net/maildir/maildirStore.cpp
index d1baf8dd..2803b17b 100644
--- a/src/net/maildir/maildirStore.cpp
+++ b/src/net/maildir/maildirStore.cpp
@@ -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() ;
diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp
index 29a22dcf..5340e50d 100644
--- a/src/net/pop3/POP3Store.cpp
+++ b/src/net/pop3/POP3Store.cpp
@@ -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;
}
diff --git a/src/net/sendmail/sendmailTransport.cpp b/src/net/sendmail/sendmailTransport.cpp
index 2b5c4b04..514a66a6 100644
--- a/src/net/sendmail/sendmailTransport.cpp
+++ b/src/net/sendmail/sendmailTransport.cpp
@@ -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())
diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
index 48ea5cdc..385ebcec 100644
--- a/src/net/smtp/SMTPTransport.cpp
+++ b/src/net/smtp/SMTPTransport.cpp
@@ -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;
}
diff --git a/src/net/tls/TLSSecuredConnectionInfos.cpp b/src/net/tls/TLSSecuredConnectionInfos.cpp
new file mode 100644
index 00000000..2670b81b
--- /dev/null
+++ b/src/net/tls/TLSSecuredConnectionInfos.cpp
@@ -0,0 +1,63 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// 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
+
diff --git a/vmime/net/connectionInfos.hpp b/vmime/net/connectionInfos.hpp
new file mode 100644
index 00000000..ee02eb16
--- /dev/null
+++ b/vmime/net/connectionInfos.hpp
@@ -0,0 +1,60 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// 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
+
diff --git a/vmime/net/defaultConnectionInfos.hpp b/vmime/net/defaultConnectionInfos.hpp
new file mode 100644
index 00000000..39530f18
--- /dev/null
+++ b/vmime/net/defaultConnectionInfos.hpp
@@ -0,0 +1,58 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// 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
+
diff --git a/vmime/net/imap/IMAPConnection.hpp b/vmime/net/imap/IMAPConnection.hpp
index f01236f2..3ca9b007 100644
--- a/vmime/net/imap/IMAPConnection.hpp
+++ b/vmime/net/imap/IMAPConnection.hpp
@@ -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();
diff --git a/vmime/net/imap/IMAPStore.hpp b/vmime/net/imap/IMAPStore.hpp
index 26810b9d..ce38190b 100644
--- a/vmime/net/imap/IMAPStore.hpp
+++ b/vmime/net/imap/IMAPStore.hpp
@@ -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;
diff --git a/vmime/net/maildir/maildirStore.hpp b/vmime/net/maildir/maildirStore.hpp
index f2792403..a229ae8c 100644
--- a/vmime/net/maildir/maildirStore.hpp
+++ b/vmime/net/maildir/maildirStore.hpp
@@ -79,6 +79,9 @@ public:
const int getCapabilities() const;
+ const bool isSecuredConnection() const;
+ ref <connectionInfos> getConnectionInfos() const;
+
private:
void registerFolder(maildirFolder* folder);
diff --git a/vmime/net/pop3/POP3Store.hpp b/vmime/net/pop3/POP3Store.hpp
index 2839d198..98d2e380 100644
--- a/vmime/net/pop3/POP3Store.hpp
+++ b/vmime/net/pop3/POP3Store.hpp
@@ -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
diff --git a/vmime/net/securedConnectionInfos.hpp b/vmime/net/securedConnectionInfos.hpp
new file mode 100644
index 00000000..2af7b970
--- /dev/null
+++ b/vmime/net/securedConnectionInfos.hpp
@@ -0,0 +1,47 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// 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
+
diff --git a/vmime/net/sendmail/sendmailTransport.hpp b/vmime/net/sendmail/sendmailTransport.hpp
index 75a7c704..9a362179 100644
--- a/vmime/net/sendmail/sendmailTransport.hpp
+++ b/vmime/net/sendmail/sendmailTransport.hpp
@@ -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();
diff --git a/vmime/net/service.hpp b/vmime/net/service.hpp
index ec165462..8104cd50 100644
--- a/vmime/net/service.hpp
+++ b/vmime/net/service.hpp
@@ -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;
diff --git a/vmime/net/smtp/SMTPTransport.hpp b/vmime/net/smtp/SMTPTransport.hpp
index d42288b7..8269fe3f 100644
--- a/vmime/net/smtp/SMTPTransport.hpp
+++ b/vmime/net/smtp/SMTPTransport.hpp
@@ -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
diff --git a/vmime/net/tls/TLSSecuredConnectionInfos.hpp b/vmime/net/tls/TLSSecuredConnectionInfos.hpp
new file mode 100644
index 00000000..77fc5ddb
--- /dev/null
+++ b/vmime/net/tls/TLSSecuredConnectionInfos.hpp
@@ -0,0 +1,76 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// 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
+