Exemple #1
0
    def __init__(self, **traits):
        """Initialise the object."""

        super(_ChangePasswordAction, self).__init__(**traits)

        get_permissions_manager().user_manager.on_trait_event(
            self._refresh_enabled, 'user_authenticated')
Exemple #2
0
    def authenticate_user(self):
        """Authenticate the user."""

        if self.user_db.authenticate_user(self.user):
            self.user.authenticated = True

            # Tell the policy manager before everybody else.
            get_permissions_manager().policy_manager.load_policy(self.user)

            self.user_authenticated = self.user
Exemple #3
0
    def unauthenticate_user(self):
        """Unauthenticate the user."""

        if self.user.authenticated and self.user_db.unauthenticate_user(self.user):
            self.user.authenticated = False

            # Tell the policy manager before everybody else.
            get_permissions_manager().policy_manager.load_policy(None)

            self.user_authenticated = None
Exemple #4
0
    def authenticate_user(self):
        """Authenticate the user."""

        if self.user_db.authenticate_user(self.user):
            self.user.authenticated = True

            # Tell the policy manager before everybody else.
            get_permissions_manager().policy_manager.load_policy(self.user)

            self.user_authenticated = self.user
Exemple #5
0
    def unauthenticate_user(self):
        """Unauthenticate the user."""

        if self.user.authenticated and self.user_db.unauthenticate_user(
                self.user):
            self.user.authenticated = False

            # Tell the policy manager before everybody else.
            get_permissions_manager().policy_manager.load_policy(None)

            self.user_authenticated = None
Exemple #6
0
    def _save_clicked(self, info):
        """Invoked by the "Save" button."""

        assignment = self._validate(info)
        if assignment is None:
            return

        # Update the data in the database.
        try:
            get_permissions_manager().policy_manager.policy_storage.set_assignment(assignment.user_name, [r.name for r in assignment.roles])

            info.ui.dispose()
        except PolicyStorageError, e:
            self._ps_error(e)
Exemple #7
0
    def _add_clicked(self, info):
        """Invoked by the "Add" button."""

        role = self._validate(info)
        if role is None:
            return

        # Add the data to the database.
        try:
            get_permissions_manager().policy_manager.policy_storage.add_role(
                    role.name, role.description,
                    [p.id for p in role.permissions])
            info.ui.dispose()
        except PolicyStorageError, e:
            self._ps_error(e)
Exemple #8
0
    def _delete_clicked(self, info):
        """Invoked by the "Delete" button."""

        role = self._validate(info)
        if role is None:
            return

        if confirm(None, "Are you sure you want to delete the role \"%s\"?" % role.name) == YES:
            # Delete the data from the database.
            try:
                get_permissions_manager().policy_manager.policy_storage.delete_role(role.name)

                info.ui.dispose()
            except PolicyStorageError, e:
                self._ps_error(e)
Exemple #9
0
    def _search_clicked(self, info):
        """Invoked by the "Search" button."""

        role = self._role(info)

        # Get all roles that satisfy the criteria.
        try:
            roles = get_permissions_manager().policy_manager.policy_storage.matching_roles(role.name)
        except PolicyStorageError, e:
            self._ps_error(e)
            return
Exemple #10
0
def role_assignment():
    """Implement the role assignment for the current policy manager."""

    # Create a dictionary of roles keyed by the role name.
    all_roles = {}

    try:
        roles = get_permissions_manager().policy_manager.policy_storage.all_roles()
    except PolicyStorageError, e:
        error(None, str(e))
        return
Exemple #11
0
    def _search_clicked(self, info):
        """Invoked by the "Search" button."""

        pm = get_permissions_manager()
        assignment = self._assignment(info)

        user = pm.user_manager.matching_user(assignment.user_name)
        if user is None:
            return

        try:
            user_name, role_names = pm.policy_manager.policy_storage.get_assignment(user.name)
        except PolicyStorageError, e:
            self._ps_error(e)
            return
Exemple #12
0
    def __init__(self, **traits):
        """Initialise the object."""

        buttons = [Action(name="Search"), Action(name="Add"),
                Action(name="Modify"), Action(name="Delete"), CancelButton]

        all_perms = get_permissions_manager().policy_manager.permissions.values()

        perms_editor = SetEditor(values=all_perms,
                left_column_title="Available Permissions",
                right_column_title="Assigned Permissions")

        perms_group = Group(Item(name='permissions', editor=perms_editor),
                label='Permissions', show_border=True, show_labels=False)

        super(_RoleView, self).__init__(Item(name='name'),
                Item(name='description'), perms_group, buttons=buttons,
                **traits)
Exemple #13
0
    def _perms_to_list(self, perm_ids):
        """Return a list of Permission instances created from the given list of
        permission ids."""

        pl = []

        for id in perm_ids:
            try:
                p = get_permissions_manager().policy_manager.permissions[id]
            except KeyError:
                # FIXME: permissions should be populated from the policy
                # database - or is it needed at all?  Should it just be read
                # when managing roles?
                p = Permission(id=id, application_defined=False)

            pl.append(p)

        return pl
    def __init__(self, **traits):
        """Initialise the object."""

        pm = get_permissions_manager()

        # Put them in a group so we can optionally append (because the PyFace
        # API doesn't do what you expect with append()).
        group = Group()

        group.append(LoginAction())

        for act in pm.user_manager.user_actions:
            group.append(act)

        group.append(LogoutAction())

        for act in pm.user_manager.management_actions:
            group.append(act)

        for act in pm.policy_manager.management_actions:
            group.append(act)

        super(UserMenuManager, self).__init__(group, **traits)
Exemple #15
0
    def __init__(self, **traits):
        """Initialise the object."""

        pm = get_permissions_manager()

        # Put them in a group so we can optionally append (because the PyFace
        # API doesn't do what you expect with append()).
        group = Group()

        group.append(LoginAction())

        for act in pm.user_manager.user_actions:
            group.append(act)

        group.append(LogoutAction())

        for act in pm.user_manager.management_actions:
            group.append(act)

        for act in pm.policy_manager.management_actions:
            group.append(act)

        super(UserMenuManager, self).__init__(group, **traits)
Exemple #16
0
    def perform(self, event):
        """Perform the action."""

        get_permissions_manager().user_manager.authenticate_user()
Exemple #17
0
    def perform(self, event):
        """Perform the action."""

        um = get_permissions_manager().user_manager
        um.user_db.change_password(um.user)
Exemple #18
0
    def perform(self, event):
        """Perform the action."""

        um = get_permissions_manager().user_manager
        um.user_db.change_password(um.user)
Exemple #19
0
    def perform(self, event):
        """Perform the action."""

        get_permissions_manager().user_manager.authenticate_user()
Exemple #20
0
    def __init__(self, **traits):
        """Initialise the object."""

        super(LogoutAction, self).__init__(**traits)

        get_permissions_manager().user_manager.on_trait_event(self._refresh_enabled, 'user_authenticated')