# Path: txcas/constants.py
# VIEW_LOGIN = 0
# 
# VIEW_LOGIN_SUCCESS = 1
# 
# VIEW_LOGOUT = 2
# 
# VIEW_INVALID_SERVICE = 3
# 
# VIEW_ERROR_5XX = 4
# 
# VIEW_NOT_FOUND = 5
# 
# Path: txcas/interface.py
# class IRealmFactory(Interface):
# 
#     tag = Attribute('String used to identify the plugin factory.')
#     opt_help = Attribute('String description of the plugin.')
#     opt_usage = Attribute('String describes how to provide arguments for factory.')
# 
#     def generateRealm(argstring=""):
#         """
#         Create an object that implements IRealm.
#         """
# 
# class IServiceManagerFactory(Interface):
# 
#     tag = Attribute('String used to identify the plugin factory.')
#     opt_help = Attribute('String description of the plugin.')
#     opt_usage = Attribute('String describes how to provide arguments for factory.')
# 
#     def generateServiceManager(argstring=""):
#         """
#         Create an object that implements txcas.IServiceManager
#         """
# 
# class ITicketStoreFactory(Interface):
# 
#     tag = Attribute('String used to identify the plugin factory.')
#     opt_help = Attribute('String description of the plugin.')
#     opt_usage = Attribute('String describes how to provide arguments for factory.')
# 
#     def generateTicketStore(argstring=""):
#         """
#         Create an object that implements ITicketStore.
#         """
# 
# Path: txcas/server.py
# def escape_html(text):
#     """Produce entities within text."""
#     return "".join(html_escape_table.get(c,c) for c in text)


import argparse
import cgi
import sys
import txcas.settings
    import sys
from textwrap import dedent
from urllib import urlencode
from txcas.constants import (
    VIEW_LOGIN, 
    VIEW_LOGIN_SUCCESS, 
    VIEW_LOGOUT, 
    VIEW_INVALID_SERVICE,
    VIEW_ERROR_5XX,
    VIEW_NOT_FOUND)
from txcas.interface import (
    IRealmFactory,
    IServiceManagerFactory,
    ITicketStoreFactory)
from txcas.server import escape_html
from klein import Klein
from twisted.python import log
from twisted.web import microdom
from twisted.web.client import getPage
        from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse
        from twisted.cred.strcred import ICheckerFactory
        from txcas.server import ServerApp
    from twisted.web.resource import Resource
    from twisted.web.server import Site
    from twisted.internet import reactor
    from twisted.python import log
                    'ticket_store': 'memory_ticket_store',}})
        # Choose plugin that implements IServiceManager.
        service_manager = None
        if scp.has_option('PLUGINS', 'service_manager'):
            tag_args = scp.get('PLUGINS', 'service_manager')
            parts = tag_args.split(':')
            tag = parts[0]
            args = ':'.join(parts[1:])
            factory = txcas.settings.get_plugin_factory(tag, IServiceManagerFactory)
            if factory is None:
                sys.stderr.write("[ERROR] Service manager type '%s' is not available.\n" % tag)
                sys.exit(1)
            service_manager = factory.generateServiceManager(args)
        # Choose plugin that implements ITicketStore.
        tag_args = scp.get('PLUGINS', 'ticket_store')
        parts = tag_args.split(':')
        tag = parts[0]
        args = ':'.join(parts[1:])
        factory = txcas.settings.get_plugin_factory(tag, ITicketStoreFactory)
        if factory is None:
            sys.stderr.write("[ERROR] Ticket store type '%s' is not available.\n" % tag)
            sys.exit(1)
        ticket_store = factory.generateTicketStore(args)
        if service_manager is not None:
            ticket_store.service_manager = service_manager
        # Choose the plugin that implements IRealm.
        tag_args = scp.get('PLUGINS', 'realm')
        parts = tag_args.split(':')
        tag = parts[0]
        args = ':'.join(parts[1:])

# Path: txcas/constants.py
# VIEW_LOGIN = 0
# 
# VIEW_LOGIN_SUCCESS = 1
# 
# VIEW_LOGOUT = 2
# 
# VIEW_INVALID_SERVICE = 3
# 
# VIEW_ERROR_5XX = 4
# 
# VIEW_NOT_FOUND = 5
# 
# Path: txcas/interface.py
# class IRealmFactory(Interface):
# 
#     tag = Attribute('String used to identify the plugin factory.')
#     opt_help = Attribute('String description of the plugin.')
#     opt_usage = Attribute('String describes how to provide arguments for factory.')
# 
#     def generateRealm(argstring=""):
#         """
#         Create an object that implements IRealm.
#         """
# 
# class IServiceManagerFactory(Interface):
# 
#     tag = Attribute('String used to identify the plugin factory.')
#     opt_help = Attribute('String description of the plugin.')
#     opt_usage = Attribute('String describes how to provide arguments for factory.')
# 
#     def generateServiceManager(argstring=""):
#         """
#         Create an object that implements txcas.IServiceManager
#         """
# 
# class ITicketStoreFactory(Interface):
# 
#     tag = Attribute('String used to identify the plugin factory.')
#     opt_help = Attribute('String description of the plugin.')
#     opt_usage = Attribute('String describes how to provide arguments for factory.')
# 
#     def generateTicketStore(argstring=""):
#         """
#         Create an object that implements ITicketStore.
#         """
# 
# Path: txcas/server.py
# def escape_html(text):
#     """Produce entities within text."""
#     return "".join(html_escape_table.get(c,c) for c in text)


# Path: sample.py
import argparse
import cgi
import sys
import txcas.settings
    import sys
from textwrap import dedent
from urllib import urlencode
from txcas.constants import (
    VIEW_LOGIN, 
    VIEW_LOGIN_SUCCESS, 
    VIEW_LOGOUT, 
    VIEW_INVALID_SERVICE,
    VIEW_ERROR_5XX,
    VIEW_NOT_FOUND)
from txcas.interface import (
    IRealmFactory,
    IServiceManagerFactory,
    ITicketStoreFactory)
from txcas.server import escape_html
from klein import Klein
from twisted.python import log
from twisted.web import microdom
from twisted.web.client import getPage
        from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse
        from twisted.cred.strcred import ICheckerFactory
        from txcas.server import ServerApp
    from twisted.web.resource import Resource
    from twisted.web.server import Site
    from twisted.internet import reactor
    from twisted.python import log

                    'ticket_store': 'memory_ticket_store',}})
        # Choose plugin that implements IServiceManager.
        service_manager = None
        if scp.has_option('PLUGINS', 'service_manager'):
            tag_args = scp.get('PLUGINS', 'service_manager')
            parts = tag_args.split(':')
            tag = parts[0]
            args = ':'.join(parts[1:])
            factory = txcas.settings.get_plugin_factory(tag, IServiceManagerFactory)
            if factory is None:
                sys.stderr.write("[ERROR] Service manager type '%s' is not available.\n" % tag)
                sys.exit(1)
            service_manager = factory.generateServiceManager(args)
        # Choose plugin that implements ITicketStore.
        tag_args = scp.get('PLUGINS', 'ticket_store')
        parts = tag_args.split(':')
        tag = parts[0]
        args = ':'.join(parts[1:])
        factory = txcas.settings.get_plugin_factory(tag, ITicketStoreFactory)
        if factory is None:
            sys.stderr.write("[ERROR] Ticket store type '%s' is not available.\n" % tag)
            sys.exit(1)
        ticket_store = factory.generateTicketStore(args)
        if service_manager is not None:
            ticket_store.service_manager = service_manager
        # Choose the plugin that implements IRealm.
        tag_args = scp.get('PLUGINS', 'realm')
        parts = tag_args.split(':')
        tag = parts[0]
        args = ':'.join(parts[1:])

        factory = txcas.settings.get_plugin_factory(tag, IRealmFactory)