diff options
author | Vincent Richard <[email protected]> | 2006-01-29 17:36:34 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2006-01-29 17:36:34 +0000 |
commit | 1539754d5357df5eed7a88cc3f2955c87af9faae (patch) | |
tree | 76089fb32db228042b3185fcd7889e91e0f5fe92 /src/net/smtp/SMTPTransport.cpp | |
parent | getPeerCertificates() should be const. (diff) | |
download | vmime-1539754d5357df5eed7a88cc3f2955c87af9faae.tar.gz vmime-1539754d5357df5eed7a88cc3f2955c87af9faae.zip |
Added service::isSecuredConnection() and service::getConnectionInfos() to retrieve information about the connection.
Diffstat (limited to 'src/net/smtp/SMTPTransport.cpp')
-rw-r--r-- | src/net/smtp/SMTPTransport.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
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; } |