Package org.springframework.security.core.authority

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


    @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


   */
  public Collection<GrantedAuthority> convertRolesToAuthorities(Collection<RoleEntity> roleEntities) {
    List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(roleEntities.size());

    for (RoleEntity roleEntity : roleEntities) {
      authorities.add(new SimpleGrantedAuthority(roleEntity.getRoleName().toUpperCase()));
    }

    return authorities;
  }
View Full Code Here

   */
  public Collection<GrantedAuthority> convertRolesToAuthorities(Collection<RoleEntity> roleEntities) {
    List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(roleEntities.size());

    for (RoleEntity roleEntity : roleEntities) {
      authorities.add(new SimpleGrantedAuthority(roleEntity.getRoleName().toUpperCase()));
    }

    return authorities;
  }
View Full Code Here

        template.setExpired(true);
        template.setLocked(true);
        template.setOpenId("TEST_O");
        template.setForgotPasswordHash("TEST_P");
        template.setForgotPasswordTime(new Date());
        template.addAuthority(new AuthorityImpl(new SimpleGrantedAuthority("HOO")));


        JpaUser jpaTemplate = converter.convert(template);

        assertThat(jpaTemplate, is(not(sameInstance(template))));
View Full Code Here

        auths.addAll(role.getAppAuths());
      }
     
      List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        for (AppAuth auth : auths) {
          authorities.add(new SimpleGrantedAuthority(auth.getAuthCode()));
        }
        return authorities;
    }
View Full Code Here

    protected String doExecute(final boolean dryRun) throws JobExecutionException {
        // PRE: grant all authorities (i.e. setup the SecurityContextHolder)
        final List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();

        for (Entitlement entitlement : entitlementDAO.findAll()) {
            authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
        }

        final UserDetails userDetails = new User("admin", "FAKE_PASSWORD", true, true, true, true, authorities);

        SecurityContextHolder.getContext().setAuthentication(
View Full Code Here

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

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

    }
View Full Code Here

    }

    // -------------------
    @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

        template.setExpired(true);
        template.setLocked(true);
        template.setOpenId("TEST_O");
        template.setForgotPasswordHash("TEST_P");
        template.setForgotPasswordTime(new Date());
        template.addAuthority(new AuthorityImpl(new SimpleGrantedAuthority("HOO")));


        JpaUser jpaTemplate = converter.convert(template);

        assertThat(jpaTemplate, is(not(sameInstance(template))));
View Full Code Here

        personProfileSubPage.setOwner(user);
        personProfileSubPage.setPageType(PageType.PERSON_PROFILE);
        personProfileSubPage.setParentPage(personProfilePage);

        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new SimpleGrantedAuthority("ROLE_USER"));
    }
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.