100
def _create_connection(self, credentials=None):
101
"""Create a new connection with the provided credentials.
103
:param credentials: The credentials needed to establish the connection.
105
:return: The created connection and its associated credentials.
107
The credentials are a tuple with the username and password. The
108
password is used if GSSAPI Authentication is not available.
100
connection_class = GSSAPIFtp
102
def _login(self, connection, auth, user, password):
103
"""Login with GSSAPI Authentication.
105
The password is used if GSSAPI Authentication is not available.
110
107
The username and password can both be None, in which case the
111
108
credentials specified in the URL or provided by the
112
109
AuthenticationConfig() are used.
114
if credentials is None:
115
user, password = self._user, self._password
117
user, password = credentials
119
auth = config.AuthenticationConfig()
121
user = auth.get_user('ftp', self._host, port=self._port,
122
default=getpass.getuser())
123
mutter("Constructing FTP instance against %r" %
124
((self._host, self._port, user, '********',
127
connection = GSSAPIFtp()
128
connection.connect(host=self._host, port=self._port)
130
connection.gssapi_login(user=user)
131
except ftplib.error_perm, e:
132
if user and user != 'anonymous' and \
133
password is None: # '' is a valid password
134
password = auth.get_password('ftp', self._host, user,
136
connection.login(user=user, passwd=password)
137
connection.set_pasv(not self.is_active)
138
except socket.error, e:
139
raise errors.SocketConnectionError(self._host, self._port,
140
msg='Unable to connect to',
112
connection.gssapi_login(user=user)
142
113
except ftplib.error_perm, e:
143
raise errors.TransportError(msg="Error setting up connection:"
144
" %s" % str(e), orig_error=e)
145
return connection, (user, password)
114
super(GSSAPIFtpTransport, self)._login(connection, auth,
148
118
def get_test_permutations():