#NEWLINE# def gen_www_authn( request ) : #NEWLINE# #INDENT# def generateWWWAuthenticate( scheme , challenge ) : #NEWLINE# #INDENT# l = [ ] #NEWLINE# for ( k , v ) in challenge . iteritems ( ) : #NEWLINE# #INDENT# l . append ( ( '%s=%s' % ( k , quoteString ( v ) ) ) ) #NEWLINE# #UNINDENT# return ( '%s %s' % ( scheme , ', ' . join ( l ) ) ) #NEWLINE# #UNINDENT# def quoteString( s ) : #NEWLINE# #INDENT# return ( '"%s"' % ( s . replace ( '\\' , '\\\\' ) . replace ( '"' , '\\"' ) , ) ) #NEWLINE# #UNINDENT# import vcdm #NEWLINE# ( authn_methods , _ ) = vcdm . env [ 'authn_methods' ] #NEWLINE# for fact in authn_methods : #NEWLINE# #INDENT# challenge = fact . getChallenge ( request ) #NEWLINE# request . responseHeaders . addRawHeader ( 'www-authenticate' , generateWWWAuthenticate ( fact . scheme , challenge ) )