#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def threepid_from_creds( self , creds ) : #NEWLINE# #INDENT# ( yield run_on_reactor ( ) ) #NEWLINE# if ( 'id_server' in creds ) : #NEWLINE# #INDENT# id_server = creds [ 'id_server' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'idServer' in creds ) : #NEWLINE# #INDENT# id_server = creds [ 'idServer' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise SynapseError ( 400 , 'No id_server in creds' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'client_secret' in creds ) : #NEWLINE# #INDENT# client_secret = creds [ 'client_secret' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'clientSecret' in creds ) : #NEWLINE# #INDENT# client_secret = creds [ 'clientSecret' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise SynapseError ( 400 , 'No client_secret in creds' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( id_server not in self . trusted_id_servers ) : #NEWLINE# #INDENT# if self . trust_any_id_server_just_for_testing_do_not_use : #NEWLINE# #INDENT# logger . warn ( "Trusting untrustworthy ID server %r even though it isn't in the trusted id list for testing because 'use_insecure_ssl_client_just_for_testing_do_not_use' is set in the config" , id_server ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . warn ( ( '%s is not a trusted ID server: rejecting 3pid ' + 'credentials' ) , id_server ) #NEWLINE# defer . returnValue ( None ) #NEWLINE# #UNINDENT# #UNINDENT# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# data = ( yield self . http_client . get_json ( ( 'https://%s%s' % ( id_server , '/_matrix/identity/api/v1/3pid/getValidated3pid' ) ) , { #NEWLINE# #INDENT# 'sid' : creds [ 'sid' ] , #NEWLINE# 'client_secret' : client_secret , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# except CodeMessageException as e : #NEWLINE# #INDENT# data = json . loads ( e . msg ) #NEWLINE# #UNINDENT# if ( 'medium' in id_server ) : #NEWLINE# #INDENT# defer . returnValue ( data ) #NEWLINE# #UNINDENT# defer . returnValue ( None )