source: fedd/federation/deter_impl.py @ 7888aee

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 7888aee was 7888aee, checked in by Ted Faber <faber@…>, 14 years ago

Add skeleton plug-in

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[19cc408]1#!/usr/local/bin/python
2
[3c6dbec]3import emulab_access
[23dec62]4import dragon_access
[9c2e4e1]5import protogeni_access
[175b444]6import deter_internal_access
[7888aee]7import skeleton_access
[175b444]8
[ec4fb42]9from experiment_control import experiment_control_local
[5f6929a]10from ns2topdl import ns2topdl_local
[05191a6]11from util import read_simple_accessdb
[73ded03]12from fedid import fedid
[19cc408]13
[73ded03]14from authorizer import authorizer, abac_authorizer
[3f6bc5f]15
[7454054]16class deter_impl:
[19cc408]17    """
18    The implementation of access control based on mapping users to projects.
19
20    Users can be mapped to existing projects or have projects created
21    dynamically.  This implements both direct requests and proxies.
22    """
23    # Used by the SOAP caller
[e77c86e]24    soap_namespaces = ('http://www.isi.edu/fedd.wsdl',
25            'http://www.isi.edu/fedd_internal.wsdl')
[19cc408]26
[72ed6e4]27    def __init__(self, config=None):
[19cc408]28        """
[ec4fb42]29        Initializer.  Uses the parsed configuration to create appropriate
30        components.
[19cc408]31        """
[72ed6e4]32        self.soap_services = { }
33        self.xmlrpc_services = { }
[73ded03]34        self.auth = None
[72ed6e4]35
36        if config:
37            self.cert_file = config.get("globals", "cert_file");
38            self.cert_pwd = config.get("globals", "cert_pwd");
39            self.trusted_certs = config.get("globals", "trusted_certs");
[3c6dbec]40            self.access_type = config.get("globals", "access_type", "emulab")
[73ded03]41            self.auth_type = config.get("globals", "auth_type", "legacy")
42
43            if self.auth_type == 'legacy':
44                self.auth = authorizer()
45            elif self.auth_type == 'abac':
46                auth_url = config.get('globals', 'auth_url')
47                if not auth_url:
48                    raise RuntimeError("auth_url required for ABAC " + \
49                            "authorization")
50                if self.cert_file:
51                    me = fedid(file=self.cert_file)
52                else:
53                    raise RuntimeError("ABAC authorization needs a " +\
54                            "certificate file")
55                self.auth= abac_authorizer(url=auth_url, 
56                        cert_file=self.cert_file, cert_pwd=self.cert_pwd,
57                        trusted_certs=self.trusted_certs, me=me)
58            else:
59                raise RuntimeError("Unknown authorizer type %s" % \
60                        self.auth_type)
[72ed6e4]61
[05191a6]62            access_db = config.get("globals", "accessdb")
63
64            if access_db:
65                try:
66                    read_simple_accessdb(access_db, self.auth)
[d3c8759]67                except EnvironmentError, e:
[0b4e272]68                    raise RuntimeError(
[05191a6]69                            "Error reading accessDB %s: %s" % (access_db, e))
[cc8d8e9]70                except ValueError, e:
[0b4e272]71                    raise RuntimeError("%s" % e)
[05191a6]72
[72ed6e4]73            if config.has_section("access"):
[3c6dbec]74                if self.access_type == "emulab":
75                    self.access = emulab_access.access(config, self.auth)
[23dec62]76                elif self.access_type == "dragon":
77                    self.access = dragon_access.access(config, self.auth)
[9c2e4e1]78                elif self.access_type == "protogeni":
79                    self.access = protogeni_access.access(config, self.auth)
[175b444]80                elif self.access_type == "deter_internal":
81                    self.access = deter_internal_access.access(config,
82                            self.auth)
[7888aee]83                elif self.access_type == "skel":
84                    self.access = skeleton_access.access(config, self.auth)
[3c6dbec]85                else:
86                    raise RuntimeError("Unknown access_type: %s" % \
87                            self.access_type)
[72ed6e4]88                self.soap_services.update(self.access.soap_services) 
89                self.xmlrpc_services.update(self.access.xmlrpc_services) 
[09b4dc4]90            else:
91                self.access = None
[72ed6e4]92
93            if config.has_section("experiment_control"):
[3f6bc5f]94                self.experiment = \
[ec4fb42]95                        experiment_control_local(config, self.auth)
[5fffd82]96                # Tell the experiment control where local access control is and
[5a6b75b]97                # what testbeds it pertains to.
[c9318dc]98                if getattr(self, 'access', None):
[5a6b75b]99                    for t in self.access.testbed:
100                        self.experiment.local_access[t] = self.access
[5fffd82]101
[72ed6e4]102                self.soap_services.update(self.experiment.soap_services) 
103                self.xmlrpc_services.update(self.experiment.xmlrpc_services) 
[81a7f3f]104                self.get_handler = self.experiment.get_handler
105            else:
[39ee3cc]106                if self.access and getattr(self.access, 'get_handler', None):
[dac2316]107                    self.get_handler = self.access.get_handler
108                else:
109                    self.get_handler = None
[72ed6e4]110
[5f6929a]111            if config.has_section("ns2topdl"):
112                self.ns2topdl = ns2topdl_local(config, self.auth)
113                self.soap_services.update(self.ns2topdl.soap_services) 
114                self.xmlrpc_services.update(self.ns2topdl.xmlrpc_services) 
[f4f4117]115
[72ed6e4]116def new_feddservice(config):
[7454054]117    return deter_impl(config)
Note: See TracBrowser for help on using the repository browser.