Exemplo n.º 1
0
    def is_empty(self):
        """See if the database is empty."""

        try:
            return ProxyServer.is_empty_policy()
        except Exception, e:
            raise PolicyStorageError(ProxyServer.error(e))
Exemplo n.º 2
0
    def get_assignment(self, user_name):
        """Return the details of the assignment for the given user name."""

        try:
            return ProxyServer.get_assignment(user_name, ProxyServer.key)
        except Exception, e:
            raise PolicyStorageError(ProxyServer.error(e))
Exemplo n.º 3
0
    def delete_role(self, name):
        """Delete a role."""

        try:
            ProxyServer.delete_role(name, ProxyServer.key)
        except Exception, e:
            raise PolicyStorageError(ProxyServer.error(e))
Exemplo n.º 4
0
    def all_roles(self):
        """Return a list of all roles."""

        try:
            return ProxyServer.all_roles(ProxyServer.key)
        except Exception, e:
            raise PolicyStorageError(ProxyServer.error(e))
Exemplo n.º 5
0
    def add_role(self, name, description, perm_ids):
        """Add a new role."""

        try:
            ProxyServer.add_role(name, description, perm_ids, ProxyServer.key)
        except Exception, e:
            raise PolicyStorageError(ProxyServer.error(e))
Exemplo n.º 6
0
    def set_assignment(self, user_name, role_names):
        """Save the roles assigned to a user."""

        try:
            ProxyServer.set_assignment(user_name, role_names, ProxyServer.key)
        except Exception, e:
            raise PolicyStorageError(ProxyServer.error(e))
Exemplo n.º 7
0
    def matching_roles(self, name):
        """Return the full name, description and permissions of all the roles
        that match the given name."""

        try:
            return ProxyServer.matching_roles(name, ProxyServer.key)
        except Exception, e:
            raise PolicyStorageError(ProxyServer.error(e))
Exemplo n.º 8
0
    def modify_role(self, name, description, perm_ids):
        """Update the description and permissions for the given role."""

        try:
            ProxyServer.modify_role(name, description, perm_ids,
                    ProxyServer.key)
        except Exception, e:
            raise PolicyStorageError(ProxyServer.error(e))
Exemplo n.º 9
0
    def get_policy(self, name):
        """Return the details of the policy for the given user name."""

        description, blob, perm_ids = ProxyServer.cache

        if ProxyServer.key is not None:
            try:
                name, perm_ids = ProxyServer.get_policy(name, ProxyServer.key)
            except Exception, e:
                raise PolicyStorageError(ProxyServer.error(e))

            # Save the permissions ids in the persistent cache.
            ProxyServer.cache = description, blob, perm_ids

            try:
                ProxyServer.write_cache()
            except:
                pass