Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
 1: <?php
 2: 
 3: /*
 4:  * This file is part of SwiftMailer.
 5:  * (c) 2004-2009 Chris Corbyn
 6:  *
 7:  * For the full copyright and license information, please view the LICENSE
 8:  * file that was distributed with this source code.
 9:  */
10: 
11: /**
12:  * Handles CRAM-MD5 authentication.
13:  * @package Swift
14:  * @subpackage Transport
15:  * @author Chris Corbyn
16:  */
17: class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport_Esmtp_Authenticator
18: {
19:     /**
20:      * Get the name of the AUTH mechanism this Authenticator handles.
21:      * @return string
22:      */
23:     public function getAuthKeyword()
24:     {
25:         return 'CRAM-MD5';
26:     }
27: 
28:     /**
29:      * Try to authenticate the user with $username and $password.
30:      * @param  Swift_Transport_SmtpAgent $agent
31:      * @param  string                    $username
32:      * @param  string                    $password
33:      * @return boolean
34:      */
35:     public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password)
36:     {
37:         try {
38:             $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", array(334));
39:             $challenge = base64_decode(substr($challenge, 4));
40:             $message = base64_encode(
41:                 $username . ' ' . $this->_getResponse($password, $challenge)
42:                 );
43:             $agent->executeCommand(sprintf("%s\r\n", $message), array(235));
44: 
45:             return true;
46:         } catch (Swift_TransportException $e) {
47:             $agent->executeCommand("RSET\r\n", array(250));
48: 
49:             return false;
50:         }
51:     }
52: 
53:     /**
54:      * Generate a CRAM-MD5 response from a server challenge.
55:      * @param  string $secret
56:      * @param  string $challenge
57:      * @return string
58:      */
59:     private function _getResponse($secret, $challenge)
60:     {
61:         if (strlen($secret) > 64) {
62:             $secret = pack('H32', md5($secret));
63:         }
64: 
65:         if (strlen($secret) < 64) {
66:             $secret = str_pad($secret, 64, chr(0));
67:         }
68: 
69:         $k_ipad = substr($secret, 0, 64) ^ str_repeat(chr(0x36), 64);
70:         $k_opad = substr($secret, 0, 64) ^ str_repeat(chr(0x5C), 64);
71: 
72:         $inner  = pack('H32', md5($k_ipad . $challenge));
73:         $digest = md5($k_opad . $inner);
74: 
75:         return $digest;
76:     }
77: }
78: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen