# Path: txcas/interface.py
# class ICASAuthWhen(Interface):
# 
#     auth_when = Attribute("One of 'cred_acceptor', 'cred_requestor'.")


import functools
import string
import sys
import txcas.settings
import txcas.utils
from textwrap import dedent
from txcas.interface import ICASAuthWhen
from twisted.cred.checkers import ICredentialsChecker
from twisted.cred import credentials
from twisted.cred.error import UnauthorizedLogin
from twisted.cred.strcred import ICheckerFactory
from twisted.internet import defer
from twisted.internet.interfaces import ISSLTransport
from twisted import plugin
from zope.interface import implements
            buf.append(" - %s: %s" % (k, v))
        sys.stderr.write('\n'.join(buf))
        sys.stderr.write('\n')

        transform_s = plugin_settings.get('transform', None)
        if transform_s is not None:
            xforms = transform_s.split(',')
            funcs = []
            for xform in xforms:
                if xform == 'upper':
                    funcs.append(string.upper)
                elif xform == 'lower':
                    funcs.append(string.lower)
                elif xform == 'strip_domain':
                    funcs.append(strip_domain)
                else:
                    sys.stderr.write("Unknown transformation '%s'.\n" % xform)
                    sys.exit(1)
            transform = compose(*funcs)
            plugin_settings['transform'] = transform
        auth_when = plugin_settings.get('auth_when', 'cred_requestor')
        if auth_when not in ('cred_acceptor', 'cred_requestor'):
            sys.stderr.write(
                ("Unknown auth_when '%s'.  Must be 'cred_acceptor' or"
                " 'cred_requestor'.\n") % auth_when)
            sys.exit(1)
        return ClientCertificateChecker(**plugin_settings)

class ClientCertificateChecker(object):


# Path: txcas/interface.py
# class ICASAuthWhen(Interface):
# 
#     auth_when = Attribute("One of 'cred_acceptor', 'cred_requestor'.")


# Path: txcas/client_cert_checker.py
import functools
import string
import sys
import txcas.settings
import txcas.utils
from textwrap import dedent
from txcas.interface import ICASAuthWhen
from twisted.cred.checkers import ICredentialsChecker
from twisted.cred import credentials
from twisted.cred.error import UnauthorizedLogin
from twisted.cred.strcred import ICheckerFactory
from twisted.internet import defer
from twisted.internet.interfaces import ISSLTransport
from twisted import plugin
from zope.interface import implements

            buf.append(" - %s: %s" % (k, v))
        sys.stderr.write('\n'.join(buf))
        sys.stderr.write('\n')

        transform_s = plugin_settings.get('transform', None)
        if transform_s is not None:
            xforms = transform_s.split(',')
            funcs = []
            for xform in xforms:
                if xform == 'upper':
                    funcs.append(string.upper)
                elif xform == 'lower':
                    funcs.append(string.lower)
                elif xform == 'strip_domain':
                    funcs.append(strip_domain)
                else:
                    sys.stderr.write("Unknown transformation '%s'.\n" % xform)
                    sys.exit(1)
            transform = compose(*funcs)
            plugin_settings['transform'] = transform
        auth_when = plugin_settings.get('auth_when', 'cred_requestor')
        if auth_when not in ('cred_acceptor', 'cred_requestor'):
            sys.stderr.write(
                ("Unknown auth_when '%s'.  Must be 'cred_acceptor' or"
                " 'cred_requestor'.\n") % auth_when)
            sys.exit(1)
        return ClientCertificateChecker(**plugin_settings)

class ClientCertificateChecker(object):


    implements(ICredentialsChecker, ICASAuthWhen)