~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smtp_connection.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-04 18:51:39 UTC
  • mfrom: (2961.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20071104185139-kaio3sneodg2kp71
Authentication ring implementation (read-only)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import smtplib
22
22
import socket
23
23
 
24
 
from bzrlib import ui
 
24
from bzrlib import (
 
25
    config,
 
26
    ui,
 
27
    )
25
28
from bzrlib.errors import (
26
29
    NoDestinationAddress,
27
30
    SMTPError,
98
101
 
99
102
    def _authenticate(self):
100
103
        """If necessary authenticate yourself to the server."""
 
104
        auth = config.AuthenticationConfig()
101
105
        if self._smtp_username is None:
102
 
            return
 
106
            self._smtp_username = auth.get_user('smtp', self._smtp_server)
 
107
            if self._smtp_username is None:
 
108
                return
103
109
 
104
110
        if self._smtp_password is None:
105
 
            self._smtp_password = ui.ui_factory.get_password(
106
 
                'Please enter the SMTP password: %(user)s@%(host)s',
107
 
                user=self._smtp_username,
108
 
                host=self._smtp_server)
 
111
            self._smtp_password = auth.get_password(
 
112
                'smtp', self._smtp_server, self._smtp_username)
109
113
 
110
114
        self._connection.login(self._smtp_username, self._smtp_password)
111
115