Launchpad automatic translations update.
[odoo/odoo.git] / addons / document_ftp / ftpserver / authorizer.py
1 # -*- encoding: utf-8 -*-
2
3 class authorizer:
4     read_perms = "elr"
5     write_perms = "adfmw"
6
7     def __init__(self):
8         self.password = ''
9
10     def validate_authentication(self, username, password):
11         """Return True if the supplied username and password match the
12         stored credentials."""
13         self.password = password
14         return True
15
16     def impersonate_user(self, username, password):
17         """Impersonate another user (noop).
18
19         It is always called before accessing the filesystem.
20         By default it does nothing.  The subclass overriding this
21         method is expected to provide a mechanism to change the
22         current user.
23         """
24
25     def terminate_impersonation(self):
26         """Terminate impersonation (noop).
27
28         It is always called after having accessed the filesystem.
29         By default it does nothing.  The subclass overriding this
30         method is expected to provide a mechanism to switch back
31         to the original user.
32         """
33
34     def has_user(self, username):
35         """Whether the username exists in the virtual users table."""
36         if username=='anonymous':
37             return False
38         return True
39
40     def has_perm(self, username, perm, path=None):
41         """Whether the user has permission over path (an absolute
42         pathname of a file or a directory).
43
44         Expected perm argument is one of the following letters:
45         "elradfmw".
46         """
47         paths = path.split('/')
48         if not len(paths)>2:
49             return True
50         db_name = paths[1]
51         db,pool = pooler.get_db_and_pool(db_name)
52         res = security.login(db_name, username, self.password)
53         return bool(res)
54
55     def get_perms(self, username):
56         """Return current user permissions."""
57         return 'elr'
58
59     def get_home_dir(self, username):
60         """Return the user's home directory."""
61         return '/'
62
63     def get_msg_login(self, username):
64         """Return the user's login message."""
65         return 'Welcome on OpenERP document management system.'
66
67     def get_msg_quit(self, username):
68         """Return the user's quitting message."""
69         return 'Bye.'
70
71 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: