Exemplo n.º 1
0
 def generateTicketStore(self, argstring=""):
     scp = txcas.settings.load_settings("cas", syspath="/etc/cas")
     settings = txcas.settings.export_settings_to_dict(scp)
     ts_settings = settings.get("CAS", {})
     temp = settings.get("InMemoryTicketStore", {})
     ts_settings.update(temp)
     del temp
     if argstring.strip() != "":
         argdict = dict((x.split("=") for x in argstring.split(":")))
         ts_settings.update(argdict)
     missing = txcas.utils.get_missing_args(InMemoryTicketStore.__init__, ts_settings, ["self"])
     if len(missing) > 0:
         sys.stderr.write("[ERROR][InMemoryTicketStore] " "Missing the following settings: %s" % ", ".join(missing))
         sys.stderr.write("\n")
         sys.exit(1)
     props = ("lt_lifespan", "st_lifespan", "pt_lifespan", "tgt_lifespan", "pgt_lifespan", "ticket_size")
     ts_props = dict((prop, int(ts_settings[prop])) for prop in props if prop in ts_settings)
     txcas.utils.filter_args(InMemoryTicketStore.__init__, ts_settings, ["self"])
     if "verify_cert" in ts_settings:
         ts_settings["verify_cert"] = bool(int(ts_settings["verify_cert"]))
     obj = InMemoryTicketStore(**ts_settings)
     for prop, value in ts_props.iteritems():
         setattr(obj, prop, value)
     buf = ["[CONFIG][InMemoryTicketStore] Settings:"]
     d = dict(ts_settings)
     d.update(ts_props)
     for k in sorted(d.keys()):
         v = d[k]
         buf.append(" - %s: %s" % (k, v))
     sys.stderr.write("\n".join(buf))
     sys.stderr.write("\n")
     return obj
Exemplo n.º 2
0
    def generateViewProvider(self, argstring=""):
        """
        """
        scp = txcas.settings.load_settings('cas', syspath='/etc/cas')
        settings = txcas.settings.export_settings_to_dict(scp)
        config = settings.get('Jinja2ViewProvider', {})
        if argstring.strip() != "":
            argdict = dict((x.split('=') for x in argstring.split(':')))
            config.update(argdict)
        missing = txcas.utils.get_missing_args(
                    Jinja2ViewProvider.__init__, config, ['self'])
        if len(missing) > 0:
            sys.stderr.write(
                "[ERROR][Jinja2ViewProvider] "
                "Missing the following settings: %s" % ', '.join(missing))
            sys.stderr.write('\n')
            sys.exit(1)

        txcas.utils.filter_args(Jinja2ViewProvider.__init__, config, ['self'])
        buf = ["[CONFIG][Jinja2ViewProvider] Settings:"]
        for k in sorted(config.keys()):
            v = config[k]
            buf.append(" - %s: %s" % (k, v))
        sys.stderr.write('\n'.join(buf))
        sys.stderr.write('\n')
        return Jinja2ViewProvider(**config)
Exemplo n.º 3
0
    def generateViewProvider(self, argstring=""):
        """
        """
        scp = txcas.settings.load_settings('cas', syspath='/etc/cas')
        settings = txcas.settings.export_settings_to_dict(scp)
        config = settings.get('Jinja2ViewProvider', {})
        if argstring.strip() != "":
            argdict = dict((x.split('=') for x in argstring.split(':')))
            config.update(argdict)
        missing = txcas.utils.get_missing_args(Jinja2ViewProvider.__init__,
                                               config, ['self'])
        if len(missing) > 0:
            sys.stderr.write("[ERROR][Jinja2ViewProvider] "
                             "Missing the following settings: %s" %
                             ', '.join(missing))
            sys.stderr.write('\n')
            sys.exit(1)

        txcas.utils.filter_args(Jinja2ViewProvider.__init__, config, ['self'])
        buf = ["[CONFIG][Jinja2ViewProvider] Settings:"]
        for k in sorted(config.keys()):
            v = config[k]
            buf.append(" - %s: %s" % (k, v))
        sys.stderr.write('\n'.join(buf))
        sys.stderr.write('\n')
        return Jinja2ViewProvider(**config)
Exemplo n.º 4
0
 def generateTicketStore(self, argstring=""):
     scp = txcas.settings.load_settings('cas', syspath='/etc/cas')
     settings = txcas.settings.export_settings_to_dict(scp)
     ts_settings = settings.get('CAS', {})    
     temp = settings.get('InMemoryTicketStore', {})    
     ts_settings.update(temp)
     del temp
     if argstring.strip() != "":
         argdict = dict((x.split('=') for x in argstring.split(':')))
         ts_settings.update(argdict)
     missing = txcas.utils.get_missing_args(
                 InMemoryTicketStore.__init__, ts_settings, ['self'])
     if len(missing) > 0:
         sys.stderr.write(
             "[ERROR][InMemoryTicketStore] "
             "Missing the following settings: %s" % ', '.join(missing))
         sys.stderr.write('\n') 
         sys.exit(1)
     props = (
             'lt_lifespan', 'st_lifespan', 'pt_lifespan',
             'tgt_lifespan', 'pgt_lifespan', 'ticket_size')
     ts_props = dict((prop, int(ts_settings[prop])) for prop in props if prop in ts_settings)
     txcas.utils.filter_args(InMemoryTicketStore.__init__, ts_settings, ['self'])
     if 'verify_cert' in ts_settings:
         ts_settings['verify_cert'] = bool(int(ts_settings['verify_cert']))
     obj = InMemoryTicketStore(**ts_settings)
     for prop, value in ts_props.iteritems():
         setattr(obj, prop, value)
     buf = ["[CONFIG][InMemoryTicketStore] Settings:"]
     d = dict(ts_settings)
     d.update(ts_props)
     for k in sorted(d.keys()):
         v = d[k]
         buf.append(" - %s: %s" % (k, v))
     sys.stderr.write('\n'.join(buf)) 
     sys.stderr.write('\n') 
     return obj
Exemplo n.º 5
0
    def generateChecker(self, argstring=""):
        scp = txcas.settings.load_settings('cas', syspath='/etc/cas')
        settings = txcas.settings.export_settings_to_dict(scp)
        plugin_settings = settings.get('ClientCertificateChecker', {})
        if argstring.strip() != "":
            argdict = dict((x.split('=') for x in argstring.split(':')))
            plugin_settings.update(argdict)
        missing = txcas.utils.get_missing_args(
            ClientCertificateChecker.__init__, plugin_settings, ['self'])
        if len(missing) > 0:
            sys.stderr.write("[ERROR][ClientCertificateChecker] "
                             "Missing the following settings: %s" %
                             ', '.join(missing))
            sys.stderr.write('\n')
            sys.exit(1)

        txcas.utils.filter_args(ClientCertificateChecker.__init__,
                                plugin_settings, ['self'])
        buf = ["[CONFIG][ClientCertificateChecker] Settings:"]
        for k in sorted(plugin_settings.keys()):
            v = plugin_settings[k]
            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)
Exemplo n.º 6
0
    def generateChecker(self, argstring=""):
        scp = txcas.settings.load_settings('cas', syspath='/etc/cas')
        settings = txcas.settings.export_settings_to_dict(scp)
        plugin_settings = settings.get('ClientCertificateChecker', {})
        if argstring.strip() != "":
            argdict = dict((x.split('=') for x in argstring.split(':')))
            plugin_settings.update(argdict)
        missing = txcas.utils.get_missing_args(
                    ClientCertificateChecker.__init__, plugin_settings, ['self'])
        if len(missing) > 0:
            sys.stderr.write(
                "[ERROR][ClientCertificateChecker] "
                "Missing the following settings: %s" % ', '.join(missing))
            sys.stderr.write('\n')
            sys.exit(1)

        txcas.utils.filter_args(ClientCertificateChecker.__init__, plugin_settings, ['self'])
        buf = ["[CONFIG][ClientCertificateChecker] Settings:"]
        for k in sorted(plugin_settings.keys()):
            v = plugin_settings[k]
            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)