1
# Copyright (C) 2005, 2007 Canonical Ltd
1
# Copyright (C) 2005, 2007, 2008 Canonical Ltd
2
2
# Authors: Robert Collins <robert.collins@canonical.com>
1065
1065
return credentials
1067
def set_credentials(self, name, host, user, scheme=None, password=None,
1068
port=None, path=None, verify_certificates=None):
1069
"""Set authentication credentials for a host.
1071
Any existing credentials with matching scheme, host, port and path
1072
will be deleted, regardless of name.
1074
:param name: An arbitrary name to describe this set of credentials.
1075
:param host: Name of the host that accepts these credentials.
1076
:param user: The username portion of these credentials.
1077
:param scheme: The URL scheme (e.g. ssh, http) the credentials apply
1079
:param password: Password portion of these credentials.
1080
:param port: The IP port on the host that these credentials apply to.
1081
:param path: A filesystem path on the host that these credentials
1083
:param verify_certificates: On https, verify server certificates if
1086
values = {'host': host, 'user': user}
1087
if password is not None:
1088
values['password'] = password
1089
if scheme is not None:
1090
values['scheme'] = scheme
1091
if port is not None:
1092
values['port'] = '%d' % port
1093
if path is not None:
1094
values['path'] = path
1095
if verify_certificates is not None:
1096
values['verify_certificates'] = str(verify_certificates)
1097
config = self._get_config()
1099
for section, existing_values in config.items():
1100
for key in ('scheme', 'host', 'port', 'path'):
1101
if existing_values.get(key) != values.get(key):
1105
config.update({name: values})
1067
1108
def get_user(self, scheme, host, port=None,
1068
1109
realm=None, path=None, prompt=None):
1069
1110
"""Get a user from authentication file.