Package org.springframework.security.acls.model

Examples of org.springframework.security.acls.model.Permission


        String[] users = {"bill", "bob", "jane"}; // don't want to mess around with consistent sample data
        Permission[] permissions = {BasePermission.ADMINISTRATION, BasePermission.READ, BasePermission.DELETE};

        for (int i = 10; i < createEntities; i++) {
            String user = users[rnd.nextInt(users.length)];
            Permission permission = permissions[rnd.nextInt(permissions.length)];
            grantPermissions(i, user, permission);

            String user2 = users[rnd.nextInt(users.length)];
            Permission permission2 = permissions[rnd.nextInt(permissions.length)];
            grantPermissions(i, user2, permission2);
        }

        SecurityContextHolder.clearContext();
    }
View Full Code Here


        if (!(arg0 instanceof Permission)) {
            return false;
        }

        Permission rhs = (Permission) arg0;

        return (this.mask == rhs.getMask());
    }
View Full Code Here

     */
    @Override
    public List<Permission> buildFromNames(List<String> names) {
        List<Permission> resultingPermissions = new ArrayList<>();
        for (String name : names) {
            Permission permission = pluginPermissionManager.findPluginsBranchPermissionByName(name);
            if (permission != null) {
                resultingPermissions.add(permission);
            }
        }
        return resultingPermissions;
View Full Code Here

        initMocks(this);
    }

    @Test
    public void buildFromMaskShouldReturnPermissionFromCommons() {
        Permission targetPermission = BranchPermission.VIEW_TOPICS;
        when(jtalksPermissionFactory.buildFromMask(targetPermission.getMask())).thenReturn(targetPermission);

        JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory);
        Permission result = permissionFactory.buildFromMask(targetPermission.getMask());

        assertEquals(result, targetPermission);
        verify(pluginsPermissionFactory, never()).buildFromMask(anyInt());
    }
View Full Code Here

        verify(pluginsPermissionFactory, never()).buildFromMask(anyInt());
    }

    @Test
    public void buildFromMaskShouldReturnPluginPermissionWhenCommonNotFound() {
        Permission targetPermission = BranchPermission.VIEW_TOPICS;
        when(jtalksPermissionFactory.buildFromMask(anyInt())).thenReturn(null);
        when(pluginsPermissionFactory.buildFromMask(targetPermission.getMask())).thenReturn(targetPermission);

        JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory);
        Permission result = permissionFactory.buildFromMask(targetPermission.getMask());

        assertEquals(result, targetPermission);
        verify(jtalksPermissionFactory).buildFromMask(targetPermission.getMask());
    }
View Full Code Here

        verify(jtalksPermissionFactory).buildFromMask(targetPermission.getMask());
    }

    @Test
    public void buildFromMaskShouldReturnAnyNotNullDefaultValueWhenNoPermissionFound() {
        Permission targetPermission = BranchPermission.VIEW_TOPICS;
        when(jtalksPermissionFactory.buildFromMask(anyInt())).thenReturn(null);
        when(pluginsPermissionFactory.buildFromMask(anyInt())).thenReturn(null);

        JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory);
        Permission result = permissionFactory.buildFromMask(targetPermission.getMask());

        assertNotNull(result);
        verify(jtalksPermissionFactory).buildFromMask(targetPermission.getMask());
        verify(pluginsPermissionFactory).buildFromMask(targetPermission.getMask());
    }
View Full Code Here

    public void buildFromNameShouldReturnPermissionFromCommons() {
        JtalksPermission targetPermission = BranchPermission.VIEW_TOPICS;
        when(jtalksPermissionFactory.buildFromName(targetPermission.getName())).thenReturn(targetPermission);

        JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory);
        Permission result = permissionFactory.buildFromName(targetPermission.getName());

        assertEquals(result, targetPermission);
        verify(pluginsPermissionFactory, never()).buildFromName(anyString());
    }
View Full Code Here

        JtalksPermission targetPermission = BranchPermission.VIEW_TOPICS;
        when(jtalksPermissionFactory.buildFromName(anyString())).thenReturn(null);
        when(pluginsPermissionFactory.buildFromName(targetPermission.getName())).thenReturn(targetPermission);

        JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory);
        Permission result = permissionFactory.buildFromName(targetPermission.getName());

        assertEquals(result, targetPermission);
        verify(jtalksPermissionFactory).buildFromName(targetPermission.getName());
    }
View Full Code Here

        JtalksPermission targetPermission = BranchPermission.VIEW_TOPICS;
        when(jtalksPermissionFactory.buildFromName(anyString())).thenReturn(null);
        when(pluginsPermissionFactory.buildFromName(anyString())).thenReturn(null);

        JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory);
        Permission result = permissionFactory.buildFromName(targetPermission.getName());

        assertNotNull(result);
        verify(jtalksPermissionFactory).buildFromName(targetPermission.getName());
        verify(pluginsPermissionFactory).buildFromName(targetPermission.getName());
    }
View Full Code Here

     * @return permission with specified mask if it exist
     *         <b>NULL_PERMISSION</b> otherwise
     */
    @Override
    public Permission buildFromMask(int mask) {
        Permission permission = jtalksPermissionFactory.buildFromMask(mask);
        if (permission == null) {
            permission = pluginPermissionFactory.buildFromMask(mask);
        }
        if (permission == null) {
            permission = NullPermission.NULL_PERMISSION;
View Full Code Here

TOP

Related Classes of org.springframework.security.acls.model.Permission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.