1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 import MaKaC
.webinterface
.rh
.admins
as admins
18 import MaKaC
.webinterface
.urlHandlers
as urlHandlers
19 from MaKaC
.common
import utils
20 from MaKaC
.common
import info
21 from MaKaC
.webinterface
.pages
import admins
as adminPages
22 from MaKaC
.errors
import MaKaCError
25 class RHServicesBase(admins
.RHAdminBase
):
29 class RHIPBasedACL( RHServicesBase
):
30 """ IP Based ACL Configuration Interface """
32 _uh
= urlHandlers
.UHIPBasedACL
35 p
= adminPages
.WPIPBasedACL(self
)
38 class RHIPBasedACLFullAccessGrant( RHServicesBase
):
40 _uh
= urlHandlers
.UHIPBasedACLFullAccessGrant
42 def _checkParams( self
, params
):
43 RHServicesBase
._checkParams
( self
, params
)
48 ipAddress
= self
._params
.get('ipAddress', None)
51 if not utils
.validIP(ipAddress
):
52 raise MaKaCError("IP Address %s is not valid!" % ipAddress
)
54 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
55 ip_acl_mgr
= minfo
.getIPBasedACLMgr()
56 ip_acl_mgr
.grant_full_access(ipAddress
)
58 self
._redirect
(urlHandlers
.UHIPBasedACL
.getURL())
60 class RHIPBasedACLFullAccessRevoke( RHServicesBase
):
62 _uh
= urlHandlers
.UHIPBasedACLFullAccessRevoke
64 def _checkParams( self
, params
):
65 RHServicesBase
._checkParams
( self
, params
)
70 ipAddress
= self
._params
.get('ipAddress', None)
73 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
74 ip_acl_mgr
= minfo
.getIPBasedACLMgr()
75 ip_acl_mgr
.revoke_full_access(ipAddress
)
77 self
._redirect
(urlHandlers
.UHIPBasedACL
.getURL())