1131
1132
return password
1133
1134
def decode_password(self, credentials, encoding):
1136
cs = credential_store_registry.get_credential_store(encoding)
1138
raise ValueError('%r is not a known password_encoding' % encoding)
1139
credentials['password'] = cs.decode_password(credentials)
1134
1140
return credentials
1143
class CredentialStoreRegistry(registry.Registry):
1144
"""A class that registers credential stores.
1146
A credential store provides access to credentials via the password_encoding
1147
field in authentication.conf sections.
1149
Except for stores provided by bzr itself,most stores are expected to be
1150
provided by plugins that will therefore use
1151
register_lazy(password_encoding, module_name, member_name, help=help,
1152
info=info) to install themselves.
1155
def get_credential_store(self, encoding=None):
1156
cs = self.get(encoding)
1162
credential_store_registry = CredentialStoreRegistry()
1165
class CredentialStore(object):
1166
"""An abstract class to implement storage for credentials"""
1168
def decode_password(self, credentials):
1169
"""Returns a password for the provided credentials in clear text."""
1170
raise NotImplementedError(self.decode_password)
1173
class PlainTextCredentialStore(CredentialStore):
1174
"""Plain text credential store for the authentication.conf file."""
1176
def decode_password(self, credentials):
1177
"""See CredentialStore.decode_password."""
1178
return credentials['password']
1181
credential_store_registry.register('plain', PlainTextCredentialStore,
1182
help=PlainTextCredentialStore.__doc__)
1183
credential_store_registry.default_key = 'plain'
1137
1186
class BzrDirConfig(object):
1139
1188
def __init__(self, transport):