Package org.springframework.security.core.authority

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


        page.setOwner(user);
        region = new Region();
        region.setEntityId(VALID_REGION_ID);
        region.setPage(page);
        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(defaultRegionPermissionEvaluator.hasPermission(mockAuthentication, region, ModelPermissionEvaluator.Permission.ADMINISTER), is(true));
        verify(mockAuthentication);
    }
View Full Code Here

        region.setPage(page);
        regionWidget = new RegionWidget();
        regionWidget.setEntityId(VALID_REGION_WIDGET_ID);
        regionWidget.setRegion(region);
        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(defaultRegionWidgetPermissionEvaluator.hasPermission(mockAuthentication, regionWidget, Permission.ADMINISTER), is(true));
        verify(mockAuthentication);
    }
View Full Code Here

        user2.setEntityId(VALID_USER_ID2);
        user2.setUsername(VALID_USERNAME2);

        mockAuthentication = createMock(Authentication.class);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl("ROLE_USER"));

    }
View Full Code Here

    }

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

    private Authentication createAuthenticationToken(String username, String password, String... roles) {
        Authentication authToken;
        if (roles != null && roles.length > 0) {
            List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(roles.length);
            for (int i = 0; i < roles.length; i++) {
                authorities.add(new GrantedAuthorityImpl(roles[i]));
            }
            authToken = new UsernamePasswordAuthenticationToken(username, password, authorities);
        } else {
            authToken = new UsernamePasswordAuthenticationToken(username, password);
        }
View Full Code Here

  private static Collection<GrantedAuthority> createGrantedAuthorities(String roles[]) {
    Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
    if (roles != null) {
      for (String role : roles) {
        authorities.add(new GrantedAuthorityImpl(role.trim()));
      }
    }
    authorities.add(new GrantedAuthorityImpl(Constants.BLOG_READER_ROLE));

    return authorities;
  }
View Full Code Here

    assertEquals("profile", user.getProfile());
    assertEquals("true", user.getPreference("testPreference"));

    Collection<GrantedAuthority> authorities = user.getAuthorities();
    assertEquals(2, authorities.size());
    assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_OWNER_ROLE)));
    assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_READER_ROLE)));
  }
View Full Code Here

    assertEquals("username", user.getUsername());
    assertEquals("password", user.getPassword());

    Collection<GrantedAuthority> authorities = user.getAuthorities();
    assertEquals(2, authorities.size());
    assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_OWNER_ROLE)));
    assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_READER_ROLE)));
  }
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.