1176
1177
return password
1178
1179
def decode_password(self, credentials, encoding):
1181
cs = credential_store_registry.get_credential_store(encoding)
1183
raise ValueError('%r is not a known password_encoding' % encoding)
1184
credentials['password'] = cs.decode_password(credentials)
1179
1185
return credentials
1188
class CredentialStoreRegistry(registry.Registry):
1189
"""A class that registers credential stores.
1191
A credential store provides access to credentials via the password_encoding
1192
field in authentication.conf sections.
1194
Except for stores provided by bzr itself,most stores are expected to be
1195
provided by plugins that will therefore use
1196
register_lazy(password_encoding, module_name, member_name, help=help,
1197
info=info) to install themselves.
1200
def get_credential_store(self, encoding=None):
1201
cs = self.get(encoding)
1207
credential_store_registry = CredentialStoreRegistry()
1210
class CredentialStore(object):
1211
"""An abstract class to implement storage for credentials"""
1213
def decode_password(self, credentials):
1214
"""Returns a password for the provided credentials in clear text."""
1215
raise NotImplementedError(self.decode_password)
1218
class PlainTextCredentialStore(CredentialStore):
1219
"""Plain text credential store for the authentication.conf file."""
1221
def decode_password(self, credentials):
1222
"""See CredentialStore.decode_password."""
1223
return credentials['password']
1226
credential_store_registry.register('plain', PlainTextCredentialStore,
1227
help=PlainTextCredentialStore.__doc__)
1228
credential_store_registry.default_key = 'plain'
1182
1231
class BzrDirConfig(object):
1184
1233
def __init__(self, transport):