<s> from bottle import HTTPResponse <EOL> import base64 <EOL> from collections import namedtuple <EOL> from conans . server . rest . bottle_plugins . authorization_header import AuthorizationHeader <EOL> from conans . util . files import decode_text <EOL> class UserPasswordPair ( namedtuple ( '<STR_LIT>' , [ '<STR_LIT:user>' , '<STR_LIT:password>' ] ) ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> class HttpBasicAuthentication ( AuthorizationHeader ) : <EOL> '''<STR_LIT>''' <EOL> name = '<STR_LIT>' <EOL> api = <NUM_LIT:2> <EOL> def __init__ ( self , keyword = '<STR_LIT>' ) : <EOL> self . keyword = keyword <EOL> super ( HttpBasicAuthentication , self ) . __init__ ( keyword ) <EOL> def get_authorization_type ( self ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> def parse_authorization_value ( self , header_value ) : <EOL> """<STR_LIT>""" <EOL> if header_value is None : <EOL> return None <EOL> username , password = decode_text ( base64 . b64decode ( header_value ) ) . split ( "<STR_LIT::>" , <NUM_LIT:1> ) <EOL> ret = UserPasswordPair ( username , password ) <EOL> return { self . keyword : ret } <EOL> def get_invalid_header_response ( self ) : <EOL> """<STR_LIT>""" <EOL> return HTTPResponse ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> { "<STR_LIT>" : '<STR_LIT>' } ) </s>
