<s> """<STR_LIT>""" <EOL> import sys <EOL> from zope . interface import implements <EOL> from twisted . python import log <EOL> from twisted . internet import reactor <EOL> from twisted . web import server , resource , guard <EOL> from twisted . cred . portal import IRealm , Portal <EOL> from twisted . cred . checkers import InMemoryUsernamePasswordDatabaseDontUse <EOL> class GuardedResource ( resource . Resource ) : <EOL> """<STR_LIT>""" <EOL> def getChild ( self , path , request ) : <EOL> return self <EOL> def render ( self , request ) : <EOL> return "<STR_LIT>" <EOL> class SimpleRealm ( object ) : <EOL> """<STR_LIT>""" <EOL> implements ( IRealm ) <EOL> def requestAvatar ( self , avatarId , mind , * interfaces ) : <EOL> if resource . IResource in interfaces : <EOL> return resource . IResource , GuardedResource ( ) , lambda : None <EOL> raise NotImplementedError ( ) <EOL> def main ( ) : <EOL> log . startLogging ( sys . stdout ) <EOL> checkers = [ InMemoryUsernamePasswordDatabaseDontUse ( joe = '<STR_LIT>' ) ] <EOL> wrapper = guard . HTTPAuthSessionWrapper ( <EOL> Portal ( SimpleRealm ( ) , checkers ) , <EOL> [ guard . DigestCredentialFactory ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> reactor . listenTCP ( <NUM_LIT> , server . Site ( <EOL> resource = wrapper ) ) <EOL> reactor . run ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
