Package archipelcore :: Module archipelPermissionCenter :: Class TNArchipelPermissionCenter
[hide private]
[frames] | no frames]

Class TNArchipelPermissionCenter

source code

Instance Methods [hide private]
 
__init__(self, database_file=None, root_admins={})
Initialize the permission center.
source code
 
start(self, database_file=None, root_admins={})
Start the connection and be ready to use permissions
source code
Session
create_session(self)
Create a new SQL session
source code
 
add_admin(self, key, new_account)
Add a new admin account in the list
source code
 
del_admin(self, key)
Remove the admin account associated to the key
source code
List
admins(self)
Returns the list of admins accounts
source code
Boolean
create_permission(self, name, description='', default_permission=False, currentsession=None)
Create a new permission.
source code
TNArchipelPermission
get_permission(self, name, currentsession=None)
Get the permission by name.
source code
Boolean
delete_permission(self, name, currentsession=None)
Delete the permission by name.
source code
 
get_permissions(self, currentsession=None)
Return all permissions.
source code
Boolean
create_user(self, name, currentsession=None)
Create a new user.
source code
TNArchipelUser
get_user(self, name, currentsession=None)
Get the user by name.
source code
Boolean
delete_user(self, name, currentsession=None)
Delete the user by name.
source code
Boolean
grant_permission_to_user(self, permission_name, user_name, currentsession=None)
Grant given permission to given user.
source code
Boolean
revoke_permission_to_user(self, permission_name, user_name, currentsession=None)
Revoke given permission to given user.
source code
Boolean
user_has_permission(self, user_name, permission_name, currentsession=None)
Check if user has permission.
source code
list of TNArchipelPermission
get_user_permissions(self, user_name, currentsession=None)
Get permissions of user.
source code
Boolean
check_permission(self, user_name, permission_name)
Check if given user has given permission.
source code
Boolean
check_permissions(self, user_name, permissions)
Check if all permissions on array are granted.
source code
 
close_database(self)
Close the db connection.
source code
Method Details [hide private]

__init__(self, database_file=None, root_admins={})
(Constructor)

source code 

Initialize the permission center.

Parameters:
  • database_file (string) - the path to the db file
  • root_admins (array) - the root users JID

create_session(self)

source code 

Create a new SQL session

Returns: Session
the new session

add_admin(self, key, new_account)

source code 

Add a new admin account in the list

Parameters:
  • key (string) - unique id
  • new_account (String) - the JID of the new admin account

del_admin(self, key)

source code 

Remove the admin account associated to the key

Parameters:
  • ket (string) - the key

admins(self)

source code 

Returns the list of admins accounts

Returns: List
list of admin accounts

create_permission(self, name, description='', default_permission=False, currentsession=None)

source code 

Create a new permission.

Parameters:
  • name (string) - the name of the permission
  • description (string) - the description of the permission
  • default_permission (Boolean) - the default value of permission if not set
Returns: Boolean
True in case of success

get_permission(self, name, currentsession=None)

source code 

Get the permission by name.

Parameters:
  • name (string) - the name of the permission
Returns: TNArchipelPermission
the TNArchipelPermission object or None

delete_permission(self, name, currentsession=None)

source code 

Delete the permission by name.

Parameters:
  • name (string) - the name of the permission
Returns: Boolean
True in case of success

create_user(self, name, currentsession=None)

source code 

Create a new user.

Parameters:
  • name (string) - the name of the user
Returns: Boolean
True in case of success

get_user(self, name, currentsession=None)

source code 

Get the user by name.

Parameters:
  • name (string) - the name of the user
Returns: TNArchipelUser
the TNArchipelUser object or None

delete_user(self, name, currentsession=None)

source code 

Delete the user by name.

Parameters:
  • name (string) - the name of the user
Returns: Boolean
True in case of success

grant_permission_to_user(self, permission_name, user_name, currentsession=None)

source code 

Grant given permission to given user.

Parameters:
  • permission_name (string) - the name of the permission
  • user_name (string) - the name of the user
Returns: Boolean
True in case of success

revoke_permission_to_user(self, permission_name, user_name, currentsession=None)

source code 

Revoke given permission to given user.

Parameters:
  • permission_name (string) - the name of the permission
  • user_name (string) - the name of the user
Returns: Boolean
True in case of success

user_has_permission(self, user_name, permission_name, currentsession=None)

source code 

Check if user has permission.

Parameters:
  • user_name (string) - the name of the user
  • permission_name (string) - the name of the permission
Returns: Boolean
True in case of success

get_user_permissions(self, user_name, currentsession=None)

source code 

Get permissions of user.

Parameters:
  • user_name (string) - the name of the user
Returns: list of TNArchipelPermission
the list TNArchipelPermission of user or None

check_permission(self, user_name, permission_name)

source code 

Check if given user has given permission.

Parameters:
  • user_name (string) - the name of the user
  • permission_name (string) - the name of the permission
Returns: Boolean
True in case of success

check_permissions(self, user_name, permissions)

source code 

Check if all permissions on array are granted.

Parameters:
  • user_name (string) - the name of the user
  • permissions (array of string) - list permissions names
Returns: Boolean
True in case of success