Package org.springframework.security.core.authority

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



    @Test
    public void testIsAdmin_validAdmin() {
        List<GrantedAuthority> grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl(AuthenticationUtils.ROLE_ADMIN));
               
        expect(authentication.getAuthorities()).andReturn(grantedAuthoritiesList);
        replay(authentication);
       
        assertThat(AuthenticationUtils.isAdmin(authentication), is(true));
View Full Code Here


    }
   
    @Test
    public void testIsAdmin_notValidAdmin() {
        List<GrantedAuthority> grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl(VALID_ROLE));
               
        expect(authentication.getAuthorities()).andReturn(grantedAuthoritiesList);
        replay(authentication);
       
        assertThat(AuthenticationUtils.isAdmin(authentication), is(false));
View Full Code Here

        user2.setEntityId(INVALID_USER_ID);
        widgetComment = new WidgetComment();
        widgetComment.setEntityId(VALID_COMMENT_ID);
        widgetComment.setUser(user);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl("ROLE_USER"));
    }
View Full Code Here

   
    @Test
    public void verifyAdministrator() {
        List myGrantedAuthoritiesList = new ArrayList();
        myGrantedAuthoritiesList.addAll(grantedAuthoritiesList);
        myGrantedAuthoritiesList.add(new GrantedAuthorityImpl(AuthenticationUtils.ROLE_ADMIN));
       
        expect(mockAuthentication.getAuthorities()).andReturn(myGrantedAuthoritiesList);
        replay(mockAuthentication);
       
        assertThat(defaultWidgetCommentPermissionEvaluator.hasPermission(mockAuthentication, null, Permission.ADMINISTER), is(true));
View Full Code Here

    }

    @Test
    public void testHasPermission_authenticationUserIsAdmin() {       
        List<GrantedAuthority> grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl(AuthenticationUtils.ROLE_ADMIN));
               
        expect(authentication.getAuthorities()).andReturn(grantedAuthoritiesList);
        replay(authentication);
        assertThat(fooModelPermissionEvaluator.hasPermission(authentication, fooModel, Permission.READ), is(true));
        verify(authentication);
View Full Code Here

    }

    @Test
    public void testHasPermission_authenticationUserIsNotAdmin() {       
        List<GrantedAuthority> grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl("ROLE_THAT_IS_NOT_ADMIN"));
               
        expect(authentication.getAuthorities()).andReturn(grantedAuthoritiesList);
        replay(authentication);
        assertThat(fooModelPermissionEvaluator.hasPermission(authentication, fooModel, Permission.READ), is(false));
        verify(authentication);
View Full Code Here

        user2.setUsername(VALID_USERNAME2);
        page = new Page();
        page.setEntityId(VALID_PAGE_ID);
        page.setOwner(user);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl("ROLE_USER"));
    }
View Full Code Here

        verify(mockAuthentication);
    }
   
    @Test
    public void testHasPermission_3args_administer_hasAdminRole() {                            
        grantedAuthoritiesList.add(new GrantedAuthorityImpl(AuthenticationUtils.ROLE_ADMIN));
       
        expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthoritiesList);
        replay(mockAuthentication);             
        assertThat(defaultPagePermissionEvaluator.hasPermission(mockAuthentication, page, Permission.ADMINISTER), is(true));       
        verify(mockAuthentication);
View Full Code Here

        widget = new Widget();
        widget.setEntityId(VALID_REGION_ID);
        widget.setOwner(user);
        widget.setWidgetStatus(WidgetStatus.PUBLISHED);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl("ROLE_USER"));
    }
View Full Code Here

        verify(mockAuthentication);
    }

    @Test
    public void testHasPermission_3args_administer_hasAdminRole() {
        grantedAuthoritiesList.add(new GrantedAuthorityImpl(AuthenticationUtils.ROLE_ADMIN));
        expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthoritiesList);
        replay(mockAuthentication);
        assertThat(defaultWidgetPermissionEvaluator.hasPermission(mockAuthentication, widget, ModelPermissionEvaluator.Permission.ADMINISTER), is(true));
        verify(mockAuthentication);
    }
View Full Code Here

TOP

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

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.