#NEWLINE# def connect( self ) : #NEWLINE# #INDENT# service = re . split ( '[\\/@]' , str ( self . hdfs_namenode_principal ) ) [ 0 ] #NEWLINE# negotiate = RpcSaslProto ( ) #NEWLINE# negotiate . state = 1 #NEWLINE# self . _send_sasl_message ( negotiate ) #NEWLINE# self . sasl = sasl . Client ( ) #NEWLINE# self . sasl . setAttr ( 'service' , service ) #NEWLINE# self . sasl . setAttr ( 'host' , self . _trans . host ) #NEWLINE# self . sasl . init ( ) #NEWLINE# while True : #NEWLINE# #INDENT# res = self . _recv_sasl_message ( ) #NEWLINE# if ( res . state == 1 ) : #NEWLINE# #INDENT# mechs = [ ] #NEWLINE# for auth in res . auths : #NEWLINE# #INDENT# mechs . append ( auth . mechanism ) #NEWLINE# #UNINDENT# log . debug ( ( 'Available mechs: %s' % ',' . join ( mechs ) ) ) #NEWLINE# s_mechs = str ( ',' . join ( mechs ) ) #NEWLINE# ( ret , chosen_mech , initial_response ) = self . sasl . start ( s_mechs ) #NEWLINE# log . debug ( ( 'Chosen mech: %s' % chosen_mech ) ) #NEWLINE# initiate = RpcSaslProto ( ) #NEWLINE# initiate . state = 2 #NEWLINE# initiate . token = initial_response #NEWLINE# for auth in res . auths : #NEWLINE# #INDENT# if ( auth . mechanism == chosen_mech ) : #NEWLINE# #INDENT# auth_method = initiate . auths . add ( ) #NEWLINE# auth_method . mechanism = chosen_mech #NEWLINE# auth_method . method = auth . method #NEWLINE# auth_method . protocol = auth . protocol #NEWLINE# auth_method . serverId = self . _trans . host #NEWLINE# #UNINDENT# #UNINDENT# self . _send_sasl_message ( initiate ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( res . state == 3 ) : #NEWLINE# #INDENT# res_token = self . _evaluate_token ( res ) #NEWLINE# response = RpcSaslProto ( ) #NEWLINE# response . token = res_token #NEWLINE# response . state = 4 #NEWLINE# self . _send_sasl_message ( ret ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( res . state == 0 ) : #NEWLINE# #INDENT# return True