source: fedd/federation/deter_impl.py @ 9c2e4e1

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

Protogeni install

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