Package org.springframework.security.core.authority

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


    }

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


    }

    public void testParser39InRoleRule() {
        SecurityContext context = new SecurityContextImpl();
        List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>();
        roles.add(new GrantedAuthorityImpl("ADMIN_ROLE"));
        roles.add(new GrantedAuthorityImpl("USER_ROLE"));

        context.setAuthentication(new TestingAuthenticationToken("username", "username", roles));
        SecurityContextHolder.setContext(context);

        String text = "{firstName: inRole('USER_ROLE') == true : 'Current user must be in USER_ROLE'}";
View Full Code Here

    final ArrayList<GrantedAuthority> rightsGrantedAuthorities = new ArrayList<GrantedAuthority>(rights.size());

    // now create for all rights a GrantedAuthority entry
    // and fill the GrantedAuthority List with these authorities.
    for (final SecRight right : rights) {
      rightsGrantedAuthorities.add(new GrantedAuthorityImpl(right.getRigName()));
    }

    return rightsGrantedAuthorities;
  }
View Full Code Here

      roles.add("ROLE_AUTOMATIC_MEDIATOR");
    } else {
      roles.add("ROLE_MANUAL_MEDIATOR");
    }
    for (String role : roles) {
      authorities.add(new GrantedAuthorityImpl(role));
    }
    return authorities;
  }
View Full Code Here

    Set<String> roles = new HashSet<String>();
      roles.add("ROLE_ROOT");       
      //roles.add("ROLE_MEDIATOR");
      roles.add("ROLE_ADMIN");
    for (String role : roles) {
      authorities.add(new GrantedAuthorityImpl(role));
    }
    return authorities;
  }
View Full Code Here

    java.util.Collection<GrantedAuthority> authorities =
        new java.util.ArrayList<GrantedAuthority>();
    Set<String> roles = new HashSet<String>();
      roles.add("ROLE_ADMIN");       
    for (String role : roles) {
      authorities.add(new GrantedAuthorityImpl(role));
    }
    return authorities;
  }
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

    rule.setAttributes(attributes);
    return rule;
  }

  private Authentication getAuthentication() {
    List<GrantedAuthority> authorities = Arrays.<GrantedAuthority> asList(new GrantedAuthorityImpl("ROLE_1"),
        new GrantedAuthorityImpl("ROLE_2"), new GrantedAuthorityImpl("ROLE_3"));
    return new UsernamePasswordAuthenticationToken("test", "", authorities);
  }
View Full Code Here

    }
    catch (LDAPException localLDAPException) {
    }
    if ((displayName != null) && (!displayName.equals(""))) {
      Collection auths = new ArrayList();
      auths.add(new GrantedAuthorityImpl("ROLE_USER"));
      log.info("登录成功:" + username);
      SkyUser user = new SkyUser(username, arg1.getCredentials().toString(),
        true, true, true, true, auths);
      user.setDispalyName(displayName);
      return user;
View Full Code Here

    }
   
    @Test
    public void testHasRole() {   
        List<GrantedAuthority> grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl(VALID_ROLE));
               
        expect(authentication.getAuthorities()).andReturn(grantedAuthoritiesList).anyTimes();
        replay(authentication);
       
        assertThat(AuthenticationUtils.hasRole(authentication, VALID_ROLE), is(true));
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.