Package org.springframework.security.core.authority

Examples of org.springframework.security.core.authority.SimpleGrantedAuthority


    }

    // -------------------
    @Test
    public void testHasPermission_3args_administer_hasAdminRole() {
        grantedAuthoritiesList.add(new SimpleGrantedAuthority(AuthenticationUtils.ROLE_ADMIN));
        EasyMock.<Collection<? extends GrantedAuthority>>expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthoritiesList);
        replay(mockAuthentication);
        assertThat(defaultWidgetRatingPermissionEvaluator.hasPermission(mockAuthentication, widgetRating, ModelPermissionEvaluator.Permission.ADMINISTER), is(true));
        verify(mockAuthentication);
    }
View Full Code Here


    @Before
    public void setupSecurity() {
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        for (Entitlement entitlement : entitlementDAO.findAll()) {
            authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
        }

        UserDetails userDetails = new User(adminUser, "FAKE_PASSWORD", true, true, true, true, authorities);
        Authentication authentication = new TestingAuthenticationToken(userDetails, "FAKE_PASSWORD", authorities);
        SecurityContextHolder.getContext().setAuthentication(authentication);
View Full Code Here

    }

    @Test
    public void testGetAuthenticatedUser() throws Exception {
        List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
        grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_USER"));
        UserDetails userDetails = new UserImpl("1", "canonical");
        Authentication authentication = new TestingAuthenticationToken(userDetails, "canonical", grantedAuthorities);
        SecurityContextHolder.getContext().setAuthentication(authentication);

        User returnedUser = userService.getAuthenticatedUser();
View Full Code Here

        user2.setUsername(VALID_USERNAME2);
        user2.setId(INVALID_USER_ID);
        widgetComment = new WidgetCommentImpl(VALID_COMMENT_ID);
        widgetComment.setUserId(VALID_USER_ID);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new SimpleGrantedAuthority("ROLE_USER"));
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void verifyAdministrator() {
        List<GrantedAuthority> myGrantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        myGrantedAuthoritiesList.addAll(grantedAuthoritiesList);
        myGrantedAuthoritiesList.add(new SimpleGrantedAuthority(AuthenticationUtils.ROLE_ADMIN));


        expect((List<GrantedAuthority>) mockAuthentication.getAuthorities()).andReturn(myGrantedAuthoritiesList);
        replay(mockAuthentication);
View Full Code Here

        category = new CategoryImpl();
        category.setId(VALID_WIDGET_CATEGORY_ID);
        category.setCreatedUserId(VALID_USER_ID);

        grantedAuthorities = new ArrayList<GrantedAuthority>();
        grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_USER"));
    }
View Full Code Here

        verify(mockAuthentication);
    }

    @Test
    public void testHasPermission_3args_administer_hasAdminRole() {
        grantedAuthorities.add(new SimpleGrantedAuthority(AuthenticationUtils.ROLE_ADMIN));
        EasyMock.<Collection<? extends GrantedAuthority>>expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthorities);
        replay(mockAuthentication);
        assertThat(defaultCategoryPermissionEvaluator.hasPermission(mockAuthentication, category, ModelPermissionEvaluator.Permission.ADMINISTER), is(true));
        verify(mockAuthentication);
    }
View Full Code Here

        verify(mockCategoryRepository);
    }

    @Test
    public void testHasPermission_3args_create_hasAdminRole() {
        grantedAuthorities.add(new SimpleGrantedAuthority(AuthenticationUtils.ROLE_ADMIN));
        EasyMock.<Collection<? extends GrantedAuthority>>expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthorities);
        replay(mockAuthentication, mockCategoryRepository);
        assertThat(defaultCategoryPermissionEvaluator.hasPermission(mockAuthentication, category, ModelPermissionEvaluator.Permission.CREATE), is(true));
        verify(mockAuthentication, mockCategoryRepository);
    }
View Full Code Here

        verify(mockAuthentication, mockCategoryRepository);
    }

    @Test
    public void testHasPermission_3args_delete_hasAdminRole() {
        grantedAuthorities.add(new SimpleGrantedAuthority(AuthenticationUtils.ROLE_ADMIN));
        EasyMock.<Collection<? extends GrantedAuthority>>expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthorities);
        replay(mockAuthentication, mockCategoryRepository);
        assertThat(defaultCategoryPermissionEvaluator.hasPermission(mockAuthentication, category, ModelPermissionEvaluator.Permission.DELETE), is(true));
        verify(mockAuthentication, mockCategoryRepository);
    }
View Full Code Here

        verify(mockAuthentication, mockCategoryRepository);
    }

    @Test
    public void testHasPermission_3args_update_hasAdminRole() {
        grantedAuthorities.add(new SimpleGrantedAuthority(AuthenticationUtils.ROLE_ADMIN));
        EasyMock.<Collection<? extends GrantedAuthority>>expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthorities);
        replay(mockAuthentication, mockCategoryRepository);
        assertThat(defaultCategoryPermissionEvaluator.hasPermission(mockAuthentication, category, ModelPermissionEvaluator.Permission.UPDATE), is(true));
        verify(mockAuthentication, mockCategoryRepository);
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.authority.SimpleGrantedAuthority

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.